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

Re: how to remove namespace declarations

Subject: Re: how to remove namespace declarations
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 28 Aug 2007 14:29:05 +0200
Re:  how to remove namespace declarations
Frank Marent wrote:

i have to remove namespace declarations in certain elements. i.e. i have this one:

<Facts xmlns:html="http://www.w3.org/HTML/1998/html4" xmlns:xlink="http://www.w3.org/1999/xlink">
<lotOfElements/>
</Facts>


and i want to get this one:

<Facts>
  <lotOfElements/>
</Facts>

i can't manage to get there. even when i try to remove all attributes
from the element

<xsl:template match="Facts"> <xsl:copy> <xsl:apply-templates select="*"/> </xsl:copy> </xsl:template>

does not remove these unnecessary namespaces.

xsl:copy copies the namespace nodes that are in scope. Use xsl:element instead e.g.
<xsl:template match="Facts">
<xsl:element name="Facts">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>


Or, if you are using XSLT 2.0, I think you can do e.g.
  <xsl:template match="Facts">
    <xsl:copy copy-namespaces="no">
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

Note that <xsl:apply-templates select="@* | node()"/> would not hurt as in the XPath/XSLT data model namespace declarations are not attribute nodes but rather result in namespace nodes.

--

	Martin Honnen
	http://JavaScript.FAQTs.com/

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.