- From: Florent Georges <fgeorges@fgeorges.org>
- Date: Wed, 23 Sep 2015 21:53:14 +0200
- To: Abel Braaksma <abel.braaksma@xs4all.nl>
- Cc: Public XSLWG <public-xsl-wg@w3.org>
Hi, I have not checked the specific verses, but the namespace declaration is created because the name of the attribute uses it. That has nothing to do with a namespace node that would be carried by the attribute node. Try with a value that refers to a prefix bound in the context of its creation (as it is necessary for instance when generating an XML Schema, with type="my:type"). The user has to be double careful with the binding for prefix "my". With elements, they carry all the machinery to ensure the namespace bindings. Attribute nodes do not. Regards, -- Florent Georges http://fgeorges.org/ http://h2oconsulting.be/ On 23 September 2015 at 21:30, Abel Braaksma wrote: > 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:54:02 UTC