XPath Functions

XPath defines the grammer of location paths and a set of functions:

number last()

Returns the ordinal value of the last element in the current context

number position()

Returns the ordinal value of the current element in the current context

number count(node-set)

Returns the number of nodes in the specified node set

node-set id(object)

Returns the set of elements with the specified ID value

string local-name(node-set)

Returns the local name (the name without any namespace qualifiers) of the specified node (or the first node in document order)

string namespace-uri(node-set)

Returns the namespace URI of the specified node (or the first node in document order)

string name(node-set)

Returns the fully qualified name of the specified node (or the first node in document order)

string string(object)

Returns the string representation of the object

string concat(string1, string2, [string3, [string4], ...])

Returns the concatenation of its arguments

boolean starts-with(string1, string2)

Returns true if string1 starts with the characters in string2

boolean contains(string1, string2)

Returns true if string1 contains string2

string substring-before(string1, string2)

Returns the substring of string1 that occurs before the first occurance of string2, or the empty string if not(contains(string1, string2))

string substring-after(string, string)

Returns the substring of string1 that occurs after the first occurance of string2, or the empty string if not(contains(string1, string2))

string substring(string, startpos, [length])

Returns the substring of string starting at position startpos of length length, or the rest of the string if length is not specified

number string-length(string?)

Returns the length of the specified string

string normalize-space(string?)

Returns the specified string with leading and trailing whitespace removed and internal sequences of multiple whitespace characters replaced by a single space

string translate(string1, string2, string3)

Returns string1 with the characters in string2 replaced by the characaters in string3

boolean boolean(object)

Returns the boolean representation of the object

boolean not(boolean)

Returns the negation of boolean

boolean true()

Returns true

boolean false()

Returns false (i.e., not(true())

boolean lang(string)

Returns true if the language of the current context node (as specified by xml:lang) matches the specified language string

number number(object?)

Returns the numeric representation of the object

number sum(node-set)

Returns the sum of the numeric representations of the nodes in the node-set

number floor(number)

Returns the largest integer not greater than number

number ceiling(number)

Returns the smallest integer not less than number

number round(number)

Returns the integer value closest to number