RE: [xsl] Namespace-aliasing and excluded namespaces

Subject: RE: [xsl] Namespace-aliasing and excluded namespaces
From: "Buchcik, Kasimier" <k.buchcik@xxxxxxxxxxxx>
Date: Wed, 10 May 2006 20:50:51 +0200
Hi,

> -----Original Message-----
> From: Buchcik, Kasimier [mailto:k.buchcik@xxxxxxxxxxxx]

[...]

It seems like the XSLT 2.0 rules produce an effect,
which hinders the elimination of the stylesheet's XSLT-namespace
declaration with the prefix "xsl":

"ns-alias-1.xsl"
----------------
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:axsl="http://www.w3.org/1999/XSL/Transform-alias";
  xmlns:my-xsl="http://www.w3.org/1999/XSL/Transform";
  exclude-result-prefixes="axsl xsl my-xsl">

  <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="my-xsl"/>

  <xsl:template match="/">
    <axsl:stylesheet version="2.0"/>
  </xsl:template>

</xsl:stylesheet>


Result with Saxon 8.1.1:

<my-xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:my-xsl="http://www.w3.org/1999/XSL/Transform"/>

This is just an observation; I doubt anyone insists on generating
an other prefix than the one used for the stylesheet itself.


* Another observation is that this effect will also preserve the
XSLT-namespace declarations produced by templates of imported/included
stylesheets if the prefix differs:

Result with Saxon 8.1.1:

<?xml version='1.0' ?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template name="foo">
    <!-- Note the XSLT-namespace declaration with the prefix "xslt" in
the result. -->
    <zoo xmlns:xslt="http://www.w3.org/1999/XSL/Transform"/>
  </xsl:template>
</xsl:stylesheet>

Scenario:

"ns-alias-2.xsl"
----------------
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:axsl="http://www.w3.org/1999/XSL/Transform-alias";
  exclude-result-prefixes="axsl xsl">
  <xsl:output indent="yes"/>

  <xsl:include href="ns-alias-inc.xsl"/>

  <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>

  <xsl:template match="/">
    <axsl:stylesheet version="2.0">
      <axsl:template name="foo">
        <xsl:call-template name="zoo"/>
      </axsl:template>
    </axsl:stylesheet>
  </xsl:template>

</xsl:stylesheet>

"ns-alias-imp.xsl"
------------------
<xslt:stylesheet version="2.0"
xmlns:xslt="http://www.w3.org/1999/XSL/Transform";>
  <xslt:template name="zoo">
    <!-- Note the XSLT-namespace declaration with the prefix "xslt" in
the result. -->
    <zoo/>
  </xslt:template>
</xslt:stylesheet>

Regards,

Kasimier

Current Thread