slide 6

Examples of XPath 2.0

Same as XPath 1.0 attribute::security The “ security ” attribute of the context node
Same as XPath 1.0 sum(child::cost) The sum of all the cost children of the context node
Same as XPath 1.0
book/title[contains(.,"XPath")]
title children of the book children of the context node, where the title contains the string “XPath”*
New operator
for x in ...
function
distinct-values()
for $a in distinct-values(/bib/book/author)
return ($a, /bib/book[author = $a]/title)
Returns a sequence of distinct values from author elements inside book elements, each one followed by the title elements belonging to that author