Example 4.1. XPath expression examples applied on Example D.1 (page )
/cellar-book/owner/cellar-book/cellar/wine[quantity<2]
/cellar-book/cellar/wine[1]
//postal-code/..
/cellar-book/owner/street
//wine/@code
//cat:wine/@codea
//wine[last()]/@code
/cellar-book/cellar/wine[1]/comment/cat:bold
sum(/cellar-book/cellar/wine/quantity)
for $w in //wine return
concat($w/quantity,':',//cat:wine/@code[.=$w/@code]/../@name) //cat:wine[cat:origin/cat:country='France' and cat:price<20]
![]()
|
The
|
|
The wines for which we have 2 bottles or less. The nodes returned are
the
|
|
The first wine of the cellar. Result: node at line 120. |
|
The elements which contain a
|
|
The street of the cellar's owner. Result:
|
|
The value of the
|
|
The value of the
|
|
The code of the last wine of the cellar. Result:
|
|
The
|
|
Total number of bottles in the cellar by applying the predefined
XPath function
|
|
Sequence of 4 strings each giving the number of bottles of each wine
in the cellar, followed by a colon and the name of the corresponding
wine:
|
|
Sequence of French wines in the catalog costing less than 20 dollars: wines that start on lines 24 and 42. |