Re: Parentless attribute nodes and namespaces, text says it is disallowed, processors appear to allow it

On 24 September 2015 at 09:23, Abel Braaksma wrote:

Hi,

> <xsl:variable name="attr" as="attribute()+">
>     <xsl:attribute name="t:test" namespace="urn:my" />
>     <xsl:attribute name="t:test2" namespace="urn:my2" />
> </xsl:variable>

This uses namespace fixup, but no namespace nodes (each named node as
a QName has a name, which caries the namespace URI, as opposed to
namespace nodes which are explicit namespace bindings as values, to
allow the user to ensure some specific bindings are in the output,
typically for when content uses prefixes to be resolved like if they
were used in names in the same scope).

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

> I think you mean something like:

> <xsl:variable name="attr" as="attribute()+" xmlns:t="urn:other">
>     <xsl:attribute name="t:test" />
> </xsl:variable>

Precisely.

> Which works as expected as well

Well, not as I would expect...  But indeed, it does bind the prefix
"t" in the output, both in Saxon and MarkLogic.  I used to following
to test:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
   <xsl:template name="main">
      <result>
         <xsl:variable name="attr" as="attribute()" xmlns:t="urn:other">
            <xsl:attribute name="t:test"/>
         </xsl:variable>
         <xsl:sequence select="$attr"/>
      </result>
   </xsl:template>
</xsl:stylesheet>

I think this is a correct example that should NOT bind the prefix in
the output.  I can't explain how it is, and I cannot find a definitive
answer whether this is compliant behaviour or not (from the same
excerpt as you cite, I would say it is not).

Anyone else?

Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/

Received on Sunday, 27 September 2015 17:19:26 UTC