[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Change Namespace of element and children
Thanks all for the quick responses. I made a template match that remakes all of the elements passing through. Works as expected. <xsl:template match="*"> <xsl:element name="{local-name()}" namespace="http://www.mystuff.com"> <xsl:apply-templates select="@*|*|text()"/> </xsl:element> </xsl:template> -----Original Message----- From: Michael Kay [mailto:mike@xxxxxxxxxxxx] Sent: Wednesday, August 31, 2005 4:28 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: Change Namespace of element and children You can change the namespace for MySubElement1 in exactly the same way as you changed the namespace for MyElement. It won't happen automatically: the namespace of an element is determined entirely by the way you create that element, and not by the namespace of its new parent. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Kevin L. Cobb [mailto:kevin.cobb@xxxxxxxxxxxx] > Sent: 31 August 2005 20:33 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Change Namespace of element and children > > > Hi All, new to the list but not new to XSLT. > > I want to change the namespace of an element using XSLT. My problem > is, I can change the namepsace of a single element easily by doing a > template match and then simply re-adding the element and specifying > the new namespace ... like so: > > <xsl:template match="MyElement"> > <xsl:element name="MyElement" > namespace="http://www.mystuff.com"> > <xsl:apply-templates select="@*|*|text()"/> > </xsl:element> > </xsl:template> > > But, the problem is, child elements of MyElement end up with the > default > (empty) namespace ... like so: > > <MyElement xmlns=http://www.mystuff.com"> > <MySubElement1 xmlns="">12345</MySubElement1> > <MySubElement2 xmlns="">12345</MySubElement2> </MyELement> > > > Any ideas? > > Thanks, > > - Kevin
|
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
|