- From: Abel Braaksma <abel.braaksma@xs4all.nl>
 - Date: Wed, 23 Sep 2015 21:30:03 +0200
 - To: "Public XSLWG" <public-xsl-wg@w3.org>
 
I was wondering if the statement we have about parentless attribute nodes is still valid. Under 5.8 Sequence Constructors we say:
<quote>
Parentless attribute nodes require particular care because they have no namespace nodes associated with them. A parentless attribute node is not permitted to contain namespace-sensitive content (for example, a QName or an XPath expression) because there is no information enabling the prefix to be resolved to a namespace URI. Parentless attributes can be useful in an application (for example, they provide an alternative to the use of attribute sets: see 10.2 Named Attribute Sets) but they need to be handled with care.
</quote>
For instance, if I write something like this:
<xsl:template match="x">
   <xsl:copy>
     <xsl:variable name="attr" as="attribute()">
        <xsl:attribute name="test" namespace="urn:myns" />
     </xsl:variable>
     <xsl:copy-of select="$attr" />
   </xsl:copy>
</xsl:template>
It creates <x ns1:test="" xmlns:ns1="urn:myns" />
I doubt it should fail as the test suggests. When I try this with several processors, they all create a new namespace node with the URI of the namespace attribute and place the new attribute in that namespace. This seems reasonable, but if we allow that as a proper status-quo-in-the-wild (tested in XSLT 2.0 and 3.0), then perhaps we should reconsider that Note. Or am I misinterpreting it?
Also, what is meant by "or an XPath expression"? A namespace node does not *contain* an XPath expression.
The above variable $attr does return a namespace with fn:namespace-uri(), a QName with fn:name() and a local name with fn:local-name(). I cannot use fn:in-scope-prefixes() (requires an element) but I can see the prefix with fn:name().
This looks to me like a contradictio-in-terminus...
Cheers,
Abel
Received on Wednesday, 23 September 2015 19:30:39 UTC