1 to 3, 5, 7, 11, 13 for $i in 1 to 10 return $i*$i some $i in //item satisfies exists($i/*) if (exists(@price)) then @price else 0 @price > 3 or @cost < 2 $x + ($y * 2) //book | //magazine substring-before(author, ' ') chapter and verse 93.7 sum(for $i in //product return $i/price * $i/qty) avg( (//product)[position()<=5]/price) if (string(@x)) then (: attribute x exists and is non-empty :) @x else "none" 3 (: + if (number(@x)) then (: attribute x exists and is non-zero :) @x else 0 :) 20 mod 3 20 mod -3 -20 mod 3 -20 mod -3 20 idiv 3 20 idiv -3 -20 idiv 3 -20 idiv -3 $X + 1 last()-1 @margin*2 ceiling(count(item) div 3) $seq[position() <= last() idiv 2] item[position() mod 2 = 0] count($list) mod 5 + 1 - @credit 1---1 xdt:dayTimeDuration("P10D") div xdt:dayTimeDuration("PT6H") xdt:dayTimeDuration("-P1D") div xdt:dayTimeDuration("PT1S") xdt:yearMonthDuration("P1M") div xdt:yearMonthDuration("P1Y") ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") [1 + (($date - xs:date("1901-01-06")) div xdt:dayTimeDuration("P1D") mod 7)] $x eq 2 count($x) gt 2 @x eq "yes" @retirement-date ge current-date() @width = 3 @width = @height @width != $x count(*) > 10 sum(SALES) < 10000 position() < last() div 2 not(//@temp <= 0.0) $x > 3 and $x < 8 @name and @address string(@name) and string(@address) true() $x = 5 or $x = 10 @name or @id not(@id) or @id="" //para[position()=1 or position()=last()] para @title book/author/first-name para[@id] para/@id /*/para $paragraphs $sections/body $sections[3]/body $sections/. /contract/clause[3]/subclause[2] //figure city[not(@name=preceding-sibling::city/ @name)] / /price-list /* /child::node() /*/xsl:* //figure ancestor::CHAPTER TITLE descendant::PARA/@style section[1]/clause[3] chapter/section/para/sentence doc('a.xml')/id('Z123') book/(chapter|appendix) child::title title attribute::title @title ancestor::xyz:* *[@width] text()[starts-with(.,'The')] *[@code][position() < 10] *[position() < 10][@code] self::*[not(@code = preceding-sibling::*/@code)] namespace::* self::item comment() @comment() TITLE news:article MathML:* * text() processing-instruction() processing-instruction('ckpt') node() * xt:* title wrox:title *:title parent::node() // comment() child::text() @comment() @category title exists(..) ../@name //figure //book[@category= 'fiction'] //*/* //book/title chapter//footnote .//footnote doc('lookup.xml')//entry $winners//*/@name .//.. chapter//footnote para[position()>1] $para[position()>1] chapter/para[1] (chapter/para)[1] section[@title='Introduction'] section[title] title[substring-before(.,':')] book[not(author=preceding-sibling::author)] para[1] para[last()] para[position()!=1] para[position()=1 to 5] para[last()-1] para[3.2] para[position()] para[position()-1] para[number(@nr)] book[author="P. D. James"][1] book[1][author="P. D. James"] book[position()=1 and author="P. D. James"] */figure | */table book[not(@publisher)] | book[@publisher='Wrox'] (.|..)/title sum( (book|magazine)/@sales) (//* | //@*) [.='nimbus2000'] following::para intersect $chap//* key('a', 'Gilbert') intersect key('a', 'Sullivan') exists(. intersect $arg) @* except @note max(($net, $gross)) for $i in (1 to 4, 8, 13) return $seq[$i] string-join((@a, @b, @c), "-") (@code, "N/A")[1] book/(author, title, isbn) for $n in 1 to 10 return $seq[n] $seq[position() = 1 to 10] string-join( for $i in 1 to $N return " ", "") for $i in 1 to count($S) return ($S[$i], $T[$i]) $paragraphs[23] key('empname', 'John Smith')[@loc='Sydney'] (//section|//subsection) [title='Introduction'] (//@href/doc(.)) [pricelist][1] for $i in 1 to 5 return $i*$i for $i in 0 to 4 return 1 to $i count(for $i in 1 to 8, $j in 1 to 8 return f:square($i, $j)) some $i in //item satisfies $i/price gt 200 some $n in 1 to count($S)-1 satisfies $S[$n] eq S[$n+1] every $p in //person satisfies $p/@dob castable as xs:date some $k in //keyword, $p in //para satisfies contains($p, $k) every $d in //termdef/@id satisfies some $r in //termref satisfies $d eq $r/@def $seq[. instance of node()] if (some $s in $seq satisfies $s instance of node()) then 0 else 1 if (not($seq instance of xdt:anyAtomicType*)) then 0 else 1 $p instance of item()+ if (data(@quantity) instance of xs:string) then if ((@quantity treat as xs:string) = "n/a") then -2 else if ((@quantity treat as xs:string) = "unknown") then -1 else error() else (@quantity treat as xs:integer) + 2 abs(2) abs(-2) abs(-3.7) abs(-1.0e-7) abs(number('NaN')) adjust-time-to-timezone(xs:time("15:00:00+01:00"), $EST) adjust-time-to-timezone(xs:time("15:00:00"), $EST) adjust-time-to-timezone(xs:time("15:00:00+01:00")) adjust-time-to-timezone(xs:time("15:00:00+01:00"), ()) adjust-time-to-timezone(xs:time("15:00:00"), ()) adjust-dateTime-to-timezone(xs:dateTime("2004-03-01T15:00:00+01:00"), $EST) adjust-dateTime-to-timezone(xs:dateTime("2004-03-01T15:00:00"), $EST) adjust-dateTime-to-timezone(xs:dateTime("2004-03-01T15:00:00+01:00")) adjust-dateTime-to-timezone(xs:dateTime("2004-03-01T15:00:00+01:00"), ()) adjust-dateTime-to-timezone(xs:dateTime("2004-03-01T15:00:00"), ()) adjust-date-to-timezone(xs:date("2004-03-01+01:00"), $EST) adjust-date-to-timezone(xs:date("2004-03-01"), $EST) adjust-date-to-timezone(xs:date("2004-03-01+01:00")) adjust-date-to-timezone(xs:date("2004-03-01+01:00"), ()) adjust-date-to-timezone(xs:date("2004-03-01"), ()) avg((1.0, 2.6, 3.0)) avg(()) avg((1, xs:float('3.5'), 5.5)) avg((1, 2, 3)) avg((xdt:dayTimeDuration("P1D"), xdt:dayTimeDuration("PT12H"))) boolean(//emp[@age=21]) boolean(//emp[@age=53]) boolean(number($John/@age)) boolean(number($Mary/@age)) boolean(count($John/*)) boolean(string($John/@surname)) boolean(string($John/@name)) boolean("true") boolean("false") ceiling(1.0) ceiling(1.6) ceiling(17 div 3) ceiling(-3.0) ceiling(-8.2e0) ceiling(number('xxx')) ceiling(-0.5e0) codepoints-to-string((65, 83, 67, 73, 73)) codepoints-to-string(48 to 57) codepoints-to-string(()) codepoints-to-string(64+$n) compare("espace", "espacer") compare("espace", "espacé", $strong) compare("espace", "espacé", $weak) compare("espacer", "espacé", $strong) compare("espacer", "espacé", $weak) concat("a", "b", "c") concat("chap", 3) concat("a", (), (), "b") concat("a", ("b", "c")) contains("Shakespeare", "spear") contains("", "a") contains("Shakespeare", "") contains("", "") contains((), "a") count(//obs) count(//obs/@colors) count(data(//obs/@colors)) count(//@*) count(//obs/@date) count((5 to 10)) data($x/row/@number) data($x/row/@colors) data($x) data($x/row) day-from-date(xs:date("2004-02-28")) day-from-dateTime(xs:dateTime("2004-02-28T13:00:00")) day-from-date(xs:date("2004-07-31+01:00")) day-from-dateTime(xs:dateTime("2004-07-31T23:00:00-05:00")) days-from-dayTimeDuration(xdt:dayTimeDuration("P5DT12H")) days-from-dayTimeDuration(xdt:dayTimeDuration("PT72H")) days-from-dayTimeDuration(xdt:dayTimeDuration("-P1D")) deep-equal((1,2,3), (1,2,3)) deep-equal((1,2,3), (3,2,1)) deep-equal((1,2), (1.0, 2.0)) deep-equal((), ()) deep-equal($doc/e[1], $doc/e[2]) deep-equal($doc/e[1], $doc/e[3], $weak) deep-equal($doc/e[1]/@*, $doc/e[2]/@*, $weak) distinct-values((1, 2, 3, 3.5, 2.0, 1.0)) distinct-values(("A", "B", "C", "a", "b", "c")) distinct-values((xs:time("12:20:02Z"), xs:time("13:20:02+01:00"))) distinct-values((1, "a", current-date())) See also . empty(/para) empty(/para/a) empty(/para/a/@style) empty(/para/b) empty(/para/a[2]) ends-with("a.xml", ".xml") ends-with("a.xml", ".xsl") ends-with("a.xml", "") ends-with("", "") ends-with((), ()) error() error(xs:QName("docbook:invalid-page-ref")) escape-uri("simple.xml", true()) escape-uri("simple.xml", false()) escape-uri("my doc.xml", true()) escape-uri("my doc.xml", false()) escape-uri("f+o.pdf", true()) escape-uri("f+o.pdf", false()) escape-uri("Grüße.html", true()) escape-uri("Grüße.html", false()) See also . exists(/para) exists(/para/a) exists(/para/a/@style) exists(/para/b) exists(/para/a[2]) floor(1.0) floor(1.6e0) floor(17 div 3) floor(-3.0) floor(-8.2e0) floor(number('NaN')) hours-from-time(xs:time("12:35:03.142")) hours-from-dateTime(xs:dateTime("2004-02-28T13:55:30")) hours-from-time(xs:time("23:59:59+01:00")) hours-from-dateTime(xs:dateTime("2004-07-31T22:10:00-05:00")) hours-from-dayTimeDuration(xdt:dayTimeDuration("P5DT12H30M")) hours-from-dayTimeDuration(xdt:dayTimeDuration("PT72H")) hours-from-dayTimeDuration(xdt:dayTimeDuration("-PT36H15M")) index-of(//@colors, "red") index-of(//@colors, "green") index-of(//@colors, "pink") insert-before(1 to 5, 4, (99, 100)) insert-before(1 to 5, 0, 99) insert-before(1 to 5, 10, 99) boolean(//*[lang('de')]) /*/msg[@code="$p"][lang('fr')] local-name(/) local-name(/*) local-name(/*/@*) lower-case("Sunday") lower-case("2+2") lower-case("CÉSAR") A grand little lad was young Albert All dressed in his best, quite a swell With a stick with an horse's head handle The finest that Woolworth’s could sell. matches($e, "grand") matches($e, "^The finest", "m") matches($e, "(^.*$){4}", "m") matches($e, "Albert.*Woolworth's", "s") matches($e, "with", "i") matches("banana", "^(.a)+$") matches("23 May 2003", "^[0-9]+\s[A-Z][a-z]+\s[0-9]+$") matches("", "a*") max((10, 20, -5, 13)) max(("a", "x", "b")) max(2) max(()) min((10, 20, -5, 13)) min(("a", "x", "b")) min(2) min(()) minutes-from-time(xs:time("12:35:03.142")) minutes-from-dateTime(xs:dateTime("2004-02-28T13:55:30")) minutes-from-time(xs:time("00:30:02+01:00")) minutes-from-dateTime(xs:dateTime("2004-07-31T03:10:00+08:30")) minutes-from-dayTimeDuration(xdt:dayTimeDuration("PT12H20M")) minutes-from-dayTimeDuration(xdt:dayTimeDuration("PT210S")) minutes-from-dayTimeDuration(xdt:dayTimeDuration("-PT75M")) month-from-date(xs:date("2004-02-28")) month-from-dateTime(xs:dateTime("2004-02-28T13:00:00")) month-from-date(xs:date("2004-07-31+01:00")) month-from-dateTime(xs:dateTime("2004-07-31T23:00:00-05:00")) months-from-yearMonthDuration(xdt:yearMonthDuration("P1Y3M")) months-from-yearMonthDuration(xdt:yearMonthDuration("P15M")) months-from-yearMonthDuration(xdt:yearMonthDuration("-P1Y3M")) name(/) name(/*) name(/*/@*) namespace-uri(/) namespace-uri(/*) namespace-uri(/*/@security) namespace-uri(/*/namespace::my) namespace-uri-from-QName(expanded-QName('some.uri', invoice)) namespace-uri-from-QName(node-name(@xml:space)) normalize-space(" the &#xa; quick &#x9; brown fox ") normalize-space(" ") normalize-space("piano") normalize-space(()) normalize-unicode("garc¸on") normalize-unicode("garçon", "NFD") not(*) not(normalize-space(@a)) not(author="Kay") number(12.3) number("12.3") number(true()) number("xyz") number("") one-or-more(1) one-or-more((1,2,3)) one-or-more(()) remove((1 to 5), 4) remove((1 to 5), 10) remove((), 1) replace("banana", "a", "o") replace("banana", "(ana|na)", "[$1]") replace("banana", "(an)+", "**") replace("banana", "(an)+?", "**") one:value value resolve-QName($chap/@att-one, $chap) resolve-QName(string($data1), $data1) resolve-QName(string($data2), $data2) resolve-uri("g") resolve-uri("./g") resolve-uri("g/") resolve-uri("/g") resolve-uri("?y") resolve-uri("g?y") resolve-uri("") resolve-uri("#s") resolve-uri("../g") reverse(1 to 5) reverse(1) reverse(()) reverse(ancestor::*) round(3.2) round(4.6e0) round(7.5) round(-7.5) round(-0.0e0) round-half-to-even(1.1742, 2) round-half-to-even(1.175, 2) round-half-to-even(2.5, 0) round-half-to-even(273, -1) round-half-to-even(-8500, -3) seconds-from-time(xs:time("12:35:03.142")) seconds-from-dateTime(xs:dateTime("2004-02-28T13:55:30-01:00")) seconds-from-dayTimeDuration(xdt:dayTimeDuration("PT1M30.5S")) seconds-from-dayTimeDuration(xdt:dayTimeDuration("PT150S")) seconds-from-dayTimeDuration(xdt:dayTimeDuration("-P0.0055S")) starts-with('#note', '#') starts-with('yes', 'yes') starts-with('YES', 'yes') starts-with('yes', '') 17blue string() string(first) string(second) string(@example) string(+47.20) string(2=2) string(*) string-join(("a", "b", "c"), ", ") string-join(("A", "B", "C"), "") string-join("Z", "+") string-join((), "~") string-length("abc") string-length("<>") string-length("""") string-length("") string-length('�') string-length('𠀀') string-to-codepoints("ASCII") string-to-codepoints("𘚠") string-to-codepoints("") subsequence(3 to 10, 2) subsequence(3 to 10, 5, 2) subsequence(1 to 5, 10) subsequence(1 to 10, 2.3, 4.6) substring("abcde", 2) substring("abcde", 2, 2) substring("abcde", 10, 2) substring("abcde", 1, 20) substring-after("my.xml", ".") substring-after("my.xml", "m") substring-after("my.xml", "xml") substring-after("my.xml", "#") substring-after("", "#") substring-after("my.xml", "") substring-before("my.xml", ".") substring-before("my-xml.xml", "xml") substring-before("my.xml", "") substring-before("my.xml", "#") subtract-dates-yielding-dayTimeDuration(xs:date("2005-01-01"), xs:date("2004-07-01")) subtract-dates-yielding-dayTimeDuration(xs:date("2004-02-28"), xs:date("2004-03-01")) subtract-dates-yielding-yearMonthDuration(xs:date("2005-01-01"), xs:date("2004-07-01")) subtract-dates-yielding-yearMonthDuration(xs:date("2005-12-31"), xs:date("2004-06-30")) subtract-dates-yielding-yearMonthDuration(xs:date("2005-03-31"), xs:date("2004-02-29")) subtract-dates-yielding-yearMonthDuration(xs:date("2004-11-01"), xs:date("2004-12-15")) subtract-dateTimes-yielding-yearMonthDuration(xs:dateTime("2005-01-01T12:00:00Z"), xs:dateTime("2004-01-01T18:00:00Z")) sum((1, 2, 3, 4)) sum((1, 2, 3, 4.5)) sum((1, 2, 3.5e0, 4.5)) sum(()) sum((), 0) sum(xdt:dayTimeDuration("P3D"), xdt:dayTimeDuration("PT36H")) sum((), xdt:dayTimeDuration("PT0S")) timezone-from-date(xs:date("2004-02-28")) timezone-from-dateTime(xs:dateTime("2004-02-28T13:00:00-06:00")) timezone-from-time(xs:time("13:00:00+01:00")) timezone-from-dateTime(xs:dateTime("2004-07-31T23:00:00Z")) tokenize("Go home, Jack!", "\W+") tokenize("abc[NL]def[XY]", "\[.*?\]") translate("aba12", "abcd", "ABCD") translate("aba121", "12", "") translate("a\b\c.xml", "\", "/") translate("5,000.00", ".,", ",.") upper-case("Sunday") upper-case("2+2") upper-case("césar") year-from-date(xs:date("2004-02-28")) year-from-dateTime(xs:dateTime("1969-07-20T16:17:00-04:00"))