child::school/(child::faculty | child::staff)/child::address ; child::chapter[2] ; descendant::toy[attribute::color = "red"] ; child::employee[secretary] ; child::figref[1]/attribute::refid=>figure ; attribute::manager=>emp/attribute::manager=>emp ; (10, 1, 2, 3, 4) ; (10, (1, 2), (), (3, 4)) ; (salary, bonus) ; ($price, $price) ; (10, 1 to 4) ; ($salary + $bonus) div 12 ; $emp/hiredate - $emp/birthdate ; $paper/deadline - $paper/worktime ; $unit-price - $unit-discount ; -($bellcost + $whistlecost) ; $book1/author eq "Kennedy" ; $book1/author = "Kennedy" ; //book[isbn="1558604820"] == //book[call="QA76.9 C3845"] ; //purchase[parcel="28-451"] << //sale[parcel="33-870"] ; Harold and the Purple Crayon Crockett Johnson ;

Here is a query.

$i//title

Here is the result of the above query.

{ $i//title }
; ; ; element book { attribute isbn { isbn-0060229357 }, element author { element first { "Crockett" }, element last { "Johnson" } } } ; element {$dict/entry[word=name($e)]/variant[lang="Italian"]} {$e/node()} ;
123 Roosevelt Ave. Flushing, NY 11368
]]> ; //book[price > 100] sortby (author[1], title) ; {for $p in distinct-values(document("bib.xml")//publisher) return {$p/text()} {for $b in document("bib.xml")//book[publisher = $p] return {$b/title} {$b/price} sortby(price descending) } sortby(name) } ; (employees sortby (salary))/name ; for $e in (employees sortby (salary)) return $e/name ; if ($widget1/unit-cost < $widget2/unit-cost) then $widget1 else $widget2 ; if ($part/@discounted) then $part/wholesale else $part/retail ; every $part in //part satisfies $part/@discounted ; some $emp in //employee satisfies ($emp/bonus > 0.25 * $emp/salary) ; namespace foo = "http://www.foo.com" Lentils ; Lentils ; { //foo:bing } ; namespace xx = "http://www.foo.com" let $i := Lentils return $i/xx:bing ; Lentils ; {-- Error: attempt to redefine 'xx' in NamespaceDecl --} namespace xx = "http://www.foo.com" namespace xx = "http://www.bar.com" //xx:bing ; {-- Error: use of undeclared namespace prefix --} //xx:bing ; namespace xx = "http://www.fee.com" One Two Three ; One Two Three ; namespace foo = "http://www.foo.com" let $i := 123 return $i/foo:bing ; default element namespace = "http://www.foo.com" Lentils ; Lentils ; schema "http://www.w3.org/1999/xhtml at http:/www.w3.org/1999/xhtml/xhtml.xsd" namespace xhtml = "http://www.w3.org/1999/xhtml" document("aspect.xhtml")//xhtml:table ; default function namespace = "www.mylib.com" ; define function summary(element employee* $emps) returns element dept* { for $d in distinct-values($emps/deptno) let $e := $emps[deptno = $d] return {$d} {count($e)} {sum($e/salary)} } summary(document("acme_corp.xml")//employee[location = "Denver"]) ; define function depth(element $e) returns xs:integer { {-- An empty element has depth 1 --} {-- Otherwise, add 1 to max depth of children --} if (empty($e/*)) then 1 else max(for $c in $e/* return depth($c)) + 1 } depth(document("partlist.xml")) ; { filter(document("cookbook.xml") // (section | section/title | section/title/text())) } ; { for $i in document("catalog.xml")//:item, $p in document("parts.xml")//part[partno = $i/partno], $s in document("suppliers.xml")//supplier[suppno = $i/suppno] return { $p/description, $s/suppname, $i/price } sortby(description, suppname) } ; for $s in document("suppliers.xml")//supplier return { $s/suppname, for $i in document("catalog.xml")//:item [suppno = $s/suppno], $p in document("parts.xml")//part [partno = $i/pno] return $p/description sortby(.) } sortby(suppname) ; { for $s in document("suppliers.xml")//supplier return { $s/suppname, for $i in document("catalog.xml")//:item [suppno = $s/suppno], $p in document("parts.xml")//part [partno = $i/partno] return { $p/description, $i/price } sortby (description) } sortby (suppname) , {-- parts that have no supplier --} { for $p in document("parts.xml")//part where empty(document("catalog.xml")//:item [partno = $p/partno] ) return $p/description sortby (.) } } ; for $pn in distinct-values(document("catalog.xml")//partno) let $i := document("catalog.xml")//:item[partno = $pn] where count($i) >= 3 return {$pn} {avg($i/price)} sortby(partno) ; { let $proc := //procedure[1] for $n in $proc//node() where $n follows ($proc//incision)[1] and $n precedes ($proc//incision)[2] return $n } ; for $p in //procedure where some $i in $proc//incision satisfies empty($proc//anesthesia[. precedes $i]) return $p ; let $intro := //h2[text()="Introduction"], $next-h := //(h1|h2)[. follows $intro][1] return
{ $intro, if (empty($next-h)) then //node()[. follows $intro] else //node()[. follows $intro and . precedes $next-h] }