xsl-list
[Top] [All Lists]

Re: [xsl] Excluding unused and duplicate namespace declarations

2007-03-19 03:27:36
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(_at_)teleflex(_dot_)com 
<mailto:rpuddephatt(_at_)teleflex(_dot_)com>
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--

Ryan Puddephatt
Software Engineer

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

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [xsl] Excluding unused and duplicate namespace declarations, Ryan Puddephatt <=