[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Namespace attached to host doc rather than payload
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|