[xquery-talk] Re: Attribute node whose parent is a document node
Pierrick Brihaye
pierrick.brihaye at free.fr
Sat Jul 9 22:02:18 PDT 2005
Michael Kay a écrit :
> You can also figure it out by reading the spec.
Yes :-) However, it's a difficult exercise. Please consider this (crazy)
example :
let $a :=
<root>
<foo name="bar"/>
<name name="foo">bar</name>
<foo name="bar"/>
</root>
return
<result>{($a//@name|$a//name)}</result>
As discussed earlier, I get an XTDE0420 error from Saxon as mentionned
in http://www.w3.org/TR/xslt20/#error-summary :
> It is a non-recoverable dynamic error if the result sequence used to construct the content of a document node contains a namespace node or attribute node.
However, in http://www.w3.org/TR/xquery/#dt-direct-elem-const, we have :
> If the content sequence contains an attribute node following a node that is not an attribute node, a type error is raised [err:XQTY0024].
Aren't we in this case ? Am I faced to an XSLT or an XQuery error ?
However :
> attributes consist of all the attributes specified in the start tag as described in 3.7.1.1 Attributes, together with all the attribute nodes in the content sequence, in implementation-dependent order.
How should I interpret "all the attribute nodes in the content sequence"
? Aren't there 3 attributes in my content sequence as demonstrated by :
let $a :=
<root>
<foo name="bar"/>
<name name="foo">bar</name>
<foo name="bar"/>
</root>
return
for $b in $a//@name
return <attribute>{$b}</attribute>
which obviously returns :
<attribute name="bar"/>
<attribute name="foo"/>
<attribute name="bar"/>
But... how does this cope with the definition given at
http://www.w3.org/TR/xpath20/#dt-document-order ?
Furthermore, am I not in the case where :
> If two or more of these attributes have the same node-name, a dynamic error is raised [err:XQDY0025]. Note that the parent property of each of these attribute nodes has been set to the newly constructed element node.
... and thus get an XQDY0025 error ?
PS or course explicitely ordering my sequence :
let $a :=
<root>
<foo name="bar"/>
<name name="foo">bar</name>
<foo name="bar"/>
</root>
<result>{($a//@name,$a//name)}</result>)
...returns no error:
<result name="bar">
<name name="foo">bar</name>
</result>
... although I may have wanted 2 attributes in my <result> element (this
should be fixed in the next version, shouldn't it ?).
Cheers,
p.b.
More information about the talk
mailing list