[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Change Namespace of element and children

Subject: Re: Change Namespace of element and children
From: Evan Lenz <evan@xxxxxxxxxxxx>
Date: Wed, 31 Aug 2005 13:05:00 -0700
xslt change namespace
Hi Kevin,

If you declare the namespace as a default namespace in your stylesheet, then it will be used for all unprefixed element names, whether you use xsl:element or a literal result element.

So you'd want this:

<xsl:stylesheet ... xmlns="http://www.mystuff.com">

The bottom line is that the element has to be associated with the namespace you want wherever it appears in the stylesheet. There is no way to dynamically alter the namespace of elements you add, just because you add them inside an element with a different namespace (which is essentially what you were trying to do).

Hope this helps,
Evan

Kevin L. Cobb wrote:

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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.