child::chapter[2] ; descendant::toy[attribute::color = "red"] ; child::employee[secretary] ; (1 to 100)[. mod 5 eq 0] ; 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 ; $unit-price - $unit-discount ; -($bellcost + $whistlecost) ; $book1/author eq "Kennedy" ; 5 eq 5 ; $book1/author = "Kennedy" ; //book[isbn="1558604820"] is //book[call="QA76.9 C3845"] ; 5 is 5 ; //purchase[parcel="28-451"] << //sale[parcel="33-870"] ; 1 = 1 and 2 = 2 ; 1 = 1 or 2 = 3 ; 1 = 2 and 3 div 0 = 47 ; 1 = 1 or 3 div 0 = 47 ; 1 = 1 and 3 div 0 = 47 ; Harold and the Purple Crayon Crockett Johnson ;

Here is a query.

$i//title

Here is the result of the above query.

{ $i//title }
;

Here is a query.

$i//title

Here is the result of the above query.

Harold and the Purple Crayon
; ; element book { attribute isbn { "isbn-0060229357" }, element author { element first { "Crockett" }, element last { "Johnson" } } } ; Adresse indirizzo ;
123 Roosevelt Ave. Flushing, NY 11368
; element {cast as xs:Qname (data($dict/entry[word=name($e)]/variant[lang="Italian"]))} {$e/node()} ; 123 Roosevelt Ave. Flushing, NY 11368 ; {1, 2, 3} ; {1, "2", "three"} ; I saw 8 cats. ; I saw {5 + 3} cats. ; I saw {5 + 3} cats. ; {$b}{$c} ; ; ; ; 123 Roosevelt Ave. Flushing, NY 11368 ]]> ; {-- This is an XQuery comment --} ; let $s := (, , ) return {$s} ; for $s in (, , ) return {$s} ; for $i in (1, 2), $j in (3, 4) return { $i } { $j } ; for $i in (1, 2), $j in (3, 4) return ($i, $j) ; (1, 3, 1, 4, 2, 3, 2, 4) ; for $i in unordered((1, 2)), $j in unordered((3, 4)) return { $i } { $j } ; for $i in unordered((1, 2)), $j in unordered((3, 4)) return ($i, $j) ; { let $input := document("bib.xml") for $a in distinct-values($input//author) return { { $a/text() } , { for $b in $input//book where $b/author = $a return $b/title } } } ; for $a in distinct-values(//author) return ($a, for $b in //book[$b/author = $a] return $b/title) ; //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) ; some $x in (1, 2, 3), $y in (2, 3, 4) satisfies $x + $y = 4 ; every $x in (1, 2, 3), $y in (2, 3, 4) satisfies $x + $y = 4 ; some $x in (1, 2, "cat") satisfies $x * 2 = 4 ; every $x in (1, 2, "cat") satisfies $x * 2 = 4 ; typeswitch ($animal) case element duck return quack($animal) case element dog return woof($animal) default return "No sound" ; treat as element of type USAddress ($myaddress) ; assert as element of type USAddress ($myaddress) ; validate { $x } ; validate { Elvira Fischbein } ; 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 ; 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 ; schema namespace xhtml="http://www.w3.org/1999/xhtml" at "http:/www.w3.org/1999/xhtml/xhtml.xsd" document("aspect.xhtml")//xhtml:table ; default function namespace = "www.mylib.com" ; define function price(element product in type catalog $p) returns element USPrice in type catalog/product { $p/USPrice } ; 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] }