RE: [XSLT2] 11.1.4 ns alias: implementation-dependent prefixes

> Section 11.1.4 (Namespace Aliasing) of the XSLT 2.0 WD states 
> that "The namespace prefix that will be used in the 
> serialized output document 
> is implementation-dependent."
> 
> I think the specification should either provide a way to let 
> the user choose the serialized prefix, or define unambigously 
> which prefix will be used.

I have some sympathy with the idea that we should try to make this more
interoperable, however, I think we need to retain the principle that
prefixes are not held in element and attribute nodes, only in namespace
nodes, and this constrains the solution.

In fact, I think the example we have added to XSLT 2.0 is inconsistent with
what the specification says. Suppose you write:

<xsl:stylesheet
  version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:axsl="file://namespace.alias">

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

<xsl:template match="/">
  <axsl:template match="xsl:template"/>
</xsl:template>

</xsl:stylesheet>

Then the axsl:template element in the stylesheet has a namespace node
(axsl=file://namespace.alias), and the effect of the rules as written is
that the result tree must therefore have a namespace node
(axsl=http://www.w3.org/1999/XSL/Transform). Therefore, the namespace
declaration xmlns:axsl="http://www.w3.org/1999/XSL/Transform" must appear in
the serialized result. Contrariwise, there is nothing that obliges the
processor to include the namespace declaration
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" in the result, though the
rules for namespace fixup allow this, I think, as an additional namespace.

> 
> I have two use cases in mind:
> 1. The prefix (within a QName) appears within the data of the 
> resulting XML. For example, a stylesheet that generates a 
> stylesheet which in turn processes as stylesheet. 
> <xsl:template match="...">
>    <axsl:template match="xsl:template"> <!-- or 
> match="axsl:template" ? -->
>       ...
>    </axsl:template>
> </xsl:template>
> 
> Saxon 7.6.5 chooses to use the xsl prefix, so only the 
> version above works. Xalan 2.5.1 uses the axsl prefix, so 
> only the other version would work. (Saxon 6.5.3 declares both 
> prefixes in the result, so this might be a solution.)

If my analysis above is correct, it is safe to write match="axsl:template",
and Saxon 7.6.5 is getting it wrong.

> 
> 2. The result uses the xml namespace 
> http://www.w3.org/XML/1998/namespace.
> <xsl:namespace-alias 
> stylesheet-prefix="axml" result-prefix="xml" />  
> <xsl:template match="...">
>    <result axml:space="preserve">
>       <xsl:apply-templates />
>    </result>
> </xsl:template>
> According to XML Namespaces 1.1 (Section 3; Namespace constraints), 
> no other than the xml prefix may be bound to the namespace 
> http://www.w3.org/XML/1998/namespace.
> 
> That means in this case the result shouldn't use the axml 
> prefix for the serialized output.
> 

Correct. As it happens, I have already added a note to the current internal
draft that points this out.

Michael Kay

Received on Tuesday, 2 September 2003 06:30:38 UTC