XPath supplies these functions:
boolean(e)Converts object e to
Boolean type. False values include numeric zero,
empty strings, and empty node sets; other values
are considered true.
ceiling(e)Returns the integer closest to infinity
that is less than or equal to e.
Examples:
ceiling(5.9) returns
6;
ceiling(-5.9) returns
-5.
concat(e1,
e2, ...)Concatenates the string values of its arguments and returns the result as a single string.
contains(s1,
s2)True if string s1
contains s2.
count(e)For a node-set e,
returns the number of nodes in that set.
false()Returns the Boolean “false” value.
floor(e)Returns the integer closest to minus infinity
that is greater than or equal to
e. Examples:
floor(5.9) returns
5;
floor(-5.9) returns
-6.
id(e)For a string e,
this function returns a node-set containing the
element whose id
attribute matches e, if
there is one.
lang(s)This function tests whether a language code
s is a substring of the
context node's language attribute
(from the xml:lang attribute).
For example, lang("en")
would return a true value if the context node has
an attribute xml:lang="en-us".
last()Returns the context size; see the section above on context size.
local-name(n)For a node set , this function returns
the local name of the first element, that is, the
element name without any namespace. If the argument
is omitted, returns the local name of the
context node.n
For example, if the context node is an
xsl:message
element, local-name()
will return the string "message".
normalize-space(s)Returns the string s,
except that all leading and trailing whitespace are
removed, and all internal clumps of whitespace are
replaced by single spaces.
If the argument is omitted, it operates on the string value of the current node.
not(e)Returns the Boolean complement of the truth value
of expression e: true if
e is false, false if it
is true.
number(e)Converts an expression e
to a number. If e is not
a valid number, you get the special numeric value
NaN (not a
number). If e is a Boolean
value, you get 1 for true and 0 for false.
position()Returns the context position; see context position, above.
round(e)Returns the integer closest to the value of
expression e.
Values with a fractional part of 0.5 are rounded
towards infinity.
Examples:
round(5.1) returns
5;
round(5.5) returns
6; and
round(-5.5) returns
-5.
starts-with(s1,
s2)True if string s1
starts with string s2.
string(e)Converts e to a string.
string-length(s)Returns the length of string
s.
substring(s,
n1, n2)Returns a substring of s
starting at position n1
(counting from 1), and ending n2
characters later, or at the end of the string, whichever
comes first. You can omit the third argument, and it
will return the substring starting at position
n1 and going through the
end of s. For example,
"substring('abcdefgh', 3, 4)"
returns "cdef".
substring-after(s1,
s2)If s2 is a substring
of s1, returns the part
of s1 after the first
occurrence of s2; otherwise
it returns the empty string.
substring-before(s1,
s2)If s2 is a substring
of s1, returns the part
of s1 before the first
occurrence of s2; otherwise
it returns the empty string.
sum(n)For a node-set n,
this function converts each node to a number,
then returns the sum of those numbers.
translate(s1,
s2,
s3)The result is a copy of string
s1 with each
occurrence of a character from string
s2 replaced with the
corresponding character from string
s3.
If s3 is shorter than
s2, this function will delete
from its result any characters
from s2 that don't
correspond to characters in
s3.
true()Returns the Boolean “true” value.