RE: [xsl] Attributes with default namespaces? XSLT Rec question..

Subject: RE: [xsl] Attributes with default namespaces? XSLT Rec question..
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 13 Nov 2008 17:19:33 -0000
> A question about the XSLT recommendation..
> 
> If you add the following to your XSLT stylesheet:
>         <test xmlns="http://test";>
>                 <xsl:attribute name="test"/>
>         </test>
> 
> What namespace should that attribute receive? Should the result be:
>         <test xmlns="http://test"; test=""/>

Yes.
> 
> The XSLT 2.0 recommendation states:
>         "If the namespace attribute is not present, then the 
> lexical Qname is expanded into an expanded-QName using the 
> namespace declarations in effect for the xsl:attribute element, not 
> including any default namespace declaration."

That means: you take the prefix and look it up in the set of in-scope
namespace declarations. If there is no prefix, the attribute ends up in no
namespace.

Perhaps it doesn't say this in pedantic detail. However, the process of
expanding a lexical QName is fairly well understood: when there is no
prefix, you either use the default namespace, or you end up with a name that
is in no namespace; this text makes it clear that you don't use the default
namespace, therefore the only option left is to end up in no namespace.

Michael Kay
http://www.saxonica.com/

Current Thread