xsl-list
[Top] [All Lists]

RE: [xsl] [Fwd: Excluding unused and duplicate namespace declarations]

2007-03-19 03:19:51
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.

No, that will only stop new namespaces being added...

If you want to remove existing namespaces, try:

<xsl:template match="/">
  <xsl:copy-of select="." copy-namespaces="no"/>
</xsl:template>

Or if you want to do this in the course of a transformation, use a modified
version of the identity template:

<xsl:template match="*">
  <xsl:element name="name()" namespace="namespace-uri()">
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:element>
</xsl:template>

Of course, this may also remove namespaces that are in fact used, if they
are only used "in content" as distinct from being used in element and
attribute names.

Michael Kay
http://www.saxonica.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>