[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Copy idiom and overriding namespaces: trying to be
> A copy of my last attempt, leaving out > comment nodes and processing instructions: > > <xsl:template match="@*" > > <xsl:copy /> > </xsl:template> > > <xsl:template match="*" > > <xsl:element name="{local-name()}" namespace="{$target-namespace}"> > <xsl:apply-templates select="@* | node()" /> > </xsl:element> > </xsl:template> > Yes, that's a good solution. It doesn't copy any namespaces that aren't actually used, but that's OK if your source document doesn't use QNames-in-content (such as xsi:type="xs:integer"). And it doesn't change the namespace of any attributes. > In short, I could conclude that it is not possible to make a > template only for namespace nodes and change the result tree > namespace when you encounter an input namespace. You can read namespaces nodes using the namespace axis, and in 2.0 you can create namespace nodes using the xsl:namespace instruction; but none of this changes the name of an element or attribute. Element and attribute names consist of a namespace URI plus local name, and to change the namespace URI of the node you need to use the namespace attribute of xsl:element or xsl:attribute. Michael Kay http://www.saxonica.com/
|
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
|