XSLT » XPath Core Functions » XPath Core Functions

The XPath Core Functions are also referred to as the Inherited XPath Functions. These twenty seven (27) functions are defined in the W3C XML Path Language (XPath) Recommendation Version 1.0 which was released on 16 November 1999. All of these functions are very utilitarian in nature.

Note that there are an additional nine (9) XSLT functions which are defined in the W3C XSL Transformations (XSLT) Recommendation Version 1.0 which was also released on 16 November 1999. See the Function Index for access to the individual XSLT functions.
 
Note that these function names are used as is, without a prefix. (Some companies offer proprietary XPath functions that usually require a prefixed name.)

boolean

Syntax: true | false = boolean(value)

The Boolean function converts the value argument to a Boolean and returns a true or false.

ceiling

Syntax: number = ceiling(number)

The ceiling function returns the smallest integer that is equal to or is larger than the numeric value of the number argument.

concat

Syntax: string = concat(value1, value2, ...)

The concat function takes all of the individual arguments, concatenates them together in order, and returns the resultant string.

contains

Syntax: true | false = contains(value, substring)

The contains function determines if the substring argument is contained within the value argument and, if yes, returns a true. If no, a false is returned.

count

Syntax: number = count(node-set)

The count function counts and returns the number of nodes in a node-set.

current

Syntax: node-set current ()

The current function returns a node-set that has the current node as its only member.

floor

Syntax: number = floor(number)

The floor function returns the largest integer that is equal to or is smaller than the numeric value of the number argument.

function-available

Syntax: string generate-id (node-set?)

The function-available function returns true if and only if the expanded-name is the name of a function in the function library.

generate-id

Syntax: boolean function-available (string)

The The generate-id function returns a string that uniquely identifies the node in the argument node-set that is first in document order.

id

Syntax: node-set = id(value)

The id function returns a node-set containing zero or more nodes that have an attribute that match the value argument.

key

Syntax: node-set key (string, object)

The key function does for keys what the id function does for IDs. The first argument specifies the name of the key.

lang

Syntax: true | false = lang(language)

The lang function tests whether the language specified by the language argument matches the language of the context node (which is normally assigned by the xsl:lang element). If yes, true is returned. If no, or if no language is assigned to the context node, false is returned.

last

Syntax: number = last()

The last function returns the position number assigned to the last node in the current node list that is being processed by an xsl:for-each or xsl:apply-templates element. There are no arguments.

local-name

Syntax: string = local-name(node)

The local-name function returns the local part of a qname (or an empty string if there is no local name). A qname is composed of an optional prefix, a colon that must be present if there is a prefix, followed by the local name. The local name is dependent on node type. The node argument is optional. If omitted, the default is to use the context node.

name

Syntax: string = name(node)

The name function returns the qname of the node. A qname is composed of an optional prefix, a colon that must be present if there is a prefix, followed by the local name. The node argument is optional. If omitted, the default is to use the context node.

namespace-uri

Syntax: uri = namespace-uri(node)

The namespace-uri function returns a string that is the namespace URI of the node cited in the optional node argument. If the argument is omitted, the default is to find the namespace URI of the context node.

normalize-space

Syntax: string = normalize-space(string)

The normalize-space function returns a string in which all of the preceding and trailing white space has been removed, and in which all internal sequences of white is replaced with one white space. The string argument is optional. If omitted, the default is to use the string value of the context node.

not

Syntax: true | false = not(condition)

The not function returns the Boolean negation of the condition argument (true becomes false and vice-versa).

number

Syntax: number = number(value)

The number function converts the value argument to a number. The value argument is optional. If omitted, the default is to use the string value of the context node.

position

Syntax: number = position()

The position function returns the position number in the current node list of the node that is currently being processed by an xsl:for-each or xsl:apply-templates element. There are no arguments.

processing-instruction

Syntax: boolean processing-instruction (string?)

The node test processing-instruction() is true for any processing instruction.

round

Syntax: integer = round(number)

The round function rounds a number to its closest integer.

starts-with

Syntax: true | false = starts-with(string, substring)

The starts-with function tests whether the string specified in the string argument starts with the substring specified in the substring argument. If yes, true is returned. If no, a false is returned.

string

Syntax: = string()

The string function converts the value argument to a string. The value argument is optional. If omitted, the default is to use the string value of the context node.

string-length

Syntax: number = string-length(string)

The string-length function returns the number of characters in a string. The string argument is optional. If omitted, the default is to use the string value of the context node.

substring

Syntax: string = substring(string, start, length)

The substring function returns a portion out of the string specified in the string argument as determined by the starting point specified in the start argument and also by the optional length specified in the length argument.

substring-after

Syntax: string = substring-after(string, substring)

The substring-after function returns a portion out of the string specified in the string argument that occurs after the substring specified in the substring argument.

substring-before

Syntax: string = substring-before(string, substring)

The substring-before function returns a portion out of the string specified in the string argument that occurs before the substring specified in the substring argument.

sum

Syntax: number = sum(node-set)

The sum function adds and returns the total value of a set of numeric values that are contained in a node-set.

system-property

Syntax: object system-property (string)

The system-property function returns an object representing the value of the system property identified by the name.

text

Syntax: boolean text ()

The node test text() is true for any text node. For example, child::text() will select the text node children of the context node.

translate

Syntax: string = translate(value, string1, string2)

The translate function takes the string in the value argument, replaces all occurrences of a string specified in the string1 argument with substitute characters specified in string2 argument and returns the modified string.

true

Syntax: = true()

The true function returns the Boolean value of true. There are no arguments.

unparsed-entity-uri

Syntax: string unparsed-entity-uri (string)

The unparsed-entity-uri returns the URI of the unparsed entity with the specified name in the same document as the context node. It returns the empty string if there is no such entity.