xsl-list
[Top] [All Lists]

RE: [xsl] Namespace-aliasing and excluded namespaces

2006-05-10 11:51:12
Hi,

-----Original Message-----
From: Buchcik, Kasimier [mailto:k(_dot_)buchcik(_at_)4commerce(_dot_)de] 

[...]

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



--~------------------------------------------------------------------
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>
--~--