[xquery-talk] Position operator

Michael Kay mhk at mhk.me.uk
Mon Jan 23 09:08:59 PST 2006


It's purely a matter of operator precedences: [] binds more tightly than /.

Read it, if you prefer, as

for $x in doc("book.xml")/descendant::node()
return $x/child::title[1]

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

> -----Original Message-----
> From: talk-bounces at xquery.com 
> [mailto:talk-bounces at xquery.com] On Behalf Of Ronald Bourret
> Sent: 23 January 2006 08:23
> To: xquery-talk
> Subject: [xquery-talk] Position operator
> 
> I'm missing something obvious here.
> 
> Suppose book.xml contains multiple title elements. Why does:
> 
>     doc("book.xml")//title[1]
> 
> return a sequence of all title elements and:
> 
>     (doc("book.xml")//title)[1]
> 
> return the first title element? I would have thought both 
> queries would 
> return the first title element.
> 
> Thanks,
> 
> -- Ron
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
> 



More information about the talk mailing list