$arg
.
More... The expression fn:abs(10.5)
returns 10.5
.
The expression fn:abs(-10.5)
returns 10.5
.
fn:abs($arg as xs:numeric?) as xs:numeric?
$arg
.
More... The expression fn:abs(10.5)
returns 10.5
.
The expression fn:abs(-10.5)
returns 10.5
.
fn:adjust-date-to-timezone($arg as xs:date?) as xs:date?
fn:adjust-date-to-timezone($arg as xs:date?, $timezone as xs:dayTimeDuration?) as xs:date?
xs:date
value to a specific timezone, or to no timezone at all;
the result is the date in the target timezone that contains the starting instant of
the
supplied date.
More... Assume the dynamic context provides an implicit timezone of -05:00
(-PT5H0M)
.
let $tz-10 := xs:dayTimeDuration("-PT10H")
The expression fn:adjust-date-to-timezone(xs:date("2002-03-07"))
returns xs:date("2002-03-07-05:00")
.
The expression fn:adjust-date-to-timezone(xs:date("2002-03-07-07:00"))
returns xs:date("2002-03-07-05:00")
. ($arg
is converted to
xs:dateTime("2002-03-07T00:00:00-07:00")
. This is adjusted to the
implicit timezone, giving "2002-03-07T02:00:00-05:00"
.
).
The expression fn:adjust-date-to-timezone(xs:date("2002-03-07"),
$tz-10)
returns xs:date("2002-03-07-10:00")
.
The expression fn:adjust-date-to-timezone(xs:date("2002-03-07-07:00"),
$tz-10)
returns xs:date("2002-03-06-10:00")
. ($arg
is converted to the xs:dateTime
"2002-03-07T00:00:00-07:00"
. This is adjusted to the given timezone,
giving "2002-03-06T21:00:00-10:00"
. ).
The expression fn:adjust-date-to-timezone(xs:date("2002-03-07"),
())
returns xs:date("2002-03-07")
.
The expression fn:adjust-date-to-timezone(xs:date("2002-03-07-07:00"),
())
returns xs:date("2002-03-07")
.
fn:adjust-dateTime-to-timezone($arg as xs:dateTime?) as xs:dateTime?
fn:adjust-dateTime-to-timezone($arg as xs:dateTime?, $timezone as xs:dayTimeDuration?) as xs:dateTime?
xs:dateTime
value to a specific timezone, or to no timezone at
all.
More... Assume the dynamic context provides an implicit timezone of -05:00
(-PT5H0M)
.
let $tz-10 := xs:dayTimeDuration("-PT10H")
The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00'))
returns xs:dateTime('2002-03-07T10:00:00-05:00')
.
The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00-07:00'))
returns xs:dateTime('2002-03-07T12:00:00-05:00')
.
The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00'),
$tz-10)
returns xs:dateTime('2002-03-07T10:00:00-10:00')
.
The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00-07:00'),
$tz-10)
returns xs:dateTime('2002-03-07T07:00:00-10:00')
.
The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00-07:00'),
xs:dayTimeDuration("PT10H"))
returns xs:dateTime('2002-03-08T03:00:00+10:00')
.
The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T00:00:00+01:00'),
xs:dayTimeDuration("-PT8H"))
returns xs:dateTime('2002-03-06T15:00:00-08:00')
.
The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00'),
())
returns xs:dateTime('2002-03-07T10:00:00')
.
The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00-07:00'),
())
returns xs:dateTime('2002-03-07T10:00:00')
.
fn:adjust-time-to-timezone($arg as xs:time?) as xs:time?
fn:adjust-time-to-timezone($arg as xs:time?, $timezone as xs:dayTimeDuration?) as xs:time?
xs:time
value to a specific timezone, or to no timezone at
all.
More... Assume the dynamic context provides an implicit timezone of -05:00
(-PT5H0M)
.
let $tz-10 := xs:dayTimeDuration("-PT10H")
The expression fn:adjust-time-to-timezone(xs:time("10:00:00"))
returns xs:time("10:00:00-05:00")
.
The expression fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"))
returns xs:time("12:00:00-05:00")
.
The expression fn:adjust-time-to-timezone(xs:time("10:00:00"),
$tz-10)
returns xs:time("10:00:00-10:00")
.
The expression fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"),
$tz-10)
returns xs:time("07:00:00-10:00")
.
The expression fn:adjust-time-to-timezone(xs:time("10:00:00"), ())
returns xs:time("10:00:00")
.
The expression fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"),
())
returns xs:time("10:00:00")
.
The expression fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"),
xs:dayTimeDuration("PT10H"))
returns xs:time("03:00:00+10:00")
.
fn:analyze-string($input as xs:string?, $pattern as xs:string) as element(fn:analyze-string-result)XP3.0+
fn:analyze-string($input as xs:string?, $pattern as xs:string, $flags as xs:string) as element(fn:analyze-string-result)XP3.0+
In the following examples, the result document is shown in serialized form, with whitespace between the element nodes. This whitespace is not actually present in the result.
The expression fn:analyze-string("The cat sat on the mat.", "\w+")
returns (with whitespace added for legibility):
<analyze-string-result xmlns="http://www.w3.org/2005/xpath-functions"> <match>The</match> <non-match> </non-match> <match>cat</match> <non-match> </non-match> <match>sat</match> <non-match> </non-match> <match>on</match> <non-match> </non-match> <match>the</match> <non-match> </non-match> <match>mat</match> <non-match>.</non-match> </analyze-string-result>
The expression fn:analyze-string("2008-12-03",
"^(\d+)\-(\d+)\-(\d+)$")
returns (with whitespace added for legibility):
<analyze-string-result xmlns="http://www.w3.org/2005/xpath-functions"> <match><group nr="1">2008</group>-<group nr="2" >12</group>-<group nr="3">03</group></match> </analyze-string-result>
The expression fn:analyze-string("A1,C15,,D24, X50,",
"([A-Z])([0-9]+)")
returns (with whitespace added for legibility):
<analyze-string-result xmlns="http://www.w3.org/2005/xpath-functions"> <match><group nr="1">A</group><group nr="2">1</group></match> <non-match>,</non-match> <match><group nr="1">C</group><group nr="2">15</group></match> <non-match>,,</non-match> <match><group nr="1">D</group><group nr="2">24</group></match> <non-match>, </non-match> <match><group nr="1">X</group><group nr="2">50</group></match> <non-match>,</non-match> </analyze-string-result>
fn:apply($function as function(*), $array as array(*)) as item()*XP3.1
The expression fn:apply(fn:concat#3, ["a", "b", "c"])
returns "abc"
.
The expression fn:apply($f, array:subarray(["a", "b", "c", "d", "e", "f"], 1, fn:function-arity($f)))
calls the supplied function $f
supplying the number of arguments required by its arity.
fn:available-environment-variables( ) as xs:string*XP3.0+
fn:environment-variable
, as a (possibly empty) sequence of strings.
More... fn:avg($arg as xs:anyAtomicType*) as xs:anyAtomicType?
$arg
, that is, the
sum of the values divided by the number of values.
More... let $d1 := xs:yearMonthDuration("P20Y")
let $d2 := xs:yearMonthDuration("P10M")
let $seq3 := (3, 4, 5)
The expression fn:avg($seq3)
returns 4.0
. (The result is of type xs:decimal
.)
The expression fn:avg(($d1, $d2))
returns xs:yearMonthDuration("P10Y5M")
.
fn:avg(($d1, $seq3))
raises a type error [err:FORG0006].
The expression fn:avg(())
returns ()
.
The expression fn:avg((xs:float('INF'), xs:float('-INF')))
returns xs:float('NaN')
.
The expression fn:avg(($seq3, xs:float('NaN')))
returns xs:float('NaN')
.
fn:base-uri( ) as xs:anyURI?
fn:base-uri($arg as node()?) as xs:anyURI?
fn:boolean($arg as item()*) as xs:boolean
$arg
.
More... let $abc := ("a", "b", "")
fn:boolean($abc)
raises a type error [err:FORG0006].
The expression fn:boolean($abc[1])
returns true()
.
The expression fn:boolean($abc[0])
returns false()
.
The expression fn:boolean($abc[3])
returns false()
.
fn:boolean([])
raises a type error [err:FORG0006].
fn:ceiling($arg as xs:numeric?) as xs:numeric?
$arg
upwards to a whole number.
More... The expression fn:ceiling(10.5)
returns 11
.
The expression fn:ceiling(-10.5)
returns -10
.
fn:codepoint-equal($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:boolean?
The expression fn:codepoint-equal("abcd", "abcd")
returns true()
.
The expression fn:codepoint-equal("abcd", "abcd ")
returns false()
.
The expression fn:codepoint-equal("", "")
returns true()
.
The expression fn:codepoint-equal("", ())
returns ()
.
The expression fn:codepoint-equal((), ())
returns ()
.
fn:codepoints-to-string($arg as xs:integer*) as xs:string
xs:string
whose characters have supplied ·codepoints·.
More... The expression fn:codepoints-to-string((66, 65, 67, 72))
returns "BACH"
.
The expression fn:codepoints-to-string((2309, 2358, 2378, 2325))
returns "अशॊक"
.
The expression fn:codepoints-to-string(())
returns ""
.
The expression fn:codepoints-to-string(0)
raises error FOCH0001
.
fn:collation-key($key as xs:string) as xs:base64BinaryXP3.1
fn:collation-key($key as xs:string, $collation as xs:string) as xs:base64BinaryXP3.1
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
The expression map:merge((map{collation-key("A", $C):1}, map{collation-key("a",
$C):2}), map{"duplicates":"use-last"})(collation-key("A", $C))
returns 2
. (Given that the keys of the two entries are equal under the rules of
the chosen collation, only one of the entries can appear in the result; the one
that is chosen is the one from the last map in the input sequence.)
The expression let $M := map{collation-key("A", $C):1, collation-key("B", $C):2}
return $M(collation-key("a", $C))
returns 1
. (The strings "A" and "a" have the same collation key under this
collation.)
As the above examples illustrate, it is important that when the
collation-key
function is used to add entries to a map, then it must
also be used when retrieving entries from the map. This process can be made less
error-prone by encapsulating the map within a function: function($k)
{$M(collation-key($k, $collation)}
.
fn:collection( ) as node()*
fn:collection($arg as xs:string?) as node()*
fn:compare($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:integer?
fn:compare($comparand1 as xs:string?, $comparand2 as xs:string?, $collation as xs:string) as xs:integer?
$comparand1
collates before,
equal to, or after $comparand2
according to the rules of a selected
collation.
More... The expression fn:compare('abc', 'abc')
returns 0
.
The expression fn:compare('Strasse', 'Straße')
returns 0
. (Assuming the default collation includes provisions that equate
"ss" and the (German) character "ß"
("sharp-s"). Otherwise, the returned value depends on the
semantics of the default collation.)
The expression fn:compare('Strasse', 'Straße',
'http://www.w3.org/2013/collation/UCA?lang=de;strength=primary')
returns 0
. (The specified collation equates
"ss" and the (German) character "ß"
("sharp-s").)
The expression fn:compare('Strassen', 'Straße')
returns 1
. (Assuming the default collation includes provisions that treat
differences between "ss" and the (German) character "ß"
("sharp-s") with less strength than the differences between the
base characters, such as the final "n". ).
fn:concat($arg1, $arg2, ...)
The expression fn:concat('un', 'grateful')
returns "ungrateful"
.
The expression fn:concat('Thy ', (), 'old ', "groans", "", ' ring',
' yet', ' in', ' my', ' ancient',' ears.')
returns "Thy old groans ring yet in my ancient ears."
.
The expression fn:concat('Ciao!',())
returns "Ciao!"
.
The expression fn:concat('Ingratitude, ', 'thou ', 'marble-hearted', ' fiend!')
returns "Ingratitude, thou marble-hearted fiend!"
.
The expression fn:concat(01, 02, 03, 04, true())
returns "1234true"
.
The expression 10 || '/' || 6
returns "10/6"
.
fn:concatenate($arg1, $arg2)
fn:contains($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean
fn:contains($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean
$arg1
contains $arg2
as a
substring, taking collations into account.
More... The collation used in these examples, http://example.com/CollationA
is a
collation in which both "-" and "*" are ignorable collation units.
"Ignorable collation unit" is equivalent to "ignorable collation element" in [UTS #10].
The expression fn:contains ( "tattoo", "t")
returns true()
.
The expression fn:contains ( "tattoo", "ttt")
returns false()
.
The expression fn:contains ( "", ())
returns true()
. (The first rule is applied, followed by the second
rule.)
The expression fn:contains ( "abcdefghi", "-d-e-f-",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
The expression fn:contains ( "a*b*c*d*e*f*g*h*i*", "d-ef-",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
The expression fn:contains ( "abcd***e---f*--*ghi", "def",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
The expression fn:contains ( (), "--***-*---",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
. (The second argument contains only ignorable collation units and is
equivalent to the zero-length string.)
fn:contains-token($input as xs:string*, $token as xs:string) as xs:booleanXP3.1
fn:contains-token($input as xs:string*, $token as xs:string, $collation as xs:string) as xs:booleanXP3.1
The expression fn:contains-token("red green blue ", "red")
returns true()
.
The expression fn:contains-token(("red", "green", "blue"), " red ")
returns true()
.
The expression fn:contains-token("red, green, blue", "red")
returns false()
.
The expression fn:contains-token("red green blue", "RED", "http://www.w3.org/2005/xpath-functions/collation/html-ascii-case-insensitive")
returns true()
.
fn:count($arg as item()*) as xs:integer
let $seq1 := ($item1, $item2)
let $seq2 := (98.5, 98.3, 98.9)
let $seq3 := ()
The expression fn:count($seq1)
returns 2
.
The expression fn:count($seq3)
returns 0
.
The expression fn:count($seq2)
returns 3
.
The expression fn:count($seq2[. > 100])
returns 0
.
The expression fn:count([])
returns 1
.
The expression fn:count([1,2,3])
returns 1
.
fn:current-date( ) as xs:date
fn:current-date()
returns an xs:date
corresponding to the
current date. For example, a call of fn:current-date()
might return
2004-05-12+01:00
.
fn:current-dateTime( ) as xs:dateTime
fn:current-dateTime()
returns an xs:dateTimeStamp
corresponding to the current date and time. For example, a call of
fn:current-dateTime()
might return
2004-05-12T18:17:15.125Z
corresponding to the current time on May 12,
2004 in timezone Z
.
fn:current-time( ) as xs:time
fn:current-time()
returns an xs:time
corresponding to the
current time. For example, a call of fn:current-time()
might return
23:17:00.000-05:00
.
fn:data($arg as item()*) as xs:anyAtomicType*
fn:data( ) as xs:anyAtomicType*XP3.0+
The expression data(123)
returns 123
.
The expression data((123, 456))
returns 123, 456
.
The expression data([[1,2],[3,4]])
returns 1, 2, 3, 4
.
let $para := <para>In a hole in the ground there lived a <term author="Tolkien">hobbit</term>.</para>
The expression data($para)
returns xs:untypedAtomic("In a hole in the ground there lived a hobbit.")
.
The expression data($para/term/@author)
returns xs:untypedAtomic("Tolkien")
.
The expression data(abs#1)
raises error FOTY0013
.
fn:dateTime($arg1 as xs:date?, $arg2 as xs:time?) as xs:dateTime?
xs:dateTime
value created by combining an xs:date
and an xs:time
.
More... The expression fn:dateTime(xs:date("1999-12-31"),
xs:time("12:00:00"))
returns xs:dateTime("1999-12-31T12:00:00")
.
The expression fn:dateTime(xs:date("1999-12-31"),
xs:time("24:00:00"))
returns xs:dateTime("1999-12-31T00:00:00")
. (This is because "24:00:00"
is an alternate lexical form
for "00:00:00"
).
fn:day-from-date($arg as xs:date?) as xs:integer?
xs:date
.
More... The expression fn:day-from-date(xs:date("1999-05-31-05:00"))
returns 31
.
The expression fn:day-from-date(xs:date("2000-01-01+05:00"))
returns 1
.
fn:day-from-dateTime($arg as xs:dateTime?) as xs:integer?
xs:dateTime
.
More... The expression fn:day-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00"))
returns 31
.
The expression fn:day-from-dateTime(xs:dateTime("1999-12-31T20:00:00-05:00"))
returns 31
.
The expression fn:day-from-dateTime(fn:adjust-dateTime-to-timezone(xs:dateTime("1999-12-31T19:20:00-05:00"),
xs:dayTimeDuration("PT0S")))
returns 1
.
fn:days-from-duration($arg as xs:duration?) as xs:integer?
The expression fn:days-from-duration(xs:dayTimeDuration("P3DT10H"))
returns 3
.
The expression fn:days-from-duration(xs:dayTimeDuration("P3DT55H"))
returns 5
.
The expression fn:days-from-duration(xs:yearMonthDuration("P3Y5M"))
returns 0
.
fn:deep-equal($parameter1 as item()*, $parameter2 as item()*) as xs:boolean
fn:deep-equal($parameter1 as item()*, $parameter2 as item()*, $collation as xs:string) as xs:boolean
let $at := <attendees> <name last='Parker' first='Peter'/> <name last='Barker' first='Bob'/> <name last='Parker' first='Peter'/> </attendees>
The expression fn:deep-equal($at, $at/*)
returns false()
.
The expression fn:deep-equal($at/name[1], $at/name[2])
returns false()
.
The expression fn:deep-equal($at/name[1], $at/name[3])
returns true()
.
The expression fn:deep-equal($at/name[1], 'Peter Parker')
returns false()
.
The expression fn:deep-equal(map{1:'a', 2:'b'}, map{2:'b', 1:'a'})
returns true()
.
The expression fn:deep-equal([1, 2, 3], [1, 2, 3])
returns true()
.
The expression fn:deep-equal((1, 2, 3), [1, 2, 3])
returns false()
.
fn:default-collation( ) as xs:string
fn:default-language( ) as xs:languageXP3.1
fn:distinct-values($arg as xs:anyAtomicType*) as xs:anyAtomicType*
fn:distinct-values($arg as xs:anyAtomicType*, $collation as xs:string) as xs:anyAtomicType*
The expression fn:distinct-values((1, 2.0, 3, 2))
returns some permutation of (1, 3, 2.0)
. (The result may include either the xs:integer
2 or the xs:decimal
2.0).
The expression fn:distinct-values((xs:untypedAtomic("cherry"),
xs:untypedAtomic("plum"), xs:untypedAtomic("plum")))
returns some permutation of (xs:untypedAtomic("cherry"),
xs:untypedAtomic("plum"))
.
fn:doc($uri as xs:string?) as document-node()?
xs:string
, and returns the
corresponding document node.
More... fn:doc-available($uri as xs:string?) as xs:boolean
fn:doc($uri)
would return a document node.
More... fn:document-uri($arg as node()?) as xs:anyURI?
fn:document-uri( ) as xs:anyURI?XP3.0+
fn:element-with-id($arg as xs:string*) as element()*
fn:element-with-id($arg as xs:string*, $node as node()) as element()*
ID
value matching the
value of one or more of the IDREF
values supplied in $arg
.
More... let $emp := validate lax{ document{ <employee xml:id="ID21256" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <empnr xsi:type="xs:ID">E21256</empnr> <first>John</first> <last>Brown</last> </employee> } }
The expression $emp/fn:element-with-id('ID21256')/name()
returns "employee"
. (The xml:id
attribute has the is-id
property,
so the employee element is selected.)
The expression $emp/fn:element-with-id('E21256')/name()
returns "employee"
. (Assuming the empnr
element is given the type
xs:ID
as a result of schema validation, the element will have the
is-id
property and is therefore its parent is selected. Note the
difference from the behavior of fn:id
.)
fn:empty($arg as item()*) as xs:boolean
The expression fn:empty((1,2,3)[10])
returns true()
.
The expression fn:empty(fn:remove(("hello", "world"), 1))
returns false()
.
The expression fn:empty([])
returns false()
.
The expression fn:empty(map{})
returns false()
.
The expression fn:empty("")
returns false()
.
Assuming $in
is an element with no children:
let $break := <br/> return fn:empty($break)
The result is false()
.
fn:encode-for-uri($uri-part as xs:string?) as xs:string
The expression fn:encode-for-uri("http://www.example.com/00/Weather/CA/Los%20Angeles#ocean")
returns "http%3A%2F%2Fwww.example.com%2F00%2FWeather%2FCA%2FLos%2520Angeles%23ocean"
. (This is probably not what the user intended because all of the
delimiters have been encoded.)
The expression concat("http://www.example.com/",
encode-for-uri("~bébé"))
returns "http://www.example.com/~b%C3%A9b%C3%A9"
.
The expression concat("http://www.example.com/", encode-for-uri("100% organic"))
returns "http://www.example.com/100%25%20organic"
.
fn:ends-with($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean
fn:ends-with($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean
$arg1
contains $arg2
as a trailing
substring, taking collations into account.
More... The collation used in these examples, http://example.com/CollationA
is a
collation in which both "-" and "*" are ignorable collation units.
"Ignorable collation unit" is equivalent to "ignorable collation element" in [UTS #10].
The expression fn:ends-with ( "tattoo", "tattoo")
returns true()
.
The expression fn:ends-with ( "tattoo", "atto")
returns false()
.
The expression fn:ends-with ((), ())
returns true()
.
The expression fn:ends-with ( "abcdefghi", "-g-h-i-",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
The expression fn:ends-with ( "abcd***e---f*--*ghi", "defghi",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
The expression fn:ends-with ( "abcd***e---f*--*ghi", "defghi",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
The expression fn:ends-with ( (), "--***-*---",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
. (The second argument contains only ignorable collation units and is
equivalent to the zero-length string.)
The expression fn:ends-with ( "abcdefghi", "ghi-",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
fn:environment-variable($name as xs:string) as xs:string?XP3.0+
fn:error()
fn:error(QName)
fn:error($code as xs:QName?) as xs:string
fn:error($code as xs:QName?, $description as xs:string) as item()*
fn:error(QName?)XP3.1
fn:error
function raises an application-defined error.
More... The expression fn:error()
raises error FOER0000
. (This returns the URI
http://www.w3.org/2005/xqt-errors#FOER0000
(or the corresponding
xs:QName
) to the external processing environment, unless the error
is caught using a try/catch construct in the host language.)
The expression fn:error(fn:QName('http://www.example.com/HR', 'myerr:toohighsal'),
'Does not apply because salary is too high')
raises error myerr:toohighsal
. (This returns http://www.example.com/HR#toohighsal
and the
xs:string
"Does not apply because salary is too high"
(or the corresponding
xs:QName
) to the external processing environment, unless the error
is caught using a try/catch construct in the host language.)
fn:escape-html-uri($uri as xs:string?) as xs:string
The expression fn:escape-html-uri("http://www.example.com/00/Weather/CA/Los Angeles#ocean")
returns "http://www.example.com/00/Weather/CA/Los Angeles#ocean"
.
The expression fn:escape-html-uri("javascript:if (navigator.browserLanguage == 'fr') window.open('http://www.example.com/~bébé');")
returns "javascript:if (navigator.browserLanguage == 'fr') window.open('http://www.example.com/~b%C3%A9b%C3%A9');"
.
fn:exactly-one($arg as item()*) as item()
$arg
if it contains exactly one item. Otherwise, raises an error.
More... fn:exists($arg as item()*) as xs:boolean
The expression fn:exists(fn:remove(("hello"), 1))
returns false()
.
The expression fn:exists(fn:remove(("hello", "world"), 1))
returns true()
.
The expression fn:exists([])
returns true()
.
The expression fn:exists(map{})
returns true()
.
The expression fn:exists("")
returns true()
.
Assuming $in
is an element with no children:
let $break :=
return fn:exists($break)
The result is true()
.
fn:false( ) as xs:boolean
xs:boolean
value false
.
More... The expression fn:false()
returns xs:boolean(0)
.
fn:filter($seq as item()*, $f as function(item()) as boolean) as item()*XP3.0+
The expression fn:filter(1 to 10, function($a) {$a mod 2 = 0})
returns (2, 4, 6, 8, 10)
.
The expression fn:filter((), fn:lang("en", ?))
returns ()
.
fn:floor($arg as xs:numeric?) as xs:numeric?
$arg
downwards to a whole number.
More... The expression fn:floor(10.5)
returns 10
.
The expression fn:floor(-10.5)
returns -11
.
fn:fold-left($seq as item()*, $zero as item()*, $f as function(item()*, item()) as item()*) as item()*XP3.0+
The expression fn:fold-left(1 to 5, 0, function($a, $b) { $a + $b
})
returns 15
. (This returns the sum of the items in the sequence).
The expression fn:fold-left((2,3,5,7), 1, function($a, $b) { $a * $b
})
returns 210
. (This returns the product of the items in the sequence).
The expression fn:fold-left((true(), false(), false()), false(), function($a, $b) {
$a or $b })
returns true()
. (This returns true if any item in the sequence has an effective boolean
value of true).
The expression fn:fold-left((true(), false(), false()), false(), function($a, $b) {
$a and $b })
returns false()
. (This returns true only if every item in the sequence has an effective
boolean value of true).
The expression fn:fold-left(1 to 5, (), function($a, $b) {($b,
$a)})
returns (5,4,3,2,1)
. (This reverses the order of the items in a sequence).
The expression fn:fold-left(1 to 5, "", fn:concat(?, ".", ?))
returns ".1.2.3.4.5"
.
The expression fn:fold-left(1 to 5, "$zero", fn:concat("$f(", ?, ", ", ?, ")"))
returns "$f($f($f($f($f($zero, 1), 2), 3), 4), 5)"
.
The expression fn:fold-left(1 to 5, map{}, function($map, $n) {map:put($map, $n, $n*2)})
returns map{1:2, 2:4, 3:6, 4:8, 5:10}
.
fn:fold-right($seq as item()*, $zero as item()*, $f as function(item(), item()*) as item()*) as item()*XP3.0+
The expression fn:fold-right(1 to 5, 0, function($a, $b) { $a + $b
})
returns 15
. (This returns the sum of the items in the sequence).
The expression fn:fold-right(1 to 5, "", fn:concat(?, ".", ?))
returns "1.2.3.4.5."
.
The expression fn:fold-right(1 to 5, "$zero", concat("$f(", ?, ", ", ?,
")"))
returns "$f(1, $f(2, $f(3, $f(4, $f(5, $zero)))))"
.
fn:for-each($seq as item()*, $action as function(item()) as item()*) as item()*XP3.0+
The expression fn:for-each(1 to 5, function($a) { $a * $a })
returns (1, 4, 9, 16, 25)
.
The expression fn:for-each(("john", "jane"),
fn:string-to-codepoints#1)
returns (106, 111, 104, 110, 106, 97, 110, 101)
.
The expression fn:for-each(("23", "29"), xs:int#1)
returns (23, 29)
.
fn:for-each-pair($seq1 as item()*, $seq2 as item()*, $action as function(item(), item()) as item()*) as item()*XP3.0+
The expression fn:for-each-pair(("a", "b", "c"), ("x", "y", "z"),
concat#2)
returns ("ax", "by", "cz")
.
The expression fn:for-each-pair(1 to 5, 1 to 5, function($a, $b){10*$a + $b})
returns (11, 22, 33, 44, 55)
.
The expression let $s := 1 to 8 return fn:for-each-pair($s, tail($s), function($a, $b){$a*$b})
returns (2, 6, 12, 20, 30, 42, 56)
.
fn:format-date($value as xs:date?, $picture as xs:string) as xs:string?XP3.0+
fn:format-date($value as xs:date?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $place as xs:string?) as xs:string?XP3.0+
xs:date
value formatted for display.
More... fn:format-dateTime($value as xs:dateTime?, $picture as xs:string) as xs:string?XP3.0+
fn:format-dateTime($value as xs:dateTime?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $place as xs:string?) as xs:string?XP3.0+
xs:dateTime
value formatted for display.
More... fn:format-integer($value as xs:integer?, $picture as xs:string) as xs:stringXP3.0+
fn:format-integer($value as xs:integer?, $picture as xs:string, $lang as xs:string?) as xs:stringXP3.0+
The expression format-integer(123, '0000')
returns "0123"
.
format-integer(123, 'w')
might return "one hundred and
twenty-three"
Ordinal numbering in Italian: The specification "1;o(-º)"
with $lang
equal to
it
, if supported, should produce the sequence:
1º 2º 3º 4º ...
The specification "Ww;o"
with $lang
equal to
it
, if supported, should produce the sequence:
Primo Secondo Terzo Quarto Quinto ...
The expression format-integer(21, '1;o', 'en')
returns "21st"
.
format-integer(14, 'Ww;o(-e)', 'de')
might return
"Vierzehnte"
The expression format-integer(7, 'a')
returns "g"
.
The expression format-integer(57, 'I')
returns "LVII"
.
The expression format-integer(1234, '#;##0;')
returns "1;234"
.
fn:format-number($value as xs:numeric?, $picture as xs:string) as xs:stringXP3.0+
fn:format-number($value as xs:numeric?, $picture as xs:string, $decimal-format-name as xs:string?) as xs:stringXP3.0+
The following examples assume a default decimal format in which the chosen digits are the ASCII digits 0-9, the decimal separator is ".", the grouping separator is ",", the minus-sign is "-", and the percent-sign is "%".
The expression format-number(12345.6, '#,###.00')
returns "12,345.60"
.
The expression format-number(12345678.9, '9,999.99')
returns "12,345,678.90"
.
The expression format-number(123.9, '9999')
returns "0124"
.
The expression format-number(0.14, '01%')
returns "14%"
.
The expression format-number(-6, '000')
returns "-006"
.
The following example assumes the existence of a decimal format named 'ch' in which
the grouping separator is ʹ
and the decimal separator is
·
:
The expression format-number(1234.5678, '#ʹ##0·00',
'ch')
returns "1ʹ234·57"
.
The following examples assume that the exponent separator is in decimal format 'fortran' is 'E':
The expression format-number(1234.5678, '00.000E0', 'fortran')
returns "12.346E2"
.
The expression format-number(0.234, '0.0E0', 'fortran')
returns "2.3E-1"
.
The expression format-number(0.234, '#.00E0', 'fortran')
returns "0.23E0"
.
The expression format-number(0.234, '.00E0', 'fortran')
returns ".23E0"
.
fn:format-time($value as xs:time?, $picture as xs:string) as xs:string?XP3.0+
fn:format-time($value as xs:time?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $place as xs:string?) as xs:string?XP3.0+
xs:time
value formatted for display.
More... fn:function-arity($func as function(*)) as xs:integerXP3.0+
The expression fn:function-arity(fn:substring#2)
returns 2
.
The expression fn:function-arity(function($node){name($node)})
returns 1
.
The expression let $initial := fn:substring(?, 1, 1) return
fn:function-arity($initial)
returns 1
.
fn:function-lookup($name as xs:QName, $arity as xs:integer) as function(*)?XP3.0+
The expression fn:function-lookup(xs:QName('fn:substring'), 2)('abcd',
2)
returns 'bcd'
.
The expression (fn:function-lookup(xs:QName('xs:dateTimeStamp'), 1),
xs:dateTime#1)[1] ('2011-11-11T11:11:11Z')
returns an
xs:dateTime
value set to the specified date, time, and timezone; if
the implementation supports XSD 1.1 then the result will be an instance of the
derived type xs:dateTimeStamp
. The query is written to ensure that no
failure occurs when the implementation does not recognize the type
xs:dateTimeStamp
.
The expression let $f := fn:function-lookup(xs:QName('zip:binary-entry'), 2)
return if (exists($f)) then $f($href, $entry) else ()
returns the result of
calling zip:binary-entry($href, $entry)
if the function is available, or
an empty sequence otherwise.
fn:function-name($func as function(*)) as xs:QName?XP3.0+
The expression fn:function-name(fn:substring#2)
returns fn:QName("http://www.w3.org/2005/xpath-functions",
"fn:substring")
. (The namespace prefix of the returned QName is not
predictable.)
The expression fn:function-name(function($node){count($node/*)})
returns ()
.
fn:generate-id( ) as xs:stringXP3.0+
fn:generate-id($arg as node()?) as xs:stringXP3.0+
The primary use case for this function is to generate hyperlinks. For example, when
generating HTML, an anchor for a given section $sect
can be generated by
writing (in either XSLT or XQuery):
<a name="{fn:generate-id($sect)}"/>
and a link to that section can then be produced with code such as:
see <a href="#{fn:generate-id($sect)}">here</a>
Note that anchors generated in this way will not necessarily be the same each time a document is republished.
Since the keys in a map must be atomic values, it is possible to use generated IDs
as surrogates for nodes when constructing a map. For example, in some implementations,
testing whether a node $N
is a member of a large node-set $S
using the expression fn:exists($N intersect $S)
may be expensive; there
may then be performance benefits in creating a map:
let $SMap := map:merge($S!map{fn:generate-id(.) : .})
and then testing for membership of the node-set using:
map:contains($SMap, fn:generate-id($N))
fn:has-children( ) as xs:booleanXP3.0+
fn:has-children($node as node()?) as xs:booleanXP3.0+
fn:head($arg as item()*) as item()?XP3.0+
The expression fn:head(1 to 5)
returns 1
.
The expression fn:head(("a", "b", "c"))
returns "a"
.
The expression fn:head(())
returns ()
.
The expression fn:head([1,2,3])
returns [1,2,3]
.
fn:hours-from-dateTime($arg as xs:dateTime?) as xs:integer?
xs:dateTime
.
More... The expression fn:hours-from-dateTime(xs:dateTime("1999-05-31T08:20:00-05:00"))
returns 8
.
The expression fn:hours-from-dateTime(xs:dateTime("1999-12-31T21:20:00-05:00"))
returns 21
.
The expression fn:hours-from-dateTime(fn:adjust-dateTime-to-timezone(xs:dateTime("1999-12-31T21:20:00-05:00"),
xs:dayTimeDuration("PT0S")))
returns 2
.
The expression fn:hours-from-dateTime(xs:dateTime("1999-12-31T12:00:00"))
returns 12
.
The expression fn:hours-from-dateTime(xs:dateTime("1999-12-31T24:00:00"))
returns 0
.
fn:hours-from-duration($arg as xs:duration?) as xs:integer?
The expression fn:hours-from-duration(xs:dayTimeDuration("P3DT10H"))
returns 10
.
The expression fn:hours-from-duration(xs:dayTimeDuration("P3DT12H32M12S"))
returns 12
.
The expression fn:hours-from-duration(xs:dayTimeDuration("PT123H"))
returns 3
.
The expression fn:hours-from-duration(xs:dayTimeDuration("-P3DT10H"))
returns -10
.
fn:hours-from-time($arg as xs:time?) as xs:integer?
xs:time
.
More... Assume that the dynamic context provides an implicit timezone value of
-05:00
.
The expression fn:hours-from-time(xs:time("11:23:00"))
returns 11
.
The expression fn:hours-from-time(xs:time("21:23:00"))
returns 21
.
The expression fn:hours-from-time(xs:time("01:23:00+05:00"))
returns 1
.
The expression fn:hours-from-time(fn:adjust-time-to-timezone(xs:time("01:23:00+05:00"),
xs:dayTimeDuration("PT0S")))
returns 20
.
The expression fn:hours-from-time(xs:time("24:00:00"))
returns 0
.
fn:id($arg as xs:string*) as element()*
fn:id($arg as xs:string*, $node as node()) as element()*
ID
value matching the
value of one or more of the IDREF
values supplied in $arg
.
More... let $emp := validate lax{ document{ <employee xml:id="ID21256" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <empnr xsi:type="xs:ID">E21256</empnr> <first>John</first> <last>Brown</last> </employee> } }
The expression $emp/id('ID21256')/name()
returns "employee"
. (The xml:id
attribute has the is-id
property,
so the employee element is selected.)
The expression $emp/id('E21256')/name()
returns "empnr"
. (Assuming the empnr
element is given the type
xs:ID
as a result of schema validation, the element will have the
is-id
property and is therefore selected. Note the difference from
the behavior of fn:element-with-id
.)
fn:idref($arg as xs:string*) as node()*
fn:idref($arg as xs:string*, $node as node()) as node()*
IDREF
value
matching the value of one or more of the ID
values supplied in
$arg
.
More... let $emp := validate lax { document { <employees xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <employee xml:id="ID21256"> <empnr xsi:type="xs:ID">E21256</empnr> <first>Anil</first> <last>Singh</last> <deputy xsi:type="xs:IDREF">E30561</deputy> </employee> <employee xml:id="ID30561"> <empnr xsi:type="xs:ID">E30561</empnr> <first>John</first> <last>Brown</last> <manager xsi:type="xs:IDREF">ID21256</manager> </employee> </employees> } }
The expression $emp/(element-with-id('ID21256')/@xml:id => fn:idref())/ancestor::employee/last =>
string()
returns "Brown"
. (Assuming that manager
has the is-idref property, the call on fn:idref
selects
the manager
element. If, instead, the manager
had a ref
attribute with the is-idref property, the call on fn:idref
would select the attribute node.)
The expression $emp/(element-with-id('E30561')/empnr => fn:idref())/ancestor::employee/last => string()
returns "Singh"
. (Assuming that employee/deputy
has the is-idref property, the call on fn:idref
selects
the deputy
element.)
fn:implicit-timezone( ) as xs:dayTimeDuration
fn:in-scope-prefixes($element as element()) as xs:string*
fn:index-of($seq as xs:anyAtomicType*, $search as xs:anyAtomicType) as xs:integer*
fn:index-of($seq as xs:anyAtomicType*, $search as xs:anyAtomicType, $collation as xs:string) as xs:integer*
$seq
of items that are equal to $search
.
More... The expression fn:index-of((10, 20, 30, 40), 35)
returns ()
.
The expression fn:index-of((10, 20, 30, 30, 20, 10), 20)
returns (2, 5)
.
The expression fn:index-of(("a", "sport", "and", "a", "pastime"),
"a")
returns (1, 4)
.
The expression fn:index-of(current-date(), 23)
returns ()
.
The expression fn:index-of([1, [5, 6], [6, 7]], 6)
returns (3, 4)
. (The array is atomized to a sequence of five integers).
If @a
is an attribute of type xs:NMTOKENS
whose string
value is "red green blue"
, and whose typed value is therefore
("red", "green", "blue")
, then fn:index-of(@a, "blue")
returns 3
. This is because the function calling mechanism atomizes the
attribute node to produce a sequence of three xs:NMTOKEN
values.
fn:innermost($nodes as node()*) as node()*XP3.0+
If the source document contains nested sections represented by div
elements, the expression innermost(//div)
returns those div
elements that do not contain further div
elements.
fn:insert-before($target as item()*, $position as xs:integer, $inserts as item()*) as item()*
let $abc := ("a", "b", "c")
The expression fn:insert-before($abc, 0, "z")
returns ("z", "a", "b", "c")
.
The expression fn:insert-before($abc, 1, "z")
returns ("z", "a", "b", "c")
.
The expression fn:insert-before($abc, 2, "z")
returns ("a", "z", "b", "c")
.
The expression fn:insert-before($abc, 3, "z")
returns ("a", "b", "z", "c")
.
The expression fn:insert-before($abc, 4, "z")
returns ("a", "b", "c", "z")
.
fn:iri-to-uri($iri as xs:string?) as xs:string
The expression fn:iri-to-uri
("http://www.example.com/00/Weather/CA/Los%20Angeles#ocean")
returns "http://www.example.com/00/Weather/CA/Los%20Angeles#ocean"
.
The expression fn:iri-to-uri ("http://www.example.com/~bébé")
returns "http://www.example.com/~b%C3%A9b%C3%A9"
.
fn:json-doc($href as xs:string?) as item()?XP3.1
fn:json-doc($href as xs:string?, $options as map(*)) as item()?XP3.1
fn:json-to-xml($json-text as xs:string?, $options as map(*)) as document-node()?XP3.1
fn:json-to-xml($json-text as xs:string?) as document-node()?XP3.1
The expression json-to-xml('{"x": 1, "y": [3,4,5]}')
returns (with whitespace added for legibility):
<map xmlns="http://www.w3.org/2005/xpath-functions"> <number key="x">1</number> <array key="y"> <number>3</number> <number>4</number> <number>5</number> </array> </map>
The expression json-to-xml('"abcd"', map{'liberal': false()})
returns <string xmlns="http://www.w3.org/2005/xpath-functions">abcd</string>
.
The expression json-to-xml('{"x": "\\", "y": "\u0025"}')
returns (with whitespace added for legibility):
<map xmlns="http://www.w3.org/2005/xpath-functions"> <string key="x">\</string> <string key="y">%</string> </map>
The expression json-to-xml('{"x": "\\", "y": "\u0025"}', map{'escape':
true()})
returns (with whitespace added for legibility):
<map xmlns="http://www.w3.org/2005/xpath-functions"> <string escaped="true" key="x">\\</string> <string key="y">%</string> </map>
The following example illustrates use of the fallback
function to
handle characters that are invalid in XML.
let $jsonstr := unparsed-text('http://example.com/endpoint'), $options := map { 'liberal': true(), 'fallback': function($char as xs:string) as xs:string { let $c0chars := map { '\u0000':'[NUL]', '\u0001':'[SOH]', '\u0002':'[STX]', ... '\u001E':'[RS]', '\u001F':'[US]' }, $replacement := $c0chars($char) return if (exists($replacement)) then $replacement else error(xs:QName('err:invalid-char'), 'Error: ' || $char || ' is not a C0 control character.') } } return json-to-xml($jsonstr, $options)
fn:lang($testlang as xs:string?) as xs:boolean
fn:lang($testlang as xs:string?, $node as node()) as xs:boolean
$node
, or the context item if
the second argument is omitted, as specified by xml:lang
attributes is the
same as, or is a sublanguage of, the language specified by $testlang
.
More... The expression fn:lang("en")
would return true
if the
context node were any of the following four elements:
<para xml:lang="en"/>
<div xml:lang="en"><para>And now, and
forever!</para></div>
<para xml:lang="EN"/>
<para xml:lang="en-us"/>
The expression fn:lang("fr")
would return false
if the
context node were <para xml:lang="EN"/>
fn:last( ) as xs:integer
The expression (1 to 20)[fn:last() - 1]
returns 19
.
fn:load-xquery-module($module-uri as xs:string) as map(*)XP3.1
fn:load-xquery-module($module-uri as xs:string, $options as map(*)) as map(*)XP3.1
fn:local-name( ) as xs:string
fn:local-name($arg as node()?) as xs:string
$arg
as an xs:string
that is either the zero-length string, or has the lexical form of an
xs:NCName
.
More... fn:local-name-from-QName($arg as xs:QName?) as xs:NCName?
The expression fn:local-name-from-QName(fn:QName("http://www.example.com/example",
"person"))
returns "person"
.
fn:lower-case($arg as xs:string?) as xs:string
The expression fn:lower-case("ABc!D")
returns "abc!d"
.
fn:matches($input as xs:string?, $pattern as xs:string) as xs:boolean
fn:matches($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:boolean
The expression fn:matches("abracadabra", "bra")
returns true()
.
The expression fn:matches("abracadabra", "^a.*a$")
returns true()
.
The expression fn:matches("abracadabra", "^bra")
returns false()
.
Given the source document:
let $poem := <poem author="Wilhelm Busch"> Kaum hat dies der Hahn gesehen, Fängt er auch schon an zu krähen: Kikeriki! Kikikerikih!! Tak, tak, tak! - da kommen sie. </poem>
the following function calls produce the following results, with the
poem
element as the context node:
The expression fn:matches($poem, "Kaum.*krähen")
returns false()
.
The expression fn:matches($poem, "Kaum.*krähen", "s")
returns true()
.
The expression fn:matches($poem, "^Kaum.*gesehen,$", "m")
returns true()
.
The expression fn:matches($poem, "^Kaum.*gesehen,$")
returns false()
.
The expression fn:matches($poem, "kiki", "i")
returns true()
.
fn:max($arg as xs:anyAtomicType*) as xs:anyAtomicType?
fn:max($arg as xs:anyAtomicType*, $collation as xs:string) as xs:anyAtomicType?
The expression fn:max((3,4,5))
returns 5
.
The expression fn:max([3,4,5])
returns 5
. (Arrays are atomized).
The expression fn:max((xs:integer(5), xs:float(5.0), xs:double(0)))
returns xs:double(5.0e0)
.
fn:max((3,4,"Zero"))
raises a type error [err:FORG0006].
The expression fn:max((fn:current-date(), xs:date("2100-01-01")))
returns xs:date("2100-01-01")
. (Assuming that the current date is during the 21st
century.)
The expression fn:max(("a", "b", "c"))
returns "c"
. (Assuming a typical default collation.)
fn:min($arg as xs:anyAtomicType*) as xs:anyAtomicType?
fn:min($arg as xs:anyAtomicType*, $collation as xs:string) as xs:anyAtomicType?
The expression fn:min((3,4,5))
returns 3
.
The expression fn:min([3,4,5])
returns 3
. (Arrays are atomized).
The expression fn:min((xs:integer(5), xs:float(5), xs:double(10)))
returns xs:double(5.0e0)
.
fn:min((3,4,"Zero"))
raises a type error [err:FORG0006].
fn:min((xs:float(0.0E0), xs:float(-0.0E0)))
can return either positive
or negative zero. The two items are equal, so it is ·implementation-dependent· which is returned.
The expression fn:min((fn:current-date(), xs:date("1900-01-01")))
returns xs:date("1900-01-01")
. (Assuming that the current date is set to a reasonable
value.)
The expression fn:min(("a", "b", "c"))
returns "a"
. (Assuming a typical default collation.)
fn:minutes-from-dateTime($arg as xs:dateTime?) as xs:integer?
xs:dateTime
.
More... The expression fn:minutes-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00"))
returns 20
.
The expression fn:minutes-from-dateTime(xs:dateTime("1999-05-31T13:30:00+05:30"))
returns 30
.
fn:minutes-from-duration($arg as xs:duration?) as xs:integer?
The expression fn:minutes-from-duration(xs:dayTimeDuration("P3DT10H"))
returns 0
.
The expression fn:minutes-from-duration(xs:dayTimeDuration("-P5DT12H30M"))
returns -30
.
fn:minutes-from-time($arg as xs:time?) as xs:integer?
xs:time
.
More... The expression fn:minutes-from-time(xs:time("13:00:00Z"))
returns 0
.
fn:month-from-date($arg as xs:date?) as xs:integer?
xs:date
.
More... The expression fn:month-from-date(xs:date("1999-05-31-05:00"))
returns 5
.
The expression fn:month-from-date(xs:date("2000-01-01+05:00"))
returns 1
.
fn:month-from-dateTime($arg as xs:dateTime?) as xs:integer?
xs:dateTime
.
More... The expression fn:month-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00"))
returns 5
.
The expression fn:month-from-dateTime(xs:dateTime("1999-12-31T19:20:00-05:00"))
returns 12
.
The expression fn:month-from-dateTime(fn:adjust-dateTime-to-timezone(xs:dateTime("1999-12-31T19:20:00-05:00"),
xs:dayTimeDuration("PT0S")))
returns 1
.
fn:months-from-duration($arg as xs:duration?) as xs:integer?
The expression fn:months-from-duration(xs:yearMonthDuration("P20Y15M"))
returns 3
.
The expression fn:months-from-duration(xs:yearMonthDuration("-P20Y18M"))
returns -6
.
The expression fn:months-from-duration(xs:dayTimeDuration("-P2DT15H0M0S"))
returns 0
.
fn:name( ) as xs:string
fn:name($arg as node()?) as xs:string
xs:string
that is either the zero-length
string, or has the lexical form of an xs:QName
.
More... fn:namespace-uri( ) as xs:anyURI
fn:namespace-uri($arg as node()?) as xs:anyURI
fn:namespace-uri-for-prefix($prefix as xs:string?, $element as element()) as xs:anyURI?
$element
,
identified by its namespace prefix.
More... let $e := <z:a xmlns="http://example.org/one" xmlns:z="http://example.org/two"> <b xmlns=""/> </z:a>
The expression fn:namespace-uri-for-prefix("z", $e)
returns "http://example.org/two"
.
The expression fn:namespace-uri-for-prefix("", $e)
returns "http://example.org/one"
.
The expression fn:namespace-uri-for-prefix((), $e)
returns "http://example.org/one"
.
The expression fn:namespace-uri-for-prefix("xml", $e)
returns "http://www.w3.org/XML/1998/namespace"
.
The expression fn:namespace-uri-for-prefix("xml", $e)
returns "http://www.w3.org/XML/1998/namespace"
.
fn:namespace-uri-from-QName($arg as xs:QName?) as xs:anyURI?
The expression fn:namespace-uri-from-QName(fn:QName("http://www.example.com/example",
"person"))
returns xs:anyURI("http://www.example.com/example")
.
fn:nilled($arg as node()?) as xs:boolean?
fn:nilled( ) as xs:booleanXP3.0+
fn:node-name($arg as node()?) as xs:QName?
fn:node-name( ) as xs:QName?XP3.0+
xs:QName
.
More... fn:normalize-space( ) as xs:string
fn:normalize-space($arg as xs:string?) as xs:string
$arg
with leading and trailing whitespace removed, and
sequences of internal whitespace reduced to a single space character.
More... The expression fn:normalize-space(" The wealthy curled darlings
of our nation. ")
returns "The wealthy curled darlings of our nation."
.
The expression fn:normalize-space(())
returns ""
.
fn:normalize-unicode($arg as xs:string?) as xs:string
fn:normalize-unicode($arg as xs:string?, $normalizationForm as xs:string) as xs:string
$arg
after applying Unicode normalization.
More... fn:not($arg as item()*) as xs:boolean
true
if the effective boolean value of $arg
is
false
, or false
if it is true
.
More... The expression fn:not(fn:true())
returns false()
.
The expression fn:not(())
returns true()
.
The expression fn:not("false")
returns false()
.
fn:not(1 to 10)
raises a type error [err:FORG0006].
fn:number( ) as xs:double
fn:number($arg as xs:anyAtomicType?) as xs:double
$arg
or, if $arg
is not
specified, the context item after atomization, converted to an xs:double
.
More... The expression fn:number($item1/quantity)
returns 5.0e0
.
The expression fn:number($item2/description)
returns xs:double('NaN')
.
Assume that the context item is the xs:string
value "15
".
Then fn:number()
returns 1.5e1
.
fn:one-or-more($arg as item()*) as item()+
$arg
if it contains one or more items. Otherwise, raises an error.
More... fn:outermost($nodes as node()*) as node()*XP3.0+
If the source document contains nested sections represented by div
elements, the expression outermost(//div)
returns those div
elements that are not contained within further div
elements.
fn:parse-ietf-date($value as xs:string?) as xs:dateTime?XP3.1
xs:dateTime
value.
More... The expression fn:parse-ietf-date("Wed, 06 Jun 1994 07:29:35 GMT")
returns xs:dateTime("1994-06-06T07:29:35Z")
.
The expression fn:parse-ietf-date("Wed, 6 Jun 94 07:29:35 GMT")
returns xs:dateTime("1994-06-06T07:29:35Z")
.
The expression fn:parse-ietf-date("Wed Jun 06 11:54:45 EST 2013")
returns xs:dateTime("2013-06-06T11:54:45-05:00")
.
The expression fn:parse-ietf-date("Sunday, 06-Nov-94 08:49:37 GMT")
returns xs:dateTime("1994-11-06T08:49:37Z")
.
The expression fn:parse-ietf-date("Wed, 6 Jun 94 07:29:35 +0500")
returns xs:dateTime("1994-06-06T07:29:35+05:00")
.
fn:parse-json($json-text as xs:string?) as item()?XP3.1
fn:parse-json($json-text as xs:string?, $options as map(*)) as item()?XP3.1
The expression parse-json('{"x":1, "y":[3,4,5]}')
returns map{"x":1e0,"y":[3e0,4e0,5e0]}
.
The expression parse-json('"abcd"')
returns "abcd"
.
The expression parse-json('{"x":"\\", "y":"\u0025"}')
returns map{"x":"\","y":"%"}
.
The expression parse-json('{"x":"\\", "y":"\u0025"}', map{'escape':true()})
returns map{"x":"\\","y":"%"}
.
The expression parse-json('{"x":"\\", "y":"\u0000"}')
returns map{"x":"\","y":codepoints-to-string(65533)}
.
The expression parse-json('{"x":"\\", "y":"\u0000"}', map{'escape':true()})
returns map{"x":"\\","y":"\u0000"}
.
The expression parse-json('{"x":"\\", "y":"\u0000"}', map{'fallback':function($s){'['||$s||']'}})
returns map{"x":"\","y":"[\u0000]"}
.
fn:parse-xml($arg as xs:string?) as document-node(element(*)) ?XP3.0+
The expression fn:parse-xml("<alpha>abcd</alpha>")
returns a newly
created document node, having an alpha
element as its only child; the
alpha
element in turn is the parent of a text node whose string value
is "abcd"
.
fn:parse-xml-fragment($arg as xs:string?) as document-node()?XP3.0+
The expression
fn:parse-xml-fragment("<alpha>abcd</alpha><beta>abcd</beta>")
returns a newly created document node, having two elements named alpha
and beta
as its children; each of these elements in turn is the parent
of a text node.
The expression fn:parse-xml-fragment("He was <i>so</i> kind")
returns a newly created document node having three children: a text node whose string
value is "He was "
, an element node named i
having a child
text node with string value "so"
, and a text node whose string value is
" kind"
.
The expression fn:parse-xml-fragment("")
returns a document node having
no children.
The expression fn:parse-xml-fragment(" ")
returns a document node whose
children comprise a single text node whose string value is a single space.
The expression fn:parse-xml-fragment('<?xml version="1.0" encoding="utf8"
standalone="yes"?><a/>')
results in a dynamic error [err:FODC0006] because the "standalone" keyword is not permitted in the text
declaration that appears at the start of an external general parsed entity. (Thus,
it
is not the case that any input accepted by the fn:parse-xml
function
will also be accepted by fn:parse-xml-fragment
.)
fn:path( ) as xs:string?XP3.0+
fn:path($arg as node()?) as xs:string?XP3.0+
let $e := document { <p xmlns="http://example.com/one" xml:lang="de" author="Friedrich von Schiller"> Freude, schöner Götterfunken,<br/> Tochter aus Elysium,<br/> Wir betreten feuertrunken,<br/> Himmlische, dein Heiligtum.</p>}
The expression fn:path($e)
returns '/'
.
The expression fn:path($e/*:p)
returns '/Q{http://example.com/one}p[1]'
.
The expression fn:path($e/*:p/@xml:lang)
returns '/Q{http://example.com/one}p[1]/@Q{http://www.w3.org/XML/1998/namespace}lang'
.
The expression fn:path($e/*:p/@author)
returns '/Q{http://example.com/one}p[1]/@author'
.
The expression fn:path($e/*:p/*:br[2])
returns '/Q{http://example.com/one}p[1]/Q{http://example.com/one}br[2]'
.
The expression fn:path($e//text()[starts-with(normalize-space(),
'Tochter')])
returns '/Q{http://example.com/one}p[1]/text()[2]'
.
let $emp := <employee xml:id="ID21256"> <empnr>E21256</empnr> <first>John</first> <last>Brown</last> </employee>
The expression fn:path($emp)
returns 'Q{http://www.w3.org/2005/xpath-functions}root()'
.
The expression fn:path($emp/@xml:id)
returns 'Q{http://www.w3.org/2005/xpath-functions}root()/@Q{http://www.w3.org/XML/1998/namespace}id'
.
The expression fn:path($emp/empnr)
returns 'Q{http://www.w3.org/2005/xpath-functions}root()/Q{}empnr[1]'
.
fn:position( ) as xs:integer
fn:prefix-from-QName($arg as xs:QName?) as xs:NCName?
fn:QName($paramURI as xs:string?, $paramQName as xs:string) as xs:QName
xs:QName
value formed using a supplied namespace URI and lexical QName.
More...
fn:QName("http://www.example.com/example", "person")
returns an
xs:QName
with namespace URI = "http://www.example.com/example", local
name = "person" and prefix = "".
fn:QName("http://www.example.com/example", "ht:person")
returns an
xs:QName
with namespace URI = "http://www.example.com/example", local
name = "person" and prefix = "ht".
fn:random-number-generator( ) as map(string, item())XP3.1
fn:random-number-generator($seed as xs:anyAtomicType?) as map(string, item())XP3.1
The following example returns a random permutation of the integers in the range 1
to 100:
fn:random-number-generator()?permute(1 to 100)
The following example returns a 10% sample of the items in an input sequence $seq
, chosen at random:
fn:random-number-generator()?permute($seq)[position() = 1 to (count($seq) idiv 10)]
The following code defines a function that can be called to produce a random sequence
of xs:double
values in the range zero to one, of specified length:
declare %public function r:random-sequence($length as xs:integer) as xs:double* { r:random-sequence($length, fn:random-number-generator()) }; declare %private function r:random-sequence($length as xs:integer, $G as map(xs:string, item())) { if ($length eq 0) then () else ($G?number, r:random-sequence($length - 1, $G?next())) }; r:random-sequence(200);
fn:remove($target as item()*, $position as xs:integer) as item()*
$target
except the item
at position $position
.
More... let $abc := ("a", "b", "c")
The expression fn:remove($abc, 0)
returns ("a", "b", "c")
.
The expression fn:remove($abc, 1)
returns ("b", "c")
.
The expression fn:remove($abc, 6)
returns ("a", "b", "c")
.
The expression fn:remove((), 3)
returns ()
.
fn:replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string) as xs:string
fn:replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string, $flags as xs:string) as xs:string
The expression fn:replace("abracadabra", "bra", "*")
returns "a*cada*"
.
The expression fn:replace("abracadabra", "a.*a", "*")
returns "*"
.
The expression fn:replace("abracadabra", "a.*?a", "*")
returns "*c*bra"
.
The expression fn:replace("abracadabra", "a", "")
returns "brcdbr"
.
The expression fn:replace("abracadabra", "a(.)", "a$1$1")
returns "abbraccaddabbra"
.
The expression fn:replace("abracadabra", ".*?", "$1")
raises an error,
because the pattern matches the zero-length string
The expression fn:replace("AAAA", "A+", "b")
returns "b"
.
The expression fn:replace("AAAA", "A+?", "b")
returns "bbbb"
.
The expression fn:replace("darted", "^(.*?)d(.*)$", "$1c$2")
returns "carted"
. (The first d
is replaced.)
fn:resolve-QName($qname as xs:string?, $element as element()) as xs:QName?
xs:QName
value (that is, an expanded-QName) by taking an
xs:string
that has the lexical form of an xs:QName
(a
string in the form "prefix:local-name" or "local-name") and resolving it using the
in-scope namespaces for a given element.
More... Assume that the element bound to $element
has a single namespace binding
bound to the prefix eg
.
fn:resolve-QName("hello", $element)
returns a QName with local name
"hello" that is in no namespace.
fn:resolve-QName("eg:myFunc", $element)
returns an xs:QName
whose namespace URI is specified by the namespace binding corresponding to the prefix
"eg" and whose local name is "myFunc".
fn:resolve-uri($relative as xs:string?) as xs:anyURI?
fn:resolve-uri($relative as xs:string?, $base as xs:string) as xs:anyURI?
fn:reverse($arg as item()*) as item()*
let $abc := ("a", "b", "c")
The expression fn:reverse($abc)
returns ("c", "b", "a")
.
The expression fn:reverse(("hello"))
returns ("hello")
.
The expression fn:reverse(())
returns ()
.
The expression fn:reverse([1,2,3])
returns [1,2,3]
. (The input is a sequence containing a single item (the array)).
The expression fn:reverse(([1,2,3],[4,5,6]))
returns ([4,5,6],[1,2,3])
.
fn:root( ) as node()
fn:root($arg as node()?) as node()?
$arg
belongs. This will usually, but
not necessarily, be a document node.
More... These examples use some variables which could be defined in [XQuery 3.1: An XML Query Language] as:
let $i := <tool>wrench</tool> let $o := <order> {$i} <quantity>5</quantity> </order> let $odoc := document {$o} let $newi := $o/tool
Or they could be defined in [XSL Transformations (XSLT) Version 3.0] as:
<xsl:variable name="i" as="element()"> <tool>wrench</tool> </xsl:variable> <xsl:variable name="o" as="element()"> <order> <xsl:copy-of select="$i"/> <quantity>5</quantity> </order> </xsl:variable> <xsl:variable name="odoc"> <xsl:copy-of select="$o"/> </xsl:variable> <xsl:variable name="newi" select="$o/tool"/>
fn:root($i)
returns the element node $i
fn:root($o/quantity)
returns the element node $o
fn:root($odoc//quantity)
returns the document node $odoc
fn:root($newi)
returns the element node $o
The final three examples could be made type-safe by wrapping their operands with
fn:exactly-one()
.
fn:round($arg as xs:numeric?) as xs:numeric?
fn:round($arg as xs:numeric?, $precision as xs:integer) as xs:numeric?XP3.0+
The expression fn:round(2.5)
returns 3.0
.
The expression fn:round(2.4999)
returns 2.0
.
The expression fn:round(-2.5)
returns -2.0
. (Not the possible alternative, -3
).
The expression fn:round(1.125, 2)
returns 1.13
.
The expression fn:round(8452, -2)
returns 8500
.
The expression fn:round(3.1415e0, 2)
returns 3.14e0
.
fn:round-half-to-even($arg as xs:numeric?) as xs:numeric?
fn:round-half-to-even($arg as xs:numeric?, $precision as xs:integer) as xs:numeric?
The expression fn:round-half-to-even(0.5)
returns 0.0
.
The expression fn:round-half-to-even(1.5)
returns 2.0
.
The expression fn:round-half-to-even(2.5)
returns 2.0
.
The expression fn:round-half-to-even(3.567812e+3, 2)
returns 3567.81e0
.
The expression fn:round-half-to-even(4.7564e-3, 2)
returns 0.0e0
.
The expression fn:round-half-to-even(35612.25, -2)
returns 35600
.
fn:seconds-from-dateTime($arg as xs:dateTime?) as xs:decimal?
xs:dateTime
.
More... The expression fn:seconds-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00"))
returns 0
.
fn:seconds-from-duration($arg as xs:duration?) as xs:decimal?
The expression fn:seconds-from-duration(xs:dayTimeDuration("P3DT10H12.5S"))
returns 12.5
.
The expression fn:seconds-from-duration(xs:dayTimeDuration("-PT256S"))
returns -16.0
.
fn:seconds-from-time($arg as xs:time?) as xs:decimal?
xs:time
.
More... The expression fn:seconds-from-time(xs:time("13:20:10.5"))
returns 10.5
.
fn:serialize($arg as item()*) as xs:stringXP3.0+
fn:serialize($arg as item()*, $params as element(output:serialization-parameters)?) as xs:stringXP3.0+
fn:serialize($arg as item()*) as xs:stringXP3.1
fn:serialize($arg as item()*, $params as item()?) as xs:stringXP3.1
$arg
as described in
[XSLT and XQuery Serialization 3.1], returning the serialized representation
of the sequence as a string.
More... Given the variables:
let $params := <output:serialization-parameters xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization"> <output:omit-xml-declaration value="yes"/> </output:serialization-parameters>
let $data := <a b="3"/>
The following call might produce the output shown:
The expression fn:serialize($data, $params)
returns '<a b="3"/>'
.
The following call would also produce the output shown (though the second argument
could equally well be supplied
as an empty map (map{}
), since both parameters are given their default values):
The expression fn:serialize($data, map{"method":"xml", "omit-xml-declaration":true()})
returns '<a b="3"/>'
.
fn:sort($input as item()*) as item()*XP3.1
fn:sort($input as item()*, $collation as xs:string?) as item()*XP3.1
fn:sort($input as item()*, $collation as xs:string?, $key as function(item()) as anyAtomicType*) as item()*XP3.1
The expression fn:sort((1, 4, 6, 5, 3))
returns (1, 3, 4, 5, 6)
.
The expression fn:sort((1, -2, 5, 10, -10, 10, 8), (), fn:abs#1)
returns (1, -2, 5, 8, 10, -10, 10)
.
To sort a set of strings $in
using Swedish collation:
let $SWEDISH := "http://www.w3.org/2013/collation/UCA?lang=se" return fn:sort($in, $SWEDISH)
To sort a sequence of employees by last name as the major sort key and first name as the minor sort key, using the default collation:
fn:sort($employees, (), function($emp) {$emp/name ! (last, first)})
fn:starts-with($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean
fn:starts-with($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean
$arg1
contains $arg2
as a leading
substring, taking collations into account.
More... The collation used in these examples, http://example.com/CollationA
is a
collation in which both "-" and "*" are ignorable collation units.
"Ignorable collation unit" is equivalent to "ignorable collation element" in [UTS #10].
The expression fn:starts-with("tattoo", "tat")
returns true()
.
The expression fn:starts-with ( "tattoo", "att")
returns false()
.
The expression fn:starts-with ((), ())
returns true()
.
The expression fn:starts-with ( "abcdefghi", "-a-b-c-",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
The expression fn:starts-with ( "a*b*c*d*e*f*g*h*i*", "a-bc-",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
The expression fn:starts-with ( "abcd***e---f*--*ghi", "abcdef",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
The expression fn:starts-with ( (), "--***-*---",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
. (The second argument contains only ignorable collation units and is
equivalent to the zero-length string.)
The expression fn:starts-with ( "-abcdefghi", "-abc",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns true()
.
fn:static-base-uri( ) as xs:anyURI?
fn:string( ) as xs:string
fn:string($arg as item()?) as xs:string
$arg
represented as an xs:string
.
More... The expression string(23)
returns "23"
.
The expression string(false())
returns "false"
.
The expression string("Paris")
returns "Paris"
.
The expression string((1, 2, 3))
raises error XPTY0004
.
The expression string([[1, 2], [3, 4]])
raises error FOTY0014
.
The expression string(abs#1)
raises error FOTY0014
.
let $para := <para>In a hole in the ground there lived a <term author="Tolkien">hobbit</term>.</para>
The expression string($para)
returns "In a hole in the ground there lived a hobbit."
.
fn:string-join($arg1 as xs:string*, $arg2 as xs:string) as xs:string
fn:string-join($arg1 as xs:string*) as xs:stringXP3.0+
fn:string-join($arg1 as xs:anyAtomicType*) as xs:stringXP3.1
fn:string-join($arg1 as xs:anyAtomicType*, $arg2 as xs:string) as xs:stringXP3.1
The expression fn:string-join(1 to 9)
returns "123456789"
.
The expression fn:string-join(('Now', 'is', 'the', 'time', '...'),
' ')
returns "Now is the time ..."
.
The expression fn:string-join(('Blow, ', 'blow, ', 'thou ', 'winter ', 'wind!'),
'')
returns "Blow, blow, thou winter wind!"
.
The expression fn:string-join((), 'separator')
returns ""
.
The expression fn:string-join(1 to 5, ', ')
returns "1, 2, 3, 4, 5"
.
let $doc := <doc> <chap> <section xml:id="xyz"/> </chap> </doc>
The expression $doc//@xml:id ! fn:string-join((node-name(), '="', ., '"'))
returns 'xml:id="xyz"'
.
The expression $doc//section ! fn:string-join(ancestor-or-self::*/name(), '/')
returns "doc/chap/section"
.
fn:string-length( ) as xs:integer
fn:string-length($arg as xs:string?) as xs:integer
The expression fn:string-length("Harp not on that string, madam; that is past.")
returns 45
.
The expression fn:string-length(())
returns 0
.
fn:string-to-codepoints($arg as xs:string?) as xs:integer*
xs:string
value.
More... The expression fn:string-to-codepoints("Thérèse")
returns (84, 104, 233, 114, 232, 115, 101)
.
fn:subsequence($sourceSeq as item()*, $startingLoc as xs:double) as item()*
fn:subsequence($sourceSeq as item()*, $startingLoc as xs:double, $length as xs:double) as item()*
$sourceSeq
beginning at the position indicated by the value of $startingLoc
and
continuing for the number of items indicated by the value of $length
.
More... let $seq := ("item1", "item2", "item3", "item4", "item5")
The expression fn:subsequence($seq, 4)
returns ("item4", "item5")
.
The expression fn:subsequence($seq, 3, 2)
returns ("item3", "item4")
.
fn:substring($sourceString as xs:string?, $start as xs:double) as xs:string
fn:substring($sourceString as xs:string?, $start as xs:double, $length as xs:double) as xs:string
$sourceString
beginning at the position
indicated by the value of $start
and continuing for the number of ·characters· indicated by the value of
$length
.
More... The expression fn:substring("motor car", 6)
returns " car"
. (Characters starting at position 6 to the end of
$sourceString
are selected.)
The expression fn:substring("metadata", 4, 3)
returns "ada"
. (Characters at positions greater than or equal to 4 and less than 7 are
selected.)
The expression fn:substring("12345", 1.5, 2.6)
returns "234"
. (Characters at positions greater than or equal to 2 and less than 5 are
selected.)
The expression fn:substring("12345", 0, 3)
returns "12"
. (Characters at positions greater than or equal to 0 and less than 3 are
selected. Since the first position is 1, these are the characters at positions 1
and 2.)
The expression fn:substring("12345", 5, -3)
returns ""
. (Characters at positions greater than or equal to 5 and less than 2 are
selected.)
The expression fn:substring("12345", -3, 5)
returns "1"
. (Characters at positions greater than or equal to -3 and less than 2
are selected. Since the first position is 1, this is the character at position
1.)
The expression fn:substring("12345", 0 div 0E0, 3)
returns ""
. (Since 0 div 0E0
returns NaN
, and
NaN
compared to any other number returns false
, no
characters are selected.)
The expression fn:substring("12345", 1, 0 div 0E0)
returns ""
. (As above.)
The expression fn:substring((), 1, 3)
returns ""
.
The expression fn:substring("12345", -42, 1 div 0E0)
returns "12345"
. (Characters at positions greater than or equal to -42 and less than
INF
are selected.)
The expression fn:substring("12345", -1 div 0E0, 1 div 0E0)
returns ""
. (Since the value of -INF + INF
is NaN
, no
characters are selected.)
fn:substring-after($arg1 as xs:string?, $arg2 as xs:string?) as xs:string
fn:substring-after($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:string
$arg1
that follows the first occurrence of
$arg2
, taking collations into account.
More... The collation used in these examples, http://example.com/CollationA
is a
collation in which both "-" and "*" are ignorable collation units.
"Ignorable collation unit" is equivalent to "ignorable collation element" in [UTS #10].
The expression fn:substring-after("tattoo", "tat")
returns "too"
.
The expression fn:substring-after("tattoo", "tattoo")
returns ""
.
The expression fn:substring-after((), ())
returns ""
.
The expression fn:substring-after("abcdefghi", "--d-e-",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns "fghi"
.
The expression fn:substring-after("abc--d-e-fghi", "--d-e-",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns "-fghi"
.
The expression fn:substring-after ( "a*b*c*d*e*f*g*h*i*", "***cde***",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns "*f*g*h*i*"
.
The expression fn:substring-after ( "Eureka!", "--***-*---",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns "Eureka!"
. (The second argument contains only ignorable collation units and is
equivalent to the zero-length string.)
fn:substring-before($arg1 as xs:string?, $arg2 as xs:string?) as xs:string
fn:substring-before($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:string
$arg1
that precedes the first occurrence of
$arg2
, taking collations into account.
More... The collation used in these examples, http://example.com/CollationA
is a
collation in which both "-" and "*" are ignorable collation units.
"Ignorable collation unit" is equivalent to "ignorable collation element" in [UTS #10].
The expression fn:substring-before ( "tattoo", "attoo")
returns "t"
.
The expression fn:substring-before ( "tattoo", "tatto")
returns ""
.
The expression fn:substring-before ((), ())
returns ""
.
The expression fn:substring-before ( "abcdefghi", "--d-e-",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns "abc"
.
The expression fn:substring-before ( "abc--d-e-fghi", "--d-e-",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns "abc--"
.
The expression fn:substring-before ( "a*b*c*d*e*f*g*h*i*", "***cde",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns "a*b*"
.
The expression fn:substring-before ( "Eureka!", "--***-*---",
"http://www.w3.org/2013/collation/UCA?lang=en;alternate=blanked;strength=primary")
returns ""
. (The second argument contains only ignorable collation units and is
equivalent to the zero-length string.)
fn:sum($arg as xs:anyAtomicType*) as xs:anyAtomicType
fn:sum($arg as xs:anyAtomicType*, $zero as xs:anyAtomicType?) as xs:anyAtomicType?
$arg
.
More... let $d1 := xs:yearMonthDuration("P20Y")
let $d2 := xs:yearMonthDuration("P10M")
let $seq1 := ($d1, $d2)
let $seq3 := (3, 4, 5)
The expression fn:sum(($d1, $d2))
returns xs:yearMonthDuration("P20Y10M")
.
The expression fn:sum($seq1[. lt xs:yearMonthDuration('P3M')],
xs:yearMonthDuration('P0M'))
returns xs:yearMonthDuration("P0M")
.
The expression fn:sum($seq3)
returns 12
.
The expression fn:sum(())
returns 0
.
The expression fn:sum((),())
returns ()
.
The expression fn:sum((1 to 100)[. lt 0], 0)
returns 0
.
fn:sum(($d1, 9E1))
raises a type error [err:FORG0006].
The expression fn:sum(($d1, $d2), "ein Augenblick")
returns xs:yearMonthDuration("P20Y10M")
. (There is no requirement that the $zero
value should be
the same type as the items in $arg
, or even that it should belong to
a type that supports addition.)
The expression fn:sum([1, 2, 3])
returns 6
. (Atomizing an array returns the sequence obtained by atomizing its members.)
The expression fn:sum([[1, 2], [3, 4]])
returns 10
. (Atomizing an array returns the sequence obtained by atomizing its members.)
fn:tail($arg as item()*) as item()*XP3.0+
The expression fn:tail(1 to 5)
returns (2, 3, 4, 5)
.
The expression fn:tail(("a", "b", "c"))
returns ("b", "c")
.
The expression fn:tail("a")
returns ()
.
The expression fn:tail(())
returns ()
.
The expression fn:tail([1,2,3])
returns ()
.
fn:timezone-from-date($arg as xs:date?) as xs:dayTimeDuration?
xs:date
.
More... The expression fn:timezone-from-date(xs:date("1999-05-31-05:00"))
returns xs:dayTimeDuration("-PT5H")
.
The expression fn:timezone-from-date(xs:date("2000-06-12Z"))
returns xs:dayTimeDuration("PT0S")
.
fn:timezone-from-dateTime($arg as xs:dateTime?) as xs:dayTimeDuration?
xs:dateTime
.
More... The expression fn:timezone-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00"))
returns xs:dayTimeDuration("-PT5H")
.
The expression fn:timezone-from-dateTime(xs:dateTime("2000-06-12T13:20:00Z"))
returns xs:dayTimeDuration("PT0S")
.
The expression fn:timezone-from-dateTime(xs:dateTime("2004-08-27T00:00:00"))
returns ()
.
fn:timezone-from-time($arg as xs:time?) as xs:dayTimeDuration?
xs:time
.
More... The expression fn:timezone-from-time(xs:time("13:20:00-05:00"))
returns xs:dayTimeDuration("-PT5H")
.
The expression fn:timezone-from-time(xs:time("13:20:00"))
returns ()
.
fn:tokenize($input as xs:string?, $pattern as xs:string) as xs:string*
fn:tokenize($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:string*
fn:tokenize($input as xs:string?) as xs:string*XP3.1
The expression fn:tokenize(" red green blue ")
returns ("red", "green", "blue")
.
The expression fn:tokenize("The cat sat on the mat", "\s+")
returns ("The", "cat", "sat", "on", "the", "mat")
.
The expression fn:tokenize(" red green blue ", "\s+")
returns ("", "red", "green", "blue", "")
.
The expression fn:tokenize("1, 15, 24, 50", ",\s*")
returns ("1", "15", "24", "50")
.
The expression fn:tokenize("1,15,,24,50,", ",")
returns ("1", "15", "", "24", "50", "")
.
fn:tokenize("abba", ".?")
raises the dynamic error [err:FORX0003].
The expression fn:tokenize("Some unparsed <br> HTML <BR> text",
"\s*<br>\s*", "i")
returns ("Some unparsed", "HTML", "text")
.
fn:trace($value as item()*, $label as xs:string) as item()*
fn:trace($value as item()*) as item()*XP3.1
Consider a situation in which a user wants to investigate the actual value passed
to
a function. Assume that in a particular execution, $v
is an
xs:decimal
with value 124.84
. Writing fn:trace($v,
'the value of $v is:')
will put the strings "124.84"
and
"the value of $v is:"
in the trace data set in implementation
dependent order.
fn:transform($options as map(*)) as map(*)XP3.1
The following example loads a stylesheet from the location render.xsl
,
applies it to a document loaded from test.xml
, and uses an XPath expression
to examine the result:
let $result := fn:transform( map { "stylesheet-location" : "render.xsl", "source-node" : fn:doc('test.xml') }) return $result?output//body
fn:translate($arg as xs:string?, $mapString as xs:string, $transString as xs:string) as xs:string
$arg
modified by replacing or removing individual
characters.
More... The expression fn:translate("bar","abc","ABC")
returns "BAr"
.
The expression fn:translate("--aaa--","abc-","ABC")
returns "AAA"
.
The expression fn:translate("abcdabc", "abc", "AB")
returns "ABdAB"
.
fn:true( ) as xs:boolean
xs:boolean
value true
.
More... The expression fn:true()
returns xs:boolean(1)
.
fn:unordered($sourceSeq as item()*) as item()
$sourceSeq
in an ·implementation-dependent· order.
More... The expression fn:unordered((1, 2, 3, 4, 5))
returns some permutation of (1, 2, 3, 4, 5)
.
fn:unparsed-text($href as xs:string?) as xs:string?XP3.0+
fn:unparsed-text($href as xs:string?, $encoding as xs:string) as xs:string?XP3.0+
fn:unparsed-text
function reads an external resource (for example, a
file) and returns a string representation of the resource.
More... This XSLT example attempts to read a file containing 'boilerplate' HTML and copy it directly to the serialized output file:
<xsl:output method="html"/> <xsl:template match="/"> <xsl:value-of select="unparsed-text('header.html', 'iso-8859-1')" disable-output-escaping="yes"/> <xsl:apply-templates/> <xsl:value-of select="unparsed-text('footer.html', 'iso-8859-1')" disable-output-escaping="yes"/> </xsl:template>
fn:unparsed-text-available($href as xs:string?) as xs:booleanXP3.0+
fn:unparsed-text-available($href as xs:string?, $encoding as xs:string) as xs:booleanXP3.0+
fn:unparsed-text
function are
non-recoverable, these two functions are provided to allow an application to determine
whether a call with particular arguments would succeed.
More... fn:unparsed-text-lines($href as xs:string?, $encoding as xs:string) as xs:string*XP3.0+
fn:unparsed-text-lines($href as xs:string?) as xs:string*XP3.0+
fn:unparsed-text-lines
function reads an external resource (for
example, a file) and returns its contents as a sequence of strings, one for each line
of
text in the string representation of the resource.
More... fn:upper-case($arg as xs:string?) as xs:string
The expression fn:upper-case("abCd0")
returns "ABCD0"
.
fn:uri-collection( ) as xs:anyURI*XP3.0+
fn:uri-collection($arg as xs:string?) as xs:anyURI*XP3.0+
xs:anyURI
values representing the URIs in a URI
collection.
More... fn:xml-to-json($input as node()?, $options as map(*)) as xs:string?XP3.1
fn:xml-to-json($input as node()?) as xs:string?XP3.1
The input <array xmlns="http://www.w3.org/2005/xpath-functions"><number>1</number><string>is</string><boolean>1</boolean></array>
produces the result [1,"is",true]
.
The input <map xmlns="http://www.w3.org/2005/xpath-functions"><number key="Sunday">1</number><number
key="Monday">2</number></map>
produces the result {"Sunday":1,"Monday":2}
.
fn:year-from-date($arg as xs:date?) as xs:integer?
xs:date
.
More... The expression fn:year-from-date(xs:date("1999-05-31"))
returns 1999
.
The expression fn:year-from-date(xs:date("2000-01-01+05:00"))
returns 2000
.
The expression fn:year-from-date(xs:date("-0002-06-01"))
returns -2
. (The result is the same whether XSD 1.0 or 1.1 is in use, despite
the absence of a year 0 in the XSD 1.0 value space.)
fn:year-from-dateTime($arg as xs:dateTime?) as xs:integer?
xs:dateTime
.
More... The expression fn:year-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00"))
returns 1999
.
The expression fn:year-from-dateTime(xs:dateTime("1999-05-31T21:30:00-05:00"))
returns 1999
.
The expression fn:year-from-dateTime(xs:dateTime("1999-12-31T19:20:00"))
returns 1999
.
The expression fn:year-from-dateTime(xs:dateTime("1999-12-31T24:00:00"))
returns 2000
.
The expression fn:year-from-dateTime(xs:dateTime("-0002-06-06T00:00:00"))
returns -2
. (The result is the same whether XSD 1.0 or 1.1 is in use, despite
the absence of a year 0 in the XSD 1.0 value space.)
fn:years-from-duration($arg as xs:duration?) as xs:integer?
The expression fn:years-from-duration(xs:yearMonthDuration("P20Y15M"))
returns 21
.
The expression fn:years-from-duration(xs:yearMonthDuration("-P15M"))
returns -1
.
The expression fn:years-from-duration(xs:dayTimeDuration("-P2DT15H"))
returns 0
.
fn:zero-or-one($arg as item()*) as item()?
$arg
if it contains zero or one items. Otherwise, raises an
error.
More... array:append($array as array(*), $appendage as item()*) as array(*)XP3.1
The expression array:append(["a", "b", "c"], "d")
returns ["a", "b", "c", "d"]
.
The expression array:append(["a", "b", "c"], ("d", "e"))
returns ["a", "b", "c", ("d", "e")]
.
The expression array:append(["a", "b", "c"], ["d", "e"])
returns ["a", "b", "c", ["d", "e"]]
.
array:filter($array as array(*), $function as function(item()*) as boolean) as array(*)XP3.1
$array
for which
$function
returns true.
More... The expression array:filter(["A", "B", 1, 2], function($x) {$x instance of xs:integer})
returns [1, 2]
.
The expression array:filter(["the cat", "sat", "on the mat"], function($s){fn:count(fn:tokenize($s))
gt 1})
returns ["the cat", "on the mat"]
.
The expression array:filter(["A", "B", "", 0, 1], boolean#1)
returns ["A", "B", 1]
.
array:flatten($input as item()*) as item()*XP3.1
The expression array:flatten([1, 4, 6, 5, 3])
returns (1, 4, 6, 5, 3)
.
The expression array:flatten(([1, 2, 5], [[10, 11], 12], [], 13))
returns (1, 2, 5, 10, 11, 12, 13)
.
The expression array:flatten([(1,0), (1,1), (0,1), (0,0)])
returns (1, 0, 1, 1, 0, 1, 0, 0)
.
array:fold-left($array as array(*), $zero as item()*, $function as function(item()*, item()*) as item()*) as item()*XP3.1
The expression array:fold-left([true(), true(), false()], true(), function($x, $y){$x and $y})
returns false()
. (Returns true if every member of the input array has an effective boolean value of
true()
.)
The expression array:fold-left([true(), true(), false()], false(), function($x, $y){$x or $y})
returns true()
. (Returns true if at least one member of the input array has an effective boolean value
of true()
.)
The expression array:fold-left([1,2,3], [], function($x, $y){[$x, $y]})
returns [[[[], 1], 2], 3]
.
array:fold-right($array as array(*), $zero as item()*, $function as function(item()*, item()*) as item()*) as item()*XP3.1
The expression array:fold-right([true(), true(), false()], true(), function($x, $y){$x and $y})
returns false()
. (Returns true if every member of the input array has an effective boolean value of
true()
.)
The expression array:fold-right([true(), true(), false()], false(), function($x, $y){$x or $y})
returns true()
. (Returns true if at least one member of the input array has an effective boolean value
of true()
.)
The expression array:fold-right([1,2,3], [], function($x, $y){[$x, $y]})
returns [1, [2, [3, []]]]
.
array:for-each($array as array(*), $action as function(item()*) as item()*) as array(*)XP3.1
array:size($array)
, in which
each member is computed by applying $function
to the corresponding member of
$array
.
More... The expression array:for-each(["A", "B", 1, 2], function($z) {$z instance of xs:integer})
returns [false(), false(), true(), true()]
.
The expression array:for-each(["the cat", "sat", "on the mat"], fn:tokenize#1)
returns [("the", "cat"), "sat", ("on", "the", "mat")]
.
array:for-each-pair($array1 as array(*), $array2 as array(*), $function as function(item()*, item()*) as item()*) as array(*)XP3.1
The expression array:for-each-pair(["A", "B", "C"], [1, 2, 3], function($x, $y) { array {$x, $y}})
returns [["A", 1], ["B", 2], ["C", 3]]
.
The expression let $A := ["A", "B", "C", "D"] return array:for-each-pair($A, array:tail($A), concat#2)
returns ["AB", "BC", "CD"]
.
array:get($array as array(*), $position as xs:integer) as item()*XP3.1
The expression ["a", "b", "c"] => array:get(2)
returns "b"
.
The expression ["a", ["b", "c"]] => array:get(2)
returns ["b", "c"]
.
array:head($array as array(*)) as item()*XP3.1
$array(1)
.
More... The expression array:head([5, 6, 7, 8])
returns 5
.
The expression array:head([["a", "b"], ["c", "d"]])
returns ["a", "b"]
.
The expression array:head([("a", "b"), ("c", "d")])
returns "a", "b"
.
array:insert-before($array as array(*), $position as xs:integer, $member as item()*) as array(*)XP3.1
The expression array:insert-before(["a", "b", "c", "d"], 3, ("x", "y"))
returns ["a", "b", ("x", "y"), "c", "d"]
.
The expression array:insert-before(["a", "b", "c", "d"], 5, ("x", "y"))
returns ["a", "b", "c", "d", ("x", "y")]
.
The expression array:insert-before(["a", "b", "c", "d"], 3, ["x", "y"])
returns ["a", "b", ["x", "y"], "c", "d"]
.
array:join($arrays as array(*)*) as array(*)XP3.1
The expression array:join(())
returns [ ]
.
The expression array:join([1, 2, 3])
returns [1, 2, 3]
.
The expression array:join((["a", "b"], ["c", "d"]))
returns ["a", "b", "c", "d"]
.
The expression array:join((["a", "b"], ["c", "d"], [ ]))
returns ["a", "b", "c", "d"]
.
The expression array:join((["a", "b"], ["c", "d"], [["e", "f"]]))
returns ["a", "b", "c", "d", ["e", "f"]]
.
array:put($array as array(*), $position as xs:integer, $member as item()*) as array(*)XP3.1
The expression array:put(["a", "b", "c"], 2, "d")
returns ["a", "d", "c"]
.
The expression array:put(["a", "b", "c"], 2, ("d", "e"))
returns ["a", ("d", "e"), "c"]
.
The expression array:put(["a"], 1, ["d", "e"])
returns [["d", "e"]]
.
array:remove($array as array(*), $positions as xs:integer*) as array(*)XP3.1
The expression array:remove(["a", "b", "c", "d"], 1)
returns ["b", "c", "d"]
.
The expression array:remove(["a", "b", "c", "d"], 2)
returns ["a", "c", "d" ]
.
The expression array:remove(["a"], 1)
returns [ ]
.
The expression array:remove(["a", "b", "c", "d"], 1 to 3)
returns ["d"]
.
The expression array:remove(["a", "b", "c", "d"], ())
returns ["a", "b", "c", "d"]
.
array:reverse($array as array(*)) as array(*)XP3.1
The expression array:reverse(["a", "b", "c", "d"])
returns ["d", "c", "b", "a"]
.
The expression array:reverse([("a", "b"), ("c", "d")])
returns [("c", "d"), ("a", "b")]
.
The expression array:reverse([(1 to 5)])
returns [(1, 2, 3, 4, 5)]
.
The expression array:reverse([])
returns []
.
array:size($array as array(*)) as xs:integerXP3.1
The expression array:size(["a", "b", "c"])
returns 3
.
The expression array:size(["a", ["b", "c"]])
returns 2
.
The expression array:size([ ])
returns 0
.
The expression array:size([[ ]])
returns 1
.
array:sort($array as array(*)) as array(*)XP3.1
array:sort($array as array(*), $collation as xs:string?) as array(*)XP3.1
array:sort($array as array(*), $collation as xs:string?, $key as function(item()*) as anyAtomicType*) as array(*)XP3.1
The expression array:sort([1, 4, 6, 5, 3])
returns [1, 3, 4, 5, 6]
.
The expression array:sort([1, -2, 5, 10, -10, 10, 8], (), fn:abs#1)
returns [1, -2, 5, 8, 10, -10, 10]
.
The expression array:sort([(1,0), (1,1), (0,1), (0,0)])
returns [(0,0), (0,1), (1,0), (1,1)]
.
To sort an array of strings $in
using Swedish collation:
let $SWEDISH := "http://www.w3.org/2013/collation/UCA?lang=se" return array:sort($in, $SWEDISH)
To sort an array of maps representing employees, using last name as the major sort key and first name as the minor sort key, with the default collation:
array:sort($employees, (), function($emp) {$emp?name?last, $emp?name?first})
array:subarray($array as array(*), $start as xs:integer) as array(*)XP3.1
array:subarray($array as array(*), $start as xs:integer, $length as xs:integer) as array(*)XP3.1
The expression array:subarray(["a", "b", "c", "d"], 2)
returns ["b", "c", "d"]
.
The expression array:subarray(["a", "b", "c", "d"], 5)
returns [ ]
.
The expression array:subarray(["a", "b", "c", "d"], 2, 0)
returns [ ]
.
The expression array:subarray(["a", "b", "c", "d"], 2, 1)
returns ["b"]
.
The expression array:subarray(["a", "b", "c", "d"], 2, 2)
returns ["b", "c"]
.
The expression array:subarray(["a", "b", "c", "d"], 5, 0)
returns [ ]
.
The expression array:subarray([ ], 1, 0)
returns [ ]
.
array:tail($array as array(*)) as array(*)XP3.1
The expression array:tail([5, 6, 7, 8])
returns [6, 7, 8]
.
The expression array:tail([5])
returns [ ]
.
map:contains($map as map(*), $key as xs:anyAtomicType) as xs:booleanXP3.1
let $week := map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag", 6:"Samstag"}
The expression map:contains($week, 2)
returns true()
.
The expression map:contains($week, 9)
returns false()
.
The expression map:contains(map{}, "xyz")
returns false()
.
The expression map:contains(map{"xyz":23}, "xyz")
returns true()
.
The expression map:contains(map{"abc":23, "xyz":()}, "xyz")
returns true()
.
map:entry($key as xs:anyAtomicType, $value as item()*) as map(*)XP3.1
The expression map:entry("M", "Monday")
returns map{"M":"Monday"}
.
map:find($input as item()*, $key as xs:anyAtomicType) as array(*)XP3.1
let $responses := [map{0:'no', 1:'yes'}, map{0:'non', 1:'oui'}, map{0:'nein', 1:('ja', 'doch')}]
The expression map:find($responses, 0)
returns ['no', 'non', 'nein']
.
The expression map:find($responses, 1)
returns ['yes', 'oui', ('ja', 'doch')]
.
The expression map:find($responses, 2)
returns []
.
let $inventory := map{"name":"car", "id":"QZ123", "parts": [map{"name":"engine", "id":"YW678", "parts":[]}]}
The expression map:find($inventory, "parts")
returns [[map{"name":"engine", "id":"YW678", "parts":[]}], []]
.
map:for-each($map as map(*), $action as function(anyAtomicType, item()*) as item()*) as item()*XP3.1
The expression map:for-each(map{1:"yes", 2:"no"}, function($k,
$v){$k})
returns some permutation of (1,2)
. (This function call is equivalent to calling map:keys
. The
result is in implementation-dependent order.)
The expression distinct-values(map:for-each(map{1:"yes", 2:"no"}, function($k,
$v){$v}))
returns some permutation of ("yes", "no")
. (This function call returns the distinct values present in the map, in
implementation-dependent order.)
The expression map:merge(map:for-each(map{"a":1, "b":2}, function($k,
$v){map:entry($k, $v+1)}))
returns map{"a":2, "b":3}
. (This function call returns a map with the same keys as the input map,
with the value of each entry increased by one.)
This XQuery example converts the entries in a map to attributes on a newly constructed element node:
let $dimensions := map{'height': 3, 'width': 4, 'depth': 5}; return <box>{ map:for-each($dimensions, function ($k, $v) { attribute {$k} {$v} }) }</box>
The result is the element <box height="3" width="4"
depth="5"/>
.
map:get($map as map(*), $key as xs:anyAtomicType) as item()*XP3.1
let $week := map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag", 6:"Samstag"}
The expression map:get($week, 4)
returns "Donnerstag"
.
The expression map:get($week, 9)
returns ()
. (When the key is not present, the function returns an empty
sequence.)
The expression map:get(map:entry(7,()), 7)
returns ()
. (An empty sequence as the result can also signify that the key is
present and the associated value is an empty sequence.)
map:keys($map as map(*)) as xs:anyAtomicType*XP3.1
The expression map:keys(map{1:"yes", 2:"no"})
returns some permutation of (1,2)
. (The result is in ·implementation-dependent· order.)
map:merge($maps as map(*)*) as map(*)XP3.1
map:merge($maps as map(*)*, $options as map(*)) as map(*)XP3.1
let $week := map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag", 6:"Samstag"}
The expression map:merge(())
returns map{}
. (Returns an empty map).
The expression map:merge((map:entry(0, "no"), map:entry(1, "yes")))
returns map{0:"no", 1:"yes"}
. (Returns a map with two entries).
The expression map:merge(($week, map{7:"Unbekannt"}))
returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag",
5:"Freitag", 6:"Samstag", 7:"Unbekannt"}
. (The value of the existing map is unchanged; the returned map
contains all the entries from $week
, supplemented with an additional
entry.)
The expression map:merge(($week, map{6:"Sonnabend"}), map{"duplicates":"use-last"})
returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag",
5:"Freitag", 6:"Sonnabend"}
. (The value of the existing map is unchanged; the returned map
contains all the entries from $week
, with one entry replaced by a
new entry. Both input maps contain an entry with the key 6
; the
one used in the result is the one that comes last in the input
sequence.)
The expression map:merge(($week, map{6:"Sonnabend"}), map{"duplicates":"use-first"})
returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag",
5:"Freitag", 6:"Samstag"}
. (The value of the existing map is unchanged; the returned map
contains all the entries from $week
, with one entry replaced by a
new entry. Both input maps contain an entry with the key 6
; the
one used in the result is the one that comes first in the input
sequence.)
The expression map:merge(($week, map{6:"Sonnabend"}), map{"duplicates":"combine"})
returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag",
5:"Freitag", 6:("Samstag", "Sonnabend")}
. (The value of the existing map is unchanged; the returned map
contains all the entries from $week
, with one entry replaced by a
new entry. Both input maps contain an entry with the key 6
; the
entry that appears in the result is the sequence-concatenation of the entries
in the input maps, retaining order.)
map:put($map as map(*), $key as xs:anyAtomicType, $value as item()*) as map(*)XP3.1
let $week := map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag", 6:"Samstag"}
The expression map:put($week, 6, "Sonnabend")
returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag",
5:"Freitag", 6:"Sonnabend"}
.
The expression map:put($week, -1, "Unbekannt")
returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag",
5:"Freitag", 6:"Samstag", -1:"Unbekannt"}
.
map:remove($map as map(*), $keys as xs:anyAtomicType*) as map(*)XP3.1
let $week := map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag", 6:"Samstag"}
The expression map:remove($week, 4)
returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 5:"Freitag",
6:"Samstag"}
.
The expression map:remove($week, 23)
returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag",
5:"Freitag", 6:"Samstag"}
.
The expression map:remove($week, (0, 6 to 7))
returns map{1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag"}
.
The expression map:remove($week, ())
returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag",
6:"Samstag"}
.
map:size($map as map(*)) as xs:integerXP3.1
The expression map:size(map{})
returns 0
.
The expression map:size(map{"true":1, "false":0})
returns 2
.
math:acos($arg1 as xs:double?) as xs:double?
The expression math:acos(())
returns ()
.
The expression math:acos(0)
returns 1.5707963267948966e0
(approximately).
The expression math:acos(-0.0e0)
returns 1.5707963267948966e0
(approximately).
The expression math:acos(1.0e0)
returns 0.0e0
.
The expression math:acos(-1.0e0)
returns 3.141592653589793e0
(approximately).
The expression math:acos(2.0e0)
returns xs:double('NaN')
.
The expression math:acos(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:acos(xs:double('INF'))
returns xs:double('NaN')
.
The expression math:acos(xs:double('-INF'))
returns xs:double('NaN')
.
math:asin($arg1 as xs:double?) as xs:double?
The expression math:asin(())
returns ()
.
The expression math:asin(0)
returns 0.0e0
.
The expression math:asin(-0.0e0)
returns -0.0e0
.
The expression math:asin(1.0e0)
returns 1.5707963267948966e0
(approximately).
The expression math:asin(-1.0e0)
returns -1.5707963267948966e0
(approximately).
The expression math:asin(2.0e0)
returns xs:double('NaN')
.
The expression math:asin(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:asin(xs:double('INF'))
returns xs:double('NaN')
.
The expression math:asin(xs:double('-INF'))
returns xs:double('NaN')
.
math:atan($arg1 as xs:double?) as xs:double?
The expression math:atan(())
returns ()
.
The expression math:atan(0)
returns 0.0e0
.
The expression math:atan(-0.0e0)
returns -0.0e0
.
The expression math:atan(1.0e0)
returns 0.7853981633974483e0
(approximately).
The expression math:atan(-1.0e0)
returns -0.7853981633974483e0
(approximately).
The expression math:atan(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:atan(xs:double('INF'))
returns 1.5707963267948966e0
(approximately).
The expression math:atan(xs:double('-INF'))
returns -1.5707963267948966e0
(approximately).
math:atan2($arg1 as xs:double, $arg2 as xs:double) as xs:double
The expression math:atan2(+0.0e0, 0.0e0)
returns 0.0e0
.
The expression math:atan2(-0.0e0, 0.0e0)
returns -0.0e0
.
The expression math:atan2(+0.0e0, -0.0e0)
returns 3.141592653589793e0
.
The expression math:atan2(-0.0e0, -0.0e0)
returns -3.141592653589793e0
.
The expression math:atan2(-1, 0.0e0)
returns -1.5707963267948966e0
.
The expression math:atan2(+1, 0.0e0)
returns 1.5707963267948966e0
.
The expression math:atan2(-0.0e0, -1)
returns -3.141592653589793e0
.
The expression math:atan2(+0.0e0, -1)
returns 3.141592653589793e0
.
The expression math:atan2(-0.0e0, +1)
returns -0.0e0
.
The expression math:atan2(+0.0e0, +1)
returns +0.0e0
.
math:cos($arg1 as xs:double?) as xs:double?
The expression math:cos(())
returns ()
.
The expression math:cos(0)
returns 1.0e0
.
The expression math:cos(-0.0e0)
returns 1.0e0
.
The expression math:cos(math:pi() div 2)
returns 0.0e0
(approximately).
The expression math:cos(-math:pi() div 2)
returns 0.0e0
(approximately).
The expression math:cos(math:pi())
returns -1.0e0
(approximately).
The expression math:cos(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:cos(xs:double('INF'))
returns xs:double('NaN')
.
The expression math:cos(xs:double('-INF'))
returns xs:double('NaN')
.
math:exp($arg1 as xs:double?) as xs:double?
The expression math:exp(())
returns ()
.
The expression math:exp(0)
returns 1.0e0
.
The expression math:exp(1)
returns 2.7182818284590455e0
(approximately).
The expression math:exp(2)
returns 7.38905609893065e0
.
The expression math:exp(-1)
returns 0.36787944117144233e0
.
The expression math:exp(math:pi())
returns 23.140692632779267e0
.
The expression math:exp(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:exp(xs:double('INF'))
returns xs:double('INF')
.
The expression math:exp(xs:double('-INF'))
returns 0.0e0
.
math:exp10($arg1 as xs:double?) as xs:double?
10
^{x}.
More... The expression math:exp10(())
returns ()
.
The expression math:exp10(0)
returns 1.0e0
.
The expression math:exp10(1)
returns 1.0e1
.
The expression math:exp10(0.5)
returns 3.1622776601683795e0
.
The expression math:exp10(-1)
returns 1.0e-1
.
The expression math:exp10(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:exp10(xs:double('INF'))
returns xs:double('INF')
.
The expression math:exp10(xs:double('-INF'))
returns 0.0e0
.
math:log($arg1 as xs:double?) as xs:double?
The expression math:log(())
returns ()
.
The expression math:log(0)
returns xs:double('-INF')
.
The expression math:log(math:exp(1))
returns 1.0e0
.
The expression math:log(1.0e-3)
returns -6.907755278982137e0
.
The expression math:log(2)
returns 0.6931471805599453e0
.
The expression math:log(-1)
returns xs:double('NaN')
.
The expression math:log(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:log(xs:double('INF'))
returns xs:double('INF')
.
The expression math:log(xs:double('-INF'))
returns xs:double('NaN')
.
math:log10($arg1 as xs:double?) as xs:double?
The expression math:log10(())
returns ()
.
The expression math:log10(0)
returns xs:double('-INF')
.
The expression math:log10(1.0e3)
returns 3.0e0
.
The expression math:log10(1.0e-3)
returns -3.0e0
.
The expression math:log10(2)
returns 0.3010299956639812e0
.
The expression math:log10(-1)
returns xs:double('NaN')
.
The expression math:log10(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:log10(xs:double('INF'))
returns xs:double('INF')
.
The expression math:log10(xs:double('-INF'))
returns xs:double('NaN')
.
math:pi( ) as xs:double
The expression 2*math:pi()
returns 6.283185307179586e0
.
The expression 60 * (math:pi() div 180)
converts an angle of 60 degrees
to radians.
math:pow($arg1 as xs:double?, $arg2 as xs:numeric) as xs:double?
The expression math:pow((), 93.7)
returns ()
.
The expression math:pow(2, 3)
returns 8.0e0
.
The expression math:pow(-2, 3)
returns -8.0e0
.
The expression math:pow(2, -3)
returns 0.125e0
.
The expression math:pow(-2, -3)
returns -0.125e0
.
The expression math:pow(2, 0)
returns 1.0e0
.
The expression math:pow(0, 0)
returns 1.0e0
.
The expression math:pow(xs:double('INF'), 0)
returns 1.0e0
.
The expression math:pow(xs:double('NaN'), 0)
returns 1.0e0
.
The expression math:pow(-math:pi(), 0)
returns 1.0e0
.
The expression math:pow(0e0, 3)
returns 0.0e0
.
The expression math:pow(0e0, 4)
returns 0.0e0
.
The expression math:pow(-0e0, 3)
returns -0.0e0
.
The expression math:pow(0, 4)
returns 0.0e0
.
The expression math:pow(0e0, -3)
returns xs:double('INF')
.
The expression math:pow(0e0, -4)
returns xs:double('INF')
.
The expression math:pow(-0e0, -3)
returns xs:double('-INF')
.
The expression math:pow(0, -4)
returns xs:double('INF')
.
The expression math:pow(16, 0.5e0)
returns 4.0e0
.
The expression math:pow(16, 0.25e0)
returns 2.0e0
.
The expression math:pow(0e0, -3.0e0)
returns xs:double('INF')
.
The expression math:pow(-0e0, -3.0e0)
returns xs:double('-INF')
. (Odd-valued whole numbers are treated specially).
The expression math:pow(0e0, -3.1e0)
returns xs:double('INF')
.
The expression math:pow(-0e0, -3.1e0)
returns xs:double('INF')
.
The expression math:pow(0e0, 3.0e0)
returns 0.0e0
.
The expression math:pow(-0e0, 3.0e0)
returns -0.0e0
. (Odd-valued whole numbers are treated specially).
The expression math:pow(0e0, 3.1e0)
returns 0.0e0
.
The expression math:pow(-0e0, 3.1e0)
returns 0.0e0
.
The expression math:pow(-1, xs:double('INF'))
returns 1.0e0
.
The expression math:pow(-1, xs:double('-INF'))
returns 1.0e0
.
The expression math:pow(1, xs:double('INF'))
returns 1.0e0
.
The expression math:pow(1, xs:double('-INF'))
returns 1.0e0
.
The expression math:pow(1, xs:double('NaN'))
returns 1.0e0
.
The expression math:pow(-2.5e0, 2.0e0)
returns 6.25e0
.
The expression math:pow(-2.5e0, 2.00000001e0)
returns xs:double('NaN')
.
math:sin($arg1 as xs:double?) as xs:double?
The expression math:sin(())
returns ()
.
The expression math:sin(0)
returns 0.0e0
.
The expression math:sin(-0.0e0)
returns -0.0e0
.
The expression math:sin(math:pi() div 2)
returns 1.0e0
(approximately).
The expression math:sin(-math:pi() div 2)
returns -1.0e0
(approximately).
The expression math:sin(math:pi())
returns 0.0e0
(approximately).
The expression math:sin(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:sin(xs:double('INF'))
returns xs:double('NaN')
.
The expression math:sin(xs:double('-INF'))
returns xs:double('NaN')
.
math:sqrt($arg1 as xs:double?) as xs:double?
The expression math:sqrt(())
returns ()
.
The expression math:sqrt(0.0e0)
returns 0.0e0
.
The expression math:sqrt(-0.0e0)
returns -0.0e0
.
The expression math:sqrt(1.0e6)
returns 1.0e3
.
The expression math:sqrt(2.0e0)
returns 1.4142135623730951e0
.
The expression math:sqrt(-2.0e0)
returns xs:double('NaN')
.
The expression math:sqrt(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:sqrt(xs:double('INF'))
returns xs:double('INF')
.
The expression math:sqrt(xs:double('-INF'))
returns xs:double('NaN')
.
math:tan($arg1 as xs:double?) as xs:double?
The expression math:tan(())
returns ()
.
The expression math:tan(0)
returns 0.0e0
.
The expression math:tan(-0.0e0)
returns -0.0e0
.
The expression math:tan(math:pi() div 4)
returns 1.0e0
(approximately).
The expression math:tan(-math:pi() div 4)
returns -1.0e0
(approximately).
The expression 1 div math:tan(math:pi() div 2)
returns 0.0e0
(approximately). (Mathematically, tan(π/2) is positive infinity. But because math:pi() div 2
returns an approximation, the result of math:tan(math:pi() div 2)
will be a large
but finite number.)
The expression 1 div math:tan(-math:pi() div 2)
returns -0.0e0
(approximately). (Mathematically, tan(-π/2) is negative infinity. But because -math:pi() div 2
returns an approximation, the result of math:tan(-math:pi() div 2)
will be a large
but finite negative number.)
The expression math:tan(math:pi())
returns 0.0e0
(approximately).
The expression math:tan(xs:double('NaN'))
returns xs:double('NaN')
.
The expression math:tan(xs:double('INF'))
returns xs:double('NaN')
.
The expression math:tan(xs:double('-INF'))
returns xs:double('NaN')
.
xs:anyURI($arg as xs:anyAtomicType?) as xs:anyURI?
Casts a value to the XML Schema type anyURI.
xs:base64Binary($arg as xs:anyAtomicType?) as xs:base64Binary?
Casts a value to the XML Schema type base64Binary.
xs:boolean($arg as xs:anyAtomicType?) as xs:boolean?
Casts a value to the XML Schema type boolean.
xs:byte($arg as xs:anyAtomicType?) as xs:byte?
Casts a value to the XML Schema type byte.
xs:date($arg as xs:anyAtomicType?) as xs:date?
Casts a value to the XML Schema type date.
xs:dateTime($arg as xs:anyAtomicType?) as xs:dateTime?
Casts a value to the XML Schema type dateTime.
xs:dateTimeStamp($arg as xs:anyAtomicType?) as xs:dateTimeStamp?XP3.0+
Casts a value to the XML Schema type dateTimeStamp.
xs:dayTimeDuration($arg as xs:anyAtomicType?) as xs:dayTimeDuration?
Casts a value to the XML Schema type dayTimeDuration.
xs:decimal($arg as xs:anyAtomicType?) as xs:decimal?
Casts a value to the XML Schema type decimal.
xs:double($arg as xs:anyAtomicType?) as xs:double?
Casts a value to the XML Schema type double.
xs:duration($arg as xs:anyAtomicType?) as xs:duration?
Casts a value to the XML Schema type duration.
xs:ENTITIES($arg as xs:anyAtomicType?) as xs:ENTITIES?
Casts a value to the XML Schema type ENTITIES.
xs:ENTITY($arg as xs:anyAtomicType?) as xs:ENTITY?
Casts a value to the XML Schema type ENTITY.
xs:error($arg as xs:anyAtomicType?) as xs:error?XP3.0+
Casts a value to the XML Schema type error.
xs:float($arg as xs:anyAtomicType?) as xs:float?
Casts a value to the XML Schema type float.
xs:gDay($arg as xs:anyAtomicType?) as xs:gDay?
Casts a value to the XML Schema type gDay.
xs:gMonth($arg as xs:anyAtomicType?) as xs:gMonth?
Casts a value to the XML Schema type gMonth.
xs:gMonthDay($arg as xs:anyAtomicType?) as xs:gMonthDay?
Casts a value to the XML Schema type gMonthDay.
xs:gYear($arg as xs:anyAtomicType?) as xs:gYear?
Casts a value to the XML Schema type gYear.
xs:gYearMonth($arg as xs:anyAtomicType?) as xs:gYearMonth?
Casts a value to the XML Schema type gYearMonth.
xs:hexBinary($arg as xs:anyAtomicType?) as xs:hexBinary?
Casts a value to the XML Schema type hexBinary.
xs:ID($arg as xs:anyAtomicType?) as xs:ID?
Casts a value to the XML Schema type ID.
xs:IDREF($arg as xs:anyAtomicType?) as xs:IDREF?
Casts a value to the XML Schema type IDREF.
xs:IDREFS($arg as xs:anyAtomicType?) as xs:IDREFS?
Casts a value to the XML Schema type IDREFS.
xs:int($arg as xs:anyAtomicType?) as xs:int?
Casts a value to the XML Schema type int.
xs:integer($arg as xs:anyAtomicType?) as xs:integer?
Casts a value to the XML Schema type integer.
xs:language($arg as xs:anyAtomicType?) as xs:language?
Casts a value to the XML Schema type language.
xs:long($arg as xs:anyAtomicType?) as xs:long?
Casts a value to the XML Schema type long.
xs:Name($arg as xs:anyAtomicType?) as xs:Name?
Casts a value to the XML Schema type Name.
xs:NCName($arg as xs:anyAtomicType?) as xs:NCName?
Casts a value to the XML Schema type NCName.
xs:negativeInteger($arg as xs:anyAtomicType?) as xs:negativeInteger?
Casts a value to the XML Schema type negativeInteger.
xs:NMTOKEN($arg as xs:anyAtomicType?) as xs:NMTOKEN?
Casts a value to the XML Schema type NMTOKEN.
xs:NMTOKENS($arg as xs:anyAtomicType?) as xs:NMTOKENS?
Casts a value to the XML Schema type NMTOKENS.
xs:nonNegativeInteger($arg as xs:anyAtomicType?) as xs:nonNegativeInteger?
Casts a value to the XML Schema type nonNegativeInteger.
xs:nonPositiveInteger($arg as xs:anyAtomicType?) as xs:nonPositiveInteger?
Casts a value to the XML Schema type nonPositiveInteger.
xs:normalizedString($arg as xs:anyAtomicType?) as xs:normalizedString?
Casts a value to the XML Schema type normalizedString.
xs:numeric($arg as xs:anyAtomicType?) as xs:numeric?
Casts a value to the XML Schema type numeric.
xs:positiveInteger($arg as xs:anyAtomicType?) as xs:positiveInteger?
Casts a value to the XML Schema type positiveInteger.
xs:QName($arg as xs:anyAtomicType?) as xs:QName?
Casts a value to the XML Schema type QName.
xs:short($arg as xs:anyAtomicType?) as xs:short?
Casts a value to the XML Schema type short.
xs:string($arg as xs:anyAtomicType?) as xs:string?
Casts a value to the XML Schema type string.
xs:time($arg as xs:anyAtomicType?) as xs:time?
Casts a value to the XML Schema type time.
xs:token($arg as xs:anyAtomicType?) as xs:token?
Casts a value to the XML Schema type token.
xs:unsignedByte($arg as xs:anyAtomicType?) as xs:unsignedByte?
Casts a value to the XML Schema type unsignedByte.
xs:unsignedInt($arg as xs:anyAtomicType?) as xs:unsignedInt?
Casts a value to the XML Schema type unsignedInt.
xs:unsignedLong($arg as xs:anyAtomicType?) as xs:unsignedLong?
Casts a value to the XML Schema type unsignedLong.
xs:unsignedShort($arg as xs:anyAtomicType?) as xs:unsignedShort?
Casts a value to the XML Schema type unsignedShort.
xs:untypedAtomic($arg as xs:anyAtomicType?) as xs:untypedAtomic?
Casts a value to the XML Schema type untypedAtomic.
xs:yearMonthDuration($arg as xs:anyAtomicType?) as xs:yearMonthDuration?
Casts a value to the XML Schema type yearMonthDuration.
file:append($file as xs:string, $items as item()*) as empty-sequence()
file:append($file as xs:string, $items as item()*, $params as element(output:serialization-parameters)) as empty-sequence()
Appends a sequence of items to a file. If the file pointed by $file
does
not exist, a new file will be created. More...
file:append-binary($file as xs:string, $value as xs:base64Binary) as empty-sequence()
Appends a Base64 item as binary to a file. If the file pointed by $file
does not exist, a new file will be created. More...
file:append-text($file as xs:string, $value as xs:string) as empty-sequence()
file:append-text($file as xs:string, $value as xs:string, $encoding as xs:string) as empty-sequence()
Appends a string to a file. If the file pointed by $file
does not exist,
a new file will be created. More...
file:append-text-lines($file as xs:string, $values as xs:string*) as empty-sequence()
file:append-text-lines($file as xs:string, $lines as xs:string*, $encoding as xs:string) as empty-sequence()
Appends a sequence of strings to a file, each followed by the system-dependent
newline character. If the file pointed by $file
does not exist, a new
file will be created. More...
file:base-dir( ) as xs:string
Returns the parent directory of the static base URI.
If the Base URI property is undefined, the empty sequence is returned. -
If a static base URI exists, and if points to a local file path,
this function returns the same result as the expression
file:parent(static-base-uri())
. More...
file:children($path as xs:string) as xs:string*
Returns the paths of all files and directories that are located in the given directory. The order of the items in the resulting sequence is not defined. The "." and ".." items are never returned. More...
file:copy($source as xs:string, $target as xs:string) as empty-sequence()
Copies a file or a directory given a source and a target path/URI. The following
cases may occur if $source
points to a file: More...
file:create-dir($dir as xs:string) as empty-sequence()
Creates a directory, or does nothing if the directory already exists. The operation will create all non-existing parent directories. More...
file:create-temp-dir($prefix as xs:string, $suffix as xs:string) as xs:string
file:create-temp-dir($prefix as xs:string, $suffix as xs:string, $dir as xs:string) as xs:string
Creates a temporary directory and all non-existing parent directories and returns the full path to the created directory. More...
file:create-temp-file($prefix as xs:string, $suffix as xs:string) as xs:string
file:create-temp-file($prefix as xs:string, $suffix as xs:string, $dir as xs:string) as xs:string
Creates a temporary file and all non-existing parent directories and returns the full path to the created file. More...
file:current-dir( ) as xs:string
Returns the current working directory. -
This function returns the same result as the function call
file:resolve-path('.')
. More...
file:delete($path as xs:string) as empty-sequence()
file:delete($path as xs:string, $recursive as xs:boolean) as empty-sequence()
Deletes a file or a directory from the file system. More...
file:dir-separator( ) as xs:string
Returns the value of the operating system-specific directory separator, which usually
is /
on UNIX-based systems and \
on Windows systems. More...
file:exists($path as xs:string) as xs:boolean
Tests if the file or directory pointed by $path
exists. More...
file:is-dir($path as xs:string) as xs:boolean
Tests if $path
points to a directory. On UNIX-based systems the root and
the volume roots are considered directories. More...
file:is-file($path as xs:string) as xs:boolean
Tests if $path
points to a file. More...
file:last-modified($path as xs:string) as xs:dateTime
Returns the last modification time of a file or directory. More...
file:line-separator( ) as xs:string
Returns the value of the operating system-specific line separator, which usually is
on UNIX-based systems,
on
Windows systems and
on Mac systems. More...
file:list($dir as xs:string) as xs:string*
file:list($dir as xs:string, $recursive as xs:boolean) as xs:string*
file:list($dir as xs:string, $recursive as xs:boolean, $pattern as xs:string) as xs:string*
Lists all files and directories in a given directory. The order of the items in the
resulting sequence is not defined. The "." and ".." items are never returned. The
returned paths are relative to the provided directory $dir
. More...
file:move($source as xs:string, $target as xs:string) as empty-sequence()
Moves a file or a directory given a source and a target path/URI. The following cases
may occur if $source
points to a file: More...
file:name($path as xs:string) as xs:string
Returns the name of a file or directory. More...
file:parent($path as xs:string) as xs:string?
Transforms the given path into an absolute path, as specified by
file:path-separator( ) as xs:string
Returns the value of the operating system-specific path separator, which usually is
:
on UNIX-based systems and ;
on Windows systems. More...
file:path-to-native($path as xs:string) as xs:string
Transforms a URI, an absolute path, or relative path to a canonical, system-dependent path representation. A canonical path is both absolute and unique and thus contains no redirections such as references to parent directories or symbolic links. More...
file:path-to-uri($path as xs:string) as xs:anyURI
Transforms a file system path into a URI with the file://
scheme. If the
path is relative, it is first resolved against the current working directory. More...
file:read-binary($file as xs:string) as xs:base64Binary
file:read-binary($file as xs:string, $offset as xs:integer) as xs:base64Binary
file:read-binary($file as xs:string, $offset as xs:integer, $length as xs:integer) as xs:base64Binary
Returns the content of a file in its Base64 representation. More...
file:read-text($file as xs:string) as xs:string
file:read-text($file as xs:string, $encoding as xs:string) as xs:string
Returns the content of a file in its string representation. More...
file:read-text-lines($file as xs:string, $encoding as xs:string) as xs:string*
file:read-text-lines($file as xs:string) as xs:string*
Returns the contents of a file as a sequence of strings, separated at newline boundaries. More...
file:resolve-path($path as xs:string) as xs:string
Transforms a relative path into an absolute operating system path by resolving it against the current working directory. More...
file:size($file as xs:string) as xs:integer
Returns the byte size of a file, or the value 0
for directories. More...
file:temp-dir( ) as xs:string
Returns the path to the default temporary-file directory of an operating system. More...
file:write($file as xs:string, $items as item()*) as empty-sequence()
file:write($file as xs:string, $items as item()*, $params as element(output:serialization-parameters)) as empty-sequence()
Writes a sequence of items to a file.
If $file
already exists, it will be overwritten; otherwise, it will be created. More...
file:write-binary($file as xs:string, $value as xs:base64Binary) as empty-sequence()
file:write-binary($file as xs:string, $value as xs:base64Binary, $offset as xs:integer) as empty-sequence()
Writes a Base64 item as binary to a file.
If $file
already exists, it will be overwritten; otherwise, it will be created. More...
file:write-text($file as xs:string, $value as xs:string) as empty-sequence()
file:write-text($file as xs:string, $value as xs:string, $encoding as xs:string) as empty-sequence()
Writes a strings to a file. If $file
already exists, it will be
overwritten. More...
file:write-text-lines($file as xs:string, $values as xs:string*) as empty-sequence()
file:write-text-lines($file as xs:string, $values as xs:string*, $encoding as xs:string) as empty-sequence()
Writes a sequence of strings to a file, each followed by the system-dependent newline character.
If $file
already exists, it will be overwritten; otherwise, it will be created. More...
x:binary-to-string($data as xs:hexBinary|xs:base64Binary[ , $encoding as xs:string] ) as xs:string
$data
to a string using the given $encoding
x:css($css as xs:string)
css("a.aclass")/@href
.
x:deep-text()
x:deep-text($arg1)
deep-text(' ')
to separate text of different nodes.
x:eval($query as xs:string [ , $options as map(*) ] )
$options("language")
can choose the language, e.g. "xquery", "xquery3", "xquery3.1", "xquery3.0", "xquery1", "xquery1.0", "xpath", "xpath3", "xpath3.1", "xpath3.0", or "xpath2"
.
x:extract($string as xs:string, $regex as xs:string [ , $match as xs:integer * , [$flags as xs:string] ] )
$regex
to $string
and returns only the matching part. This returns basically what the program grep -oE
would return. $match
argument is provided, only the $match
-th submatch will be returned. This can be a sequence of several integers.
x:form( [$form as node()*] [ , $override as item()*] )
There are three kinds of values you can specify in the $override
parameter to override data in the request:
"name=value&name2=..."
. The string will be split at & and each name=value
pair is inserted in the request.{"a": "b", "c": "d e"}
inserts a=b&c=d+e
. <button name="a" value="b"/>
will insert a=b
to the request.The key/value-pairs in the override parameter are not just appended to the request, but override existing values first, while keeping the ordering. For example, if the default data of the request is a=1&b=2&a=3
,
"a="
becomes a request a=&b=2
,"a=x"
becomes a request a=x&b=2
,"b=x"
becomes a request a=1&b=x&a=3
,"a=x&a=y"
becomes a request a=x&b=2&a=y
,"a=x&a=y&a=z"
becomes a request a=x&b=2&a=y&a=z
,"a=x&a=y&a=z&b=u"
becomes a request a=x&b=u&a=y&a=z
,"a=x&a=y&a=z&b=u&b=v"
becomes a request a=x&b=u&a=y&a=z&b=v
,{"a": ()}
becomes a request b=2
(this might be surprising, but it is the only way to remove data from a request),{"a": ""}
becomes a request a=&b=2
,{"a": "x"}
becomes a request a=x&b=2
,{"a": ("x","y")}
becomes a request a=x&b=2&a=y
,{"a": ("x","y","z")}
becomes a request a=x&b=2&a=y&a=z
,({"a": ()},"a=x")
becomes a request a=x&b=2
,({"a": ""},"a=x")
becomes a request a=&b=2&a=x
,({"a": "x"},"a=y")
becomes a request a=x&b=2&a=y
,({"a": ("x","y"},"a=z&a=u")
becomes a request a=x&b=2&a=y&a=z&a=u
.Data given as map is treated as not url encoded, and (if necessary) is automatically url encoded. Data given as string is treated as url encoded, and (if necessary) is automatically decoded.
Data given as map is also special, because you can give multiple values for each keys as sequence. Furthermore, the value itself can be another map to specify more complex data. For example, {"name": {"value": "..", "type": "text/plain"}}
will add a value with a text/plain Content-Type (this requires a form with multipart encoding). The following additional properties can be specified:
value
: for a string value.filename
: to set the filename field of the Content-Disposition header.file
: to upload a file. The file is loaded, and the value
and filename
properties are set.type
: Becomes a Content-Type headerheaders
: An arbitrary sequence of headersx
and y
: Add two parameters name.x=..&name.y=..
for simulating a click on an image input element.form
function returns a JSON object with these properties:
url
: The url the form should be send to (includes the encoded data for a GET request)method
: POST or GETpost
: Encoded post data. Depending on the enctype attribute of the HTML form, the data is url encoded or multipart encoded.headers
: Sequence of additional headerscharset
: Charset of the percent-encoding (if it is not UTF-8). This is usually not used for anything, but without this property you could not know what the data actually means.x:form-combine($arg1 as map(*), $arg2 as item()*) as map(*)
x:garbage-collect()
x:get($arg1 as xs:string) as item()*
x:get($arg1 as xs:string, $arg2 as item()*) as item()*
x:get-property($arg1, $arg2)
$obj
($name
) should be used.
x:inner-html()
x:inner-html($arg1)
x:inner-text()
x:inner-text($arg1)
x:inner-xml()
x:inner-xml($arg1)
x:is-nth($i as xs:integer, $a as xs:integer, $b as xs:integer)
x:join($sequence, [$separator])
x:matched-text()
<p>{matched-text()}<br/></p>
will return the text from the start of the p-element until the first line break. If there are other HTML elements before the line breaks, the text nodes of those elements are concatenated.
x:object()
x:object($arg1)
$var
. Default values can be passed as sequence of name/value pairs. x:outer-html()
x:outer-html($arg1)
x:outer-xml()
x:outer-xml($arg1)
x:parse-date($input as xs:string, $format as xs:string) as xs:date
$format
is a standard Pascal format. (see x:parse-dateTime)
x:parse-dateTime($input as xs:string, $format as xs:string) as xs:dateTime
$format
is a standard Pascal format, using ymdhnsz (e.g. "yyyy-mm-dd hh:nn:ss"), not a XQuery 3.0 picture string.
x:parse-html($arg1 as xs:string?) as document-node(element(*)) ?
x:parse-time($input as xs:string, $format as xs:string) as xs:time
$format
is a standard Pascal format (see x:parse-dateTime)
x:random()
x:random($arg1)
x:random-seed()
x:random-seed($arg1)
x:read( ) as untypedAtomicXidel
x:request-combine($arg1 as item(), $arg2 as item()*) as map(*)
x:request-decode($arg1 as item()) as map(*)
It returns a map with the following properties:
protocol
username
password
host
port
path
query
target
params
x:resolve-html($relative as item()?, $base as string) as item?
$relative
sequence to an HTTP request with an absolute URL/URI, using $base
as reference base URI.$base
is not a node it treated as simple absolute URI. If $base
is a node, the function uses the base URI of the document that contains the node.x:sleep($arg1)
x:split-equal($arg1, $arg2)
x:split-equal($arg1, $arg2, $arg3)
x:string-to-base64Binary($data as xs:string[ , $encoding as xs:string] ) as xs:base64Binary
$data
with the given $encoding
x:string-to-hexBinary($data as xs:string[ , $encoding as xs:string] ) as xs:hexBinary
$data
with the given $encoding
x:system($arg1 as string) as stringXidel
x:transform($root as item()* [ , $f as function(*) [ , $options as map(*)] ] ) as item()*
$f
for every descendant node and replacing the node with the value returned by the function.transform(/, function($x
) { if (name($x
) = "a") then <a>{$x
/@*, <b>{$x
/node()}</b>}</a> else $x
} )
will make every link bold.$root
is omitted, the context item . is used.$options
("always-recurse") is true, all values returned by $f
are also transformed with further calls of $f
.x:type-of($arg1)
x:uri-combine($arg1 as item()*, $arg2 as item()*) as xs:string
x:uri-decode($uri-part as xs:string?)
x:uri-encode($uri-part as xs:string?)
pxp:json($arg1 as xs:string) as item()*
pxp:json($arg1 as xs:string, $arg2 as map(*)) as item()*
pxp:match($pattern as item(), $node as node()+)
$pattern
(see pattern/template documentation)
and the nodes, and returns a list or an object of matched values. match(<a>{{.}}</a>, <x><a>FOO</a><a>BAR</a></x>)
returns <a>FOO</a>
, and match(<a>*{{.}}</a>, <x><a>FOO</a><a>BAR</a></x>)
returns (<a>FOO</a>, <a>BAR</a>).
match(<x><a>{{first:=.}}</a><a>{{second:=.}}</a></x>, <x><a>FOO</a><a>BAR</a></x>)
returns an object with two properties "first" and "bar", containing respectively <a>FOO</a> and <a>BAR</a>. match(<x><a>{{first:=.}}</a><a>{{second:=.}}</a></x>, <x><a>FOO</a><a>BAR</a></x>).first
. match(<x><a>{{res:=.}}</a><a>{{res:=.}}</a></x>, <x><a>FOO</a><a>BAR</a></x>)
returns an object with a single property res with value (<a>FOO</a>, <a>BAR</a>)
. match("<a>{.}</a>", <x><a>FOO</a><a>BAR</a></x>)
.pxp:serialize-json($arg1 as item()*) as xs:string
pxp:serialize-json($arg1 as item()*, $arg2 as item()?) as xs:string
x:argc( ) as integerXidel
x:argv($arg1 as integer) as stringXidel
x:call-action($name as xs:string) as empty-sequence()
x:clear-log( [$var as xs:string] ) as empty-sequence()
x:cps($arg1 as item()*) as item()*
x:get-log( [$var as xs:string] ) as item()*
x:has-action($name as xs:string) as xs:boolean
x:integer($arg as item()[ , $base as integer] ) as integerXidel
x:integer-to-base($arg1 as integer, $base as integer) as stringXidel
x:lines($arg1 as xs:string?) as xs:string*
x:product($arg1 as xs:anyAtomicType*) as xs:anyAtomicType
x:replace-nodes($nodes as item()*, $replacement as item()*) as item()*
$nodes
with $replacement
and returns the document containing the nodes.$nodes
. x:replace-nodes(//foo, ())
removes all nodes selected by //foo
x:replace-nodes(//text(), "example")
changes all text to example
, e.g. <x>y</x>
to <x>example<x>
.
x:replace-nodes(//text(), upper-case#1)
converts all text to upper case, e.g. <x>y</x>
to <x>Y<x>
.
x:replace-nodes(//foo, function($e){ $e/element {upper-case(name())} {node(),@*} })
converts the names of selected nodes to upper-case, e.g. <x><foo>y</foo></x>
to <x><FOO>Y</FOO><x>
.
x:replace-nodes(//text(), function($e){<b>{$e}</b>})
surrounds all text by b-elements, e.g. <x>y</x>
to <x><b>y</b><x>
.
x:replace-nodes(//foo, function($e){ (<example/>,$e) })
prepends an element to the selected nodes, e.g. transforms <x><foo>y</foo></x>
to <x><example/><foo>y</foo><x>
.
x:request($request as item()*) as map(*)*Xidel
jn:is-null($arg1 as item()) as xs:boolean
jn:json-doc($arg1 as xs:string?) as json-item()?
This function returns the JSON node associated with the supplied URI. It has the same semantics as fn:doc
, except that it returns an Object or an Array.
More...
jn:keys($arg1 as item()*) as xs:string*
This function returns all keys of all objects in the supplied sequence, using the jdm:keys accessor, with duplicates eliminated. The order in which the keys are returned is implementation-dependent but must be stable within a snapshot. Non-objects in the input sequence are ignored. More...
jn:members($arg1 as item()*) as item()*
This functions returns all values that are in all arrays of an input sequence, preserving the order. Non-arrays in the input sequence are ignored. More...
jn:null( ) as xs:null
This function returns the JSON null. More...
jn:object(, ...)
jn:parse-json($arg1 as xs:string?) as json-item()*
jn:parse-json($arg1 as xs:string?, $arg2 as map(*)) as json-item()*
This function has the same semantics as fn:parse-xml(), except that it parses the string as JSON (not XML), and returns a sequence of objects or arrays rather than an XML document. More...
jn:size($arg1 as array(*)?) as xs:integer?
This function returns the size of the supplied array using the jdm:size accessor (or the empty sequence if the empty sequence is provided). More...
The JSONiq sections are taken from the JSONiq reference and are again licensed as CC-BY-SA.jnlib:accumulate($arg1 as item()*) as object()
This function dynamically builds an object, like jn:object, except that it does not throw an error upon pair collision. Instead, it accumulates them into an array. Non-object items in the input sequence are ignored. More...
jnlib:descendant-arrays($arg1 as item()*) as array(*)*
This function returns all arrays contained within the supplied items, regardless of depth. More...
jnlib:descendant-objects($arg1 as item()*) as object()*
This function returns all objects contained within the supplied items, regardless of depth. More...
jnlib:descendant-pairs($arg1 as item()*) as item()*
This function returns all descendant pairs within the supplied items. More...
jnlib:flatten($arg1 as item()*) as item()*
This function recursively "flattens" the supplied (top-level) arrays, leaving non-arrays unchanged. More...
jnlib:intersect($arg1 as item()*) as object()
This function returns an object that only contains keys shared by all input objects, and associates to each of these keys the corresponding values in the input objects (wrapped in an array if more than one). Non-objects are ignored. More...
jnlib:project($arg1 as item()*, $arg2 as xs:string*) as item()*
This function iterates on the input sequence. It projects objects by filtering their pairs and leaves non-objects intact. More...
jnlib:remove-keys($arg1 as item()*, $arg2 as xs:string*) as item()*
This function iterates on the input sequence. It removes the pairs with the given keys from all objects and leaves non-objects intact. More...
jnlib:values($arg1 as item()*) as item()*
This function returns all values in the supplied objects. Non-objects are ignored. More...
The JSONiq sections are taken from the JSONiq reference and are again licensed as CC-BY-SA.