[xsl] exclude-result-prefixes and xsl:copy issue

Subject: [xsl] exclude-result-prefixes and xsl:copy issue
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Fri, 01 Feb 2002 14:07:14 +0100
Hi,
there is a note about exclude-result-prefixes in the XSLT spec:
> NOTE: ... specifying the prefix
> in the [xsl:]exclude-result-prefixes attribute will avoid
> superfluous namespace declarations in the result tree.
(Quote intentional snipped)

I have a sort of template framework to get HTML snippets into
various final layout (example drastically simplified):
 <t:template xmlns:t="my.namespace">
   <t:content>
    <p>some content</p>
   </t::content>
 </t:template>

 <xsl:stylesheet xmlns:xsl="..." xmlns:t="my.namespace"
   exclude-result-prefixes="t">
  <xsl:template match="t:template">
    <html>
      <body>
        <xsl:call-template name="navigation"/>
        <xsl:apply-templates select="t:content/*"/>
      </body>
    <html>
  </xsl:template>

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

The xsl:copy copies the t namespace node, as explicitely mentioned
in the spec, which in turn is serialized into the result, also more
or less explicitely mentioned in the XSLT 2.0 draft (not so clear
in 1.0), this yields
  <html>
    <body>
      <p xmlns:t="my.namespace">some content</p>
    </body>
  </html>
>From my point of view this is not in the spirit of the note quoted
at the beginning.
Is this an unintended consequence of how the 1.0 standard was written
or are there cases where this behaviour is useful or necessary?
Will it break existing style sheets or will it unnecessarily complicate
implementations if unecessary namespaces would also be excluded
from copied nodes?
Well, meanwhile i helped myself by replacing xsl:copy with
  <xsl:element name="{name()}">

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread