Subject: Re: [xsl] Namespace attached to host doc rather than payload From: david_n_bertoni@xxxxxxxxxx Date: Tue, 17 Jun 2003 22:48:58 -0700 |
> To be conformant with the specification I am trying to meet, the namespace of > the payload document must appear on the "payload" element as above. However, > when I run a stylesheet transformation on the document (using .NET 1.1 > System.Xml.Xsl.XslTransform) the namespace is moved to top-level > "ListRecords" element. Just out of curiousity, is there a reason why the specification imposes this requirement? > <?xml version="1.0" encoding="UTF-8"?> > <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > xmlns:q="http://www.example.com/queue/" exclude-result-prefixes="q" > xmlns:x="http://www.example.com/ex/"> > <xsl:output method="xml" omit-xml-declaration="yes" /> Because the namespace declaration for x appears on the stylesheet element, every literal result element in your stylesheet has a copy of that namespace node: http://www.w3.org/TR/xslt#literal-result-element "The created element node will also have a copy of the namespace nodes that were present on the element node in the stylesheet tree with the exception of any namespace node whose string-value is the XSLT namespace URI (http://www.w3.org/1999/XSL/Transform), a namespace URI declared as an extension namespace (see [14.1 Extension Elements]), or a namespace URI designated as an excluded namespace." So, if you move it to the x:one and x:two literal result elements, that should solve the problem: <xsl:template match="q:one"> <x:one xmlns:x="http://www.example.com/ex/"> <xsl:value-of select="." /> </x:one> </xsl:template> <xsl:template match="q:two"> <x:two xmlns:x="http://www.example.com/ex/"> <xsl:value-of select="." /> </x:two> </xsl:template> You could also use xsl:element to generate these two elements, since xsl:element will not generate namespace nodes in the same way that a literal result element will. After modifying your stylesheet, Xalan-C 1.5 produces the output you require. I suspect msxsl will as well. Dave XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Namespace attached to host do, David Golding | Thread | Re: [xsl] Namespace attached to hos, Jeni Tennison |
RE: [xsl] Using msxsl:script or EXS, Jason | Date | [xsl] XML XSL Question about includ, Anton Wardaschko (PA |
Month |