[xquery-talk] Question on expected XQuery return per standards

Michael Kay mike at saxonica.com
Fri Mar 27 18:57:43 PST 2009


> My belief is that the standard requires that two nodes (p2, 
> p4) should be returned for result sets 1-4 below, because the 
> interpretation of the XPath should in each case be identical. 
> Set 5, on the other hand, should return only p2.

Yes, you're right. Anything else is a bug. I'm surprised - I thought cases
like this were pretty thoroughly covered in the XQuery test suite.

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

> 
> We're seeing different behavior from a couple of XML parsers. 
> Anyone care to read from the stone tablets on this one?
> 
> (: begin query :)
> 
> let $xml :=
>   <root>
>     <div>
>       <p>p1</p>
>       <p>p2</p>
>     </div>
>     <div>
>       <p>p3</p>
>       <p>p4</p>
>     </div>
>   </root>
> 
> return (
>   <set1>{ $xml/descendant-or-self::node()/p[position() eq 2] }</set1>,
>   <set2>{ $xml//p[position() eq 2] }</set2>,
>   <set3>{ $xml/descendant-or-self::node()/p[2] }</set3>,
>   <set4>{ $xml//p[2] }</set4>,
>   <set5>{ $xml/descendant::p[2] }</set5>
> )
> 
> (: end query :)
> 
> David S.
> 
> --
> David Sewell, Editorial and Technical Manager ROTUNDA, The 
> University of Virginia Press PO Box 801079, Charlottesville, 
> VA 22904-4318 USA
> Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
> Email: dsewell at virginia.edu   Tel: +1 434 924 9973
> Web: http://rotunda.upress.virginia.edu/
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk



More information about the talk mailing list