fn:starts-with function

The fn:starts-with function determines whether a string begins with a given substring. The substring is matched using the default collation.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-fn:starts-with(string,substring)----------------------------><

string
The string in which to search for substring.

string has the xs:string data type, or is the empty sequence. If string is the empty sequence, string is set to a string of length 0.

substring
The substring to search for.

substring has the xs:string data type, or is the empty sequence.

Returned value

The returned value is the xs:boolean value true if either of the following conditions are satisfied:
  • substring occurs at the beginning of string.
  • substring is an empty sequence or a string of length zero.
Otherwise, the returned value is false.

Example

The following function determines whether the string 'Test literal' begins with the string 'lite'.
fn:starts-with('Test literal','lite')

The returned value is false.