String Functions
concat
concat($arg1 as xs:anyAtomicType, $arg2 as xs:anyAtomicType, ...) as xs:string
Returns the concatenation of the string values of the arguments. Accepts two or more arguments.
concat('Hello', ' ', 'World') → "Hello World"contains
contains($arg1 as xs:string, $arg2 as xs:string) as xs:boolean
Returns true if $arg1 contains $arg2 as a substring.
contains('abcde', 'cd') → trueends-with
ends-with($arg1 as xs:string, $arg2 as xs:string) as xs:boolean
Returns true if $arg1 ends with $arg2.
ends-with('hello.xml', '.xml') → trueencode-for-uri
encode-for-uri($uri as xs:string) as xs:string
Encodes a string for use in a URI by escaping reserved characters.
escape-html-uri
escape-html-uri($uri as xs:string) as xs:string
Escapes a URI for use in HTML attributes.
iri-to-uri
iri-to-uri($iri as xs:string) as xs:string
Converts an IRI to a URI by escaping non-ASCII characters.
lower-case
lower-case($arg as xs:string) as xs:string
Converts a string to lower case.
lower-case('ABC') → "abc"matches
matches($input as xs:string, $pattern as xs:string) as xs:boolean
matches($input as xs:string, $pattern as xs:string, $flags as xs:string) as xs:boolean
Returns true if $input matches the regular expression $pattern. Optional $flags control matching behavior (e.g. "i" for case-insensitive).
matches('Hello', '^H') → truenormalize-space
normalize-space() as xs:string
normalize-space($arg as xs:string) as xs:string
Strips leading/trailing whitespace and collapses internal whitespace to single spaces.
normalize-space(' hello world ') → "hello world"normalize-unicode
normalize-unicode($arg as xs:string) as xs:string
normalize-unicode($arg as xs:string, $form as xs:string) as xs:string
Returns the Unicode-normalized form of a string. Default form is NFC.
replace
replace($input as xs:string, $pattern as xs:string, $replacement as xs:string) as xs:string
replace($input as xs:string, $pattern as xs:string, $replacement as xs:string, $flags as xs:string) as xs:string
Replaces all occurrences of $pattern in $input with $replacement.
replace('abcde', 'cd', 'XX') → "abXXe"starts-with
starts-with($arg1 as xs:string, $arg2 as xs:string) as xs:boolean
Returns true if $arg1 starts with $arg2.
starts-with('hello', 'he') → truestring
string($arg as item()?) as xs:string
Returns the string value of the argument.
string-join
string-join($arg1 as xs:anyAtomicType*) as xs:string
string-join($arg1 as xs:anyAtomicType*, $arg2 as xs:string) as xs:string
Joins a sequence of strings with an optional separator.
string-join(('a', 'b', 'c'), '-') → "a-b-c"string-length
string-length() as xs:integer
string-length($arg as xs:string) as xs:integer
Returns the number of characters in a string.
string-to-codepoints
string-to-codepoints($arg as xs:string) as xs:integer*
Returns the Unicode code points of a string.
codepoints-to-string
codepoints-to-string($arg as xs:integer*) as xs:string
Converts a sequence of Unicode code points to a string.
codepoint-equal
codepoint-equal($arg1 as xs:string, $arg2 as xs:string) as xs:boolean
Compares two strings by their Unicode code points.
substring
substring($sourceString as xs:string, $start as xs:double) as xs:string
substring($sourceString as xs:string, $start as xs:double, $length as xs:double) as xs:string
Returns a substring starting at position $start (1-based), optionally limited to $length characters.
substring('hello', 2, 3) → "ell"substring-before
substring-before($arg1 as xs:string, $arg2 as xs:string) as xs:string
Returns the part of $arg1 before the first occurrence of $arg2.
substring-before('hello-world', '-') → "hello"substring-after
substring-after($arg1 as xs:string, $arg2 as xs:string) as xs:string
Returns the part of $arg1 after the first occurrence of $arg2.
substring-after('hello-world', '-') → "world"tokenize
tokenize($input as xs:string, $pattern as xs:string) as xs:string*
tokenize($input as xs:string, $pattern as xs:string, $flags as xs:string) as xs:string*
Splits $input around occurrences of $pattern.
tokenize('a, b, c', ',\s*') → ("a", "b", "c")translate
translate($arg as xs:string, $mapString as xs:string, $transString as xs:string) as xs:string
Replaces individual characters in $arg according to a character map.
translate('abc', 'abc', 'ABC') → "ABC"upper-case
upper-case($arg as xs:string) as xs:string
Converts a string to upper case.
upper-case('abc') → "ABC"compare
compare($arg1 as xs:string, $arg2 as xs:string) as xs:integer
Returns -1, 0, or 1 depending on whether $arg1 is less than, equal to, or greater than $arg2.