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

Re: Excluding unused and duplicate namespace declara

Subject: Re: Excluding unused and duplicate namespace declarations
From: Ryan Puddephatt <rpuddephatt@xxxxxxxxxxxx>
Date: Mon, 19 Mar 2007 10:27:21 +0000
Re:   Excluding unused and duplicate namespace  declara
Abel,
   Thats correct I did mean prefixes. I found a way to do what I need.

<xsl:template match="/*">
<xsl:copy copy-namespaces="no">
<xsl:namespace name="xsi" select="'http://www.w3.org/2001/XMLSchema-instance'"/>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>


<xsl:template match="@*|node()">
 <xsl:copy copy-namespaces="no">
   <xsl:apply-templates select="@*|node()"/>
 </xsl:copy>
</xsl:template>

This removes all the namespace declarations on all elements and defines the xsi namespace at the top level, meaning it isn't required at each element with an @xsi:nil like it previously was :-)

HTH someone else, thanks to MHK (via XSLT 2.0)

Ryan

Ryan Puddephatt
Software Engineer

Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP

e> rpuddehatt@xxxxxxxxxxxx <mailto:rpuddephatt@xxxxxxxxxxxx>
t> +44(0)1506 407 110
f> +44(0)1506 407 108
w> www.teleflex.com <http://www.teleflex.com>



Abel Braaksma wrote:
Ryan Puddephatt wrote:
Hi all,
I'm trying to remove all the unused and duplicate declarations from my document, but they can change depending on the input, is there an easy way to do this?


Thanks in advance

Ryan

If you transform something with XSLT 2.0, you can set exclude-result-prefixes="#all" on the main xsl:stylesheet or xsl:transform element, which will remove all namespace declarations that are unused.


It doesn't matter whether your prefixes change. If your namespace changes, your whole document (i.e, the identity of your document and nodes) changes and you'll have to pull other tricks. But different namespaces for the same content are unlikely, so I presume you meant prefixes, right?

-- Abel Braaksma
  http://www.nuntia.nl


--


Ryan Puddephatt
Software Engineer

Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP

e> rpuddehatt@xxxxxxxxxxxx <mailto:rpuddephatt@xxxxxxxxxxxx>
t> +44(0)1506 407 110
f> +44(0)1506 407 108
w> www.teleflex.com <http://www.teleflex.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.