-
-
fn:string(object)
-
- Returns the value of $arg represented as a xs:string. If no argument is supplied, the
- context item (.) is used as the default argument. The behavior of the function if the
- argument is omitted is exactly the same as if the context item had been passed as the
- argument.
-
- If the context item is undefined, error [err:XPDY0002]XP is raised.
-
- If $arg is the empty sequence, the zero-length string is returned.
-
- If $arg is a node, the function returns the string-value of the node, as obtained using
- the dm:string-value accessor defined in the Section 5.13 string-value AccessorDM.
-
- If $arg is an atomic value, then the function returns the same string as is returned by
- the expression " $arg cast as xs:string " (see 17 Casting).
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | string |
- The object to convert to a string |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | string((1<0)) |
- false |
-
-
- | string(.11) |
- 0.11 |
-
-
-
W3C Documentation reference
-
-
-
fn:codepoints-to-string()
-
- Creates an xs:string from a sequence of The Unicode Standard code points. Returns the
- zero-length string if $arg is the empty sequence. If any of the code points in $arg is
- not a legal XML character, an error is raised [err:FOCH0001].
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:integer* |
- $arg |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | codepoints-to-string((2309, 2358, 2378, 2325)) |
- अशॊक |
-
-
- | codepoints-to-string((40, 32, 865, 176, 32, 860, 662, 32, 865, 176, 41))
- |
- ( ͡° ͜ʖ ͡°) |
-
-
-
W3C Documentation reference
-
-
-
fn:string-to-codepoints()
-
- Returns the sequence of The Unicode Standard code points that constitute an xs:string.
- If $arg is a zero-length string or the empty sequence, the empty sequence is
- returned.
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string* |
- $arg |
-
-
-
Return type: xs:integer*
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | string-to-codepoints("Thérèse") |
- (84, 104, 233, 114, 232, 115, 101) |
-
-
-
W3C Documentation reference
-
-
-
fn:compare()
-
- Returns -1, 0, or 1, depending on whether the value of the $comparand1 is respectively
- less than, equal to, or greater than the value of $comparand2, according to the rules of
- the collation that is used.
-
- The collation used by the invocation of this function is determined according to the
- rules in 7.3.1 Collations.
-
- If either argument is the empty sequence, the result is the empty sequence.
-
- This function, invoked with the first signature, backs up the "eq", "ne", "gt", "lt",
- "le" and "ge" operators on string values.
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $comparand1 |
-
-
- | xs:string? |
- $comparand2 |
-
-
- | xs:string |
- $collation (Optional) |
-
-
-
Return type: xs:integer*
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | compare('abc', 'abc') |
- 0 |
-
-
- | compare('abc', 'acc') |
- -1 |
-
-
- | compare('abc', 'acc') |
- 1 |
-
-
-
W3C Documentation reference
-
-
-
fn:codepoint-equal()
-
- Returns true or false depending on whether the value of $comparand1 is equal to the
- value of $comparand2, according to the
Unicode code
- point collation.
-
- If either argument is the empty sequence, the result is the empty sequence.
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $comparand1 |
-
-
- | xs:string? |
- $comparand2 |
-
-
-
Return type: xs:boolean?
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | codepoint-equal("asdf", "asdf") |
- true |
-
-
- | codepoint-equal("asdf", "asdf ") |
- false |
-
-
-
W3C Documentation reference
-
-
-
fn:concat()
-
- Accepts two or more xs:anyAtomicType arguments and casts them to xs:string. Returns the
- xs:string that is the concatenation of the values of its arguments after conversion. If
- any of the arguments is the empty sequence, the argument is treated as the zero-length
- string.
-
- The fn:concat function is specified to allow two or more arguments, which are
- concatenated together. This is the only function specified in this document that allows
- a variable number of arguments. This capability is retained for compatibility with [XML
- Path Language (XPath) Version 1.0].
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:anyAtomicType? |
- $arg1 |
-
-
- | xs:anyAtomicType? |
- $arg2 |
-
-
- | xs:anyAtomicType? |
- $arg... (Optional) |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | concat('un', 'grateful') |
- ungrateful |
-
-
- | concat('Thy ', (), 'old ', "groans", "", ' ring', ' yet', ' in', ' my', '
- ancient',' ears.') |
- Thy old groans ring yet in my ancient ears. |
-
-
- | fn:concat('Ciao!',()) |
- Ciao! |
-
-
-
W3C Documentation reference
-
-
-
fn:string-join()
-
- Returns a xs:string created by concatenating the members of the $arg1 sequence using
- $arg2 as a separator. If the value of $arg2 is the zero-length string, then the members
- of $arg1 are concatenated without a separator.
-
- If the value of $arg1 is the empty sequence, the zero-length string is returned.
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string* |
- $arg1 |
-
-
- | xs:string |
- $arg2 |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | string-join(('Now', 'is', 'the', 'time', '...'), ' ') |
- Now is the time ... |
-
-
- | string-join(('Blow, ', 'blow, ', 'thou ', 'winter ', 'wind!'), '') |
- Blow, blow, thou winter wind! |
-
-
-
W3C Documentation reference
-
-
-
fn:substring()
-
- Returns the portion of the value of $sourceString beginning at the position indicated by
- the value of $startingLoc and continuing for the number of characters indicated by the
- value of $length. The characters returned do not extend beyond $sourceString. If
- $startingLoc is zero or negative, only those characters in positions greater than zero
- are returned.
- More specifically, the three argument version of the function returns the characters in
- $sourceString whose position $p obeys:
-
fn:round($startingLoc) <= $p < fn:round($startingLoc) + fn:round($length)
- The two argument version of the function assumes that $length is infinite and returns
- the characters in $sourceString whose position $p obeys:
-
fn:round($startingLoc) <= $p < fn:round(INF)
- In the above computations, the rules for op:numeric-less-than() and
- op:numeric-greater-than() apply.
- If the value of $sourceString is the empty sequence, the zero-length string is
- returned.
-
-
Note:
- The first character of a string is located at position 1, not position 0.
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $sourceString |
-
-
- | xs:double |
- $startingLoc |
-
-
- | xs:double |
- $length (Optional) |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | substring("motor car", 6) |
- " car" |
-
-
- | substring("metadata", 4, 3) |
- ada |
-
-
-
W3C Documentation reference
-
-
-
fn:string-length()
-
- Returns an xs:integer equal to the length in characters of the value of $arg.
-
- If the value of $arg is the empty sequence, the xs:integer 0 is returned.
-
- If no argument is supplied, $arg defaults to the string value (calculated using
- fn:string()) of the context item (.). If no argument is supplied and the context item is
- undefined an error is raised: [err:XPDY0002].
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg (Optional) |
-
-
-
Return type: xs:integer
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | string-length("Harp not on that string, madam; that is past.") |
- 45 |
-
-
- | string-length(()) |
- 0 |
-
-
-
W3C Documentation reference
-
-
-
fn:normalize-space()
-
- Returns the value of $arg with whitespace normalized by stripping leading and trailing
- whitespace and replacing sequences of one or more than one whitespace character with a
- single space, #x20.
-
- If the value of $arg is the empty sequence, returns the zero-length string.
-
- If no argument is supplied, then $arg defaults to the string value (calculated using
- fn:string()) of the context item (.). If no argument is supplied and the context item is
- undefined an error is raised: [err:XPDY0002].
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg (Optional) |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | normalize-space(" The wealthy curled darlings of our nation. ") |
- The wealthy curled darlings of our nation. |
-
-
- | normalize-space(()) |
- "" |
-
-
-
W3C Documentation reference
-
-
-
fn:normalize-unicode()
-
- Returns the value of $arg normalized according to the normalization criteria for a
- normalization form identified by the value of $normalizationForm. The effective value of
- the $normalizationForm is computed by removing leading and trailing blanks, if present,
- and converting to upper case.
-
- If the value of $arg is the empty sequence, returns the zero-length string.
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg |
-
-
- | xs:string |
- $normalizationForm (Optional) |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | normalize-unicode("test ") |
- test |
-
-
-
W3C Documentation reference
-
-
-
fn:upper-case()
-
- Returns the value of $arg after translating every character to its upper-case
- correspondent as defined in the appropriate case mappings section in the Unicode
- standard [The Unicode Standard]. For versions of Unicode beginning with the 2.1.8
- update, only locale-insensitive case mappings should be applied. Beginning with version
- 3.2.0 (and likely future versions) of Unicode, precise mappings are described in default
- case operations, which are full case mappings in the absence of tailoring for particular
- languages and environments. Every lower-case character that does not have an upper-case
- correspondent, as well as every upper-case character, is included in the returned value
- in its original form.
-
- If the value of $arg is the empty sequence, the zero-length string is returned.
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | upper-case("abCd0") |
- ABCD0 |
-
-
-
W3C Documentation reference
-
-
-
fn:lower-case()
-
- Returns the value of $arg after translating every character to its lower-case
- correspondent as defined in the appropriate case mappings section in the Unicode
- standard [The Unicode Standard]. For versions of Unicode beginning with the 2.1.8
- update, only locale-insensitive case mappings should be applied. Beginning with version
- 3.2.0 (and likely future versions) of Unicode, precise mappings are described in default
- case operations, which are full case mappings in the absence of tailoring for particular
- languages and environments. Every upper-case character that does not have a lower-case
- correspondent, as well as every lower-case character, is included in the returned value
- in its original form.
-
- If the value of $arg is the empty sequence, the zero-length string is returned.
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | lower-case("abCd0") |
- abcd0 |
-
-
-
W3C Documentation reference
-
-
-
fn:translate()
-
- Returns the value of $arg modified so that every character in the value of $arg that
- occurs at some position N in the value of $mapString has been replaced by the character
- that occurs at position N in the value of $transString.
-
- If the value of $arg is the empty sequence, the zero-length string is returned.
-
- Every character in the value of $arg that does not appear in the value of $mapString is
- unchanged.
-
- Every character in the value of $arg that appears at some position M in the value of
- $mapString, where the value of $transString is less than M characters in length, is
- omitted from the returned value. If $mapString is the zero-length string $arg is
- returned.
-
- If a character occurs more than once in $mapString, then the first occurrence determines
- the replacement character. If $transString is longer than $mapString, the excess
- characters are ignored.
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg |
-
-
- | xs:string |
- $mapString |
-
-
- | xs:string |
- $mapString |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | translate("bar","abc","ABC") |
- BAr |
-
-
- | translate("--aaa--","abc-","ABC") |
- AAA |
-
-
- | translate("abcdabc", "abc", "AB") |
- ABdAB |
-
-
-
W3C Documentation reference
-
-
-
fn:encode-for-uri()
-
- This function encodes reserved characters in an xs:string that is intended to be used in
- the path segment of a URI. It is invertible but not idempotent. This function applies
- the URI escaping rules defined in section 2 of [RFC 3986] to the xs:string supplied as
- $uri-part. The effect of the function is to escape reserved characters. Each such
- character in the string is replaced with its percent-encoded form as described in [RFC
- 3986].
-
- If $uri-part is the empty sequence, returns the zero-length string.
-
- All characters are escaped except those identified as "unreserved" by [RFC 3986], that
- is the upper- and lower-case letters A-Z, the digits 0-9, HYPHEN-MINUS ("-"), LOW LINE
- ("_"), FULL STOP ".", and TILDE "~".
-
- Note that this function escapes URI delimiters and therefore cannot be used
- indiscriminately to encode "invalid" characters in a path segment.
-
- Since [RFC 3986] recommends that, for consistency, URI producers and normalizers should
- use uppercase hexadecimal digits for all percent-encodings, this function must always
- generate hexadecimal values using the upper-case letters A-F.
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $uri-part |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | encode-for-uri("https://www.google.com") |
- "https%3A%2F%2Fwww. google.com" |
-
-
- | concat("http://www.example.com/", encode-for-uri("~bébé")) |
- http://www.example.com/ ~b%C3%A9b%C3%A9 |
-
-
- | concat("http://www.example.com/", encode-for-uri("100% organic")) |
- http://www.example.com/ 100%25%20organic |
-
-
-
W3C Documentation reference
-
-
-
fn:iri-to-uri()
-
- This function converts an xs:string containing an IRI into a URI according to the rules
- spelled out in Section 3.1 of [RFC 3987]. It is idempotent but not invertible.
-
- If $iri contains a character that is invalid in an IRI, such as the space character (see
- note below), the invalid character is replaced by its percent-encoded form as described
- in [RFC 3986] before the conversion is performed.
-
- If $iri is the empty sequence, returns the zero-length string.
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $iri |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | iri-to-uri ("http://www.example.com/00/Weather/CA/Los%20Angeles#ocean") |
- "http://www.example.com/00/ Weather/CA/Los%20Angeles#ocean" |
-
-
- | iri-to-uri ("http://www.example.com/~bébé") |
- http://www.example.com/ ~b%C3%A9b%C3%A9 |
-
-
-
W3C Documentation reference
-
-
-
fn:escape-html-uri()
-
- This function escapes all characters except printable characters of the US-ASCII coded
- character set, specifically the octets ranging from 32 to 126 (decimal). The effect of
- the function is to escape a URI in the manner html user agents handle attribute values
- that expect URIs. Each character in $uri to be escaped is replaced by an escape
- sequence, which is formed by encoding the character as a sequence of octets in UTF-8,
- and then representing each of these octets in the form %HH, where HH is the hexadecimal
- representation of the octet. This function must always generate hexadecimal values using
- the upper-case letters A-F.
- If $uri is the empty sequence, returns the zero-length string.
-
-
Note:
- The behavior of this function corresponds to the recommended handling of non-ASCII
- characters in URI attribute values as described in [HTML 4.0] Appendix B.2.1.
-
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $uri |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | escape-html-uri("http://www.example.com/00/Weather/CA/Los Angeles#ocean")
- |
- http://www.example.com/00/Weather/CA/Los Angeles#ocean |
-
-
-
W3C Documentation reference
-
-
-
fn:contains()
-
- Returns an xs:boolean indicating whether or not the value of $arg1 contains (at the
- beginning, at the end, or anywhere within) at least one sequence of collation units that
- provides a minimal match to the collation units in the value of $arg2, according to the
- collation that is used.
-
- If the value of $arg1 or $arg2 is the empty sequence, or contains only ignorable
- collation units, it is interpreted as the zero-length string.
-
- If the value of $arg2 is the zero-length string, then the function returns true.
-
- If the value of $arg1 is the zero-length string, the function returns false.
-
- The collation used by the invocation of this function is determined according to the
- rules in 7.3.1 Collations. If the specified collation does not support collation units
- an error ·may· be raised [err:FOCH0004].
-
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg1 |
-
-
- | xs:string? |
- $arg2 |
-
-
- | xs:string? |
- $collation (Optional) |
-
-
-
Return type: xs:boolean
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | contains( "tattoo", "tat") |
- true |
-
-
- | contains( "tattoo", "ttt") |
- false |
-
-
- | contains ( "", ()) |
- true |
-
-
-
W3C Documentation reference
-
-
-
fn:starts-with()
-
- Returns an xs:boolean indicating whether or not the value of $arg1 starts with a
- sequence of collation units that provides a match to the collation units of $arg2
- according to the collation that is used.
-
- If the value of $arg1 or $arg2 is the empty sequence, or contains only ignorable
- collation units, it is interpreted as the zero-length string.
-
- If the value of $arg2 is the zero-length string, then the function returns true. If the
- value of $arg1 is the zero-length string and the value of $arg2 is not the zero-length
- string, then the function returns false.
-
- The collation used by the invocation of this function is determined according to the
- rules in 7.3.1 Collations. If the specified collation does not support collation units
- an error ·may· be raised [err:FOCH0004].
-
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg1 |
-
-
- | xs:string? |
- $arg2 |
-
-
- | xs:string? |
- $collation (Optional) |
-
-
-
Return type: xs:boolean
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | starts-with( "tattoo", "tat") |
- true |
-
-
- | starts-with( "tattoo", "ttt") |
- false |
-
-
- | starts-with ( "", ()) |
- true |
-
-
-
W3C Documentation reference
-
-
-
fn:ends-with()
-
- Returns an xs:boolean indicating whether or not the value of $arg1 starts with a
- sequence of collation units that provides a match to the collation units of $arg2
- according to the collation that is used.
-
- If the value of $arg1 or $arg2 is the empty sequence, or contains only ignorable
- collation units, it is interpreted as the zero-length string.
-
- If the value of $arg2 is the zero-length string, then the function returns true. If the
- value of $arg1 is the zero-length string and the value of $arg2 is not the zero-length
- string, then the function returns false.
-
- The collation used by the invocation of this function is determined according to the
- rules in 7.3.1 Collations. If the specified collation does not support collation units
- an error ·may· be raised [err:FOCH0004].
-
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg1 |
-
-
- | xs:string? |
- $arg2 |
-
-
- | xs:string? |
- $collation (Optional) |
-
-
-
Return type: xs:boolean
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | ends-with( "tattoo", "too") |
- true |
-
-
- | ends-with( "tattoo", "tatoo") |
- false |
-
-
- | ends-with ((), ()) |
- true |
-
-
-
W3C Documentation reference
-
-
-
fn:substring-before()
-
- Returns the substring of the value of $arg1 that precedes in the value of $arg1 the
- first occurrence of a sequence of collation units that provides a minimal match to the
- collation units of $arg2 according to the collation that is used.
-
- If the value of $arg1 or $arg2 is the empty sequence, or contains only ignorable
- collation units, it is interpreted as the zero-length string.
-
- If the value of $arg2 is the zero-length string, then the function returns the
- zero-length string.
-
- If the value of $arg1 does not contain a string that is equal to the value of $arg2,
- then the function returns the zero-length string.
-
- The collation used by the invocation of this function is determined according to the
- rules in 7.3.1 Collations If the specified collation does not support collation units an
- error ·may· be raised [err:FOCH0004].
-
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg1 |
-
-
- | xs:string? |
- $arg2 |
-
-
- | xs:string? |
- $collation (Optional) |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | substring-before( "tattoo", "too") |
- tat |
-
-
- | substring-before( "tattoo", "tat") |
- <empty string> |
-
-
-
W3C Documentation reference
-
-
-
fn:substring-after()
-
- Returns the substring of the value of $arg1 that follows in the value of $arg1 the first
- occurrence of a sequence of collation units that provides a minimal match to the
- collation units of $arg2 according to the collation that is used.
-
- If the value of $arg1 or $arg2 is the empty sequence, or contains only ignorable
- collation units, it is interpreted as the zero-length string.
-
- If the value of $arg2 is the zero-length string, then the function returns the value of
- $arg1.
-
- If the value of $arg1 does not contain a string that is equal to the value of $arg2,
- then the function returns the zero-length string.
-
- The collation used by the invocation of this function is determined according to the
- rules in 7.3.1 Collations If the specified collation does not support collation units an
- error ·may· be raised [err:FOCH0004].
-
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $arg1 |
-
-
- | xs:string? |
- $arg2 |
-
-
- | xs:string? |
- $collation (Optional) |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | substring-after( "tattoo", "too") |
- <empty string> |
-
-
- | substring-after( "tattoo", "tat") |
- too |
-
-
-
W3C Documentation reference
-
-
-
-
fn:matches()
-
- The function returns true if $input matches the regular expression supplied as $pattern
- as influenced by the value of $flags, if present; otherwise, it returns false.
-
- The effect of calling the first version of this function (omitting the argument $flags)
- is the same as the effect of calling the second version with the $flags argument set to
- a zero-length string. Flags are defined in 7.6.1.1 Flags.
-
- If $input is the empty sequence, it is interpreted as the zero-length string.
- Unless the metacharacters ^ and $ are used as anchors, the string is considered to match
- the pattern if any substring matches the pattern. But if anchors are used, the anchors
- must match the start/end of the string (in string mode), or the start/end of a line (in
- multiline mode).
-
- An error is raised [err:FORX0002] if the value of $pattern is invalid according to the
- rules described in section 7.6.1 Regular Expression Syntax.
-
- An error is raised [err:FORX0001] if the value of $flags is invalid according to the
- rules described in section 7.6.1 Regular Expression Syntax.
-
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $input |
-
-
- | xs:string |
- $pattern |
-
-
- | xs:string |
- $flags (Optional) |
-
-
-
Return type: xs:boolean
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | matches("abracadabra", "bra") |
- true |
-
-
- | matches("abracadabra", "^a.*a$") |
- false |
-
-
-
W3C Documentation reference
-
-
-
fn:replace()
-
- The function returns the xs:string that is obtained by replacing each non-overlapping
- substring of $input that matches the given $pattern with an occurrence of the
- $replacement string.
-
- The effect of calling the first version of this function (omitting the argument $flags)
- is the same as the effect of calling the second version with the $flags argument set to
- a zero-length string. Flags are defined in 7.6.1.1 Flags.
-
- The $flags argument is interpreted in the same manner as for the fn:matches()
- function.
-
- If $input is the empty sequence, it is interpreted as the zero-length string.
-
- If two overlapping substrings of $input both match the $pattern, then only the
first
- one (that is, the one whose first character comes first in the $input string) is
- replaced.
-
- Within the $replacement string, a variable $N may be used to refer to the substring
- captured by the Nth parenthesized sub-expression in the regular expression. For each
- match of the pattern, these variables are assigned the value of the content matched by
- the relevant sub-expression, and the modified replacement string is then substituted for
- the characters in $input that matched the pattern. $0 refers to the substring captured
- by the regular expression as a whole.
-
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $input |
-
-
- | xs:string |
- $pattern |
-
-
- | xs:string |
- $replacement |
-
-
- | xs:string |
- $flags (Optional) |
-
-
-
Return type: xs:string
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | replace("abracadabra", "bra", "*") |
- a*cada* |
-
-
- | replace("abracadabra", "a.*a", "*") |
- * |
-
-
- | replace("AAAA", "A+", "b") |
- b |
-
-
-
W3C Documentation reference
-
-
-
fn:tokenize()
-
- This function breaks the $input string into a sequence of strings, treating any
- substring that matches $pattern as a separator. The separators themselves are not
- returned.
-
- The effect of calling the first version of this function (omitting the argument $flags)
- is the same as the effect of calling the second version with the $flags argument set to
- a zero-length string. Flags are defined in 7.6.1.1 Flags.
-
- The $flags argument is interpreted in the same way as for the fn:matches() function.
-
- If $input is the empty sequence, or if $input is the zero-length string, the result is
- the empty sequence.
-
- If the supplied $pattern matches a zero-length string, that is, if fn:matches("",
- $pattern, $flags) returns true, then an error is raised: [err:FORX0003].
-
- If a separator occurs at the start of the $input string, the result sequence will start
- with a zero-length string. Zero-length strings will also occur in the result sequence if
- a separator occurs at the end of the $input string, or if two adjacent substrings match
- the supplied $pattern.
-
-
-
Arguments and return type:
-
-
- | Type |
- Description |
-
-
- | xs:string? |
- $input |
-
-
- | xs:string |
- $pattern |
-
-
- | xs:string |
- $flags (Optional) |
-
-
-
Return type: xs:string*
-
Examples:
-
-
- | Expression |
- Result |
-
-
- | tokenize("The cat sat on the mat", "\s+") |
- ("The", "cat", "sat", "on", "the", "mat") |
-
-
- | tokenize("1, 15, 24, 50", ",\s*") |
- ("1", "15", "24", "50") |
-
-
- | tokenize("1,15,,24,50,", ",") |
- ("1", "15", "", "24", "50", "") |
-
-
-
W3C Documentation reference
-
-
-