Some functions need information to work. This information is passed in the form of parameters, which are inserted between round ( ) brackets.
To access the Functions Reference options, click the Reference tab in the XPath expression wizard.
You can use the following functions for working with node sets.
Function | Returns |
---|---|
count( ) | The number of nodes in a node set. |
last( ) | The size (that is, the number of nodes in) the context node list. |
position | A node's position in a node-set, in document order. For example, position( ) = 2 returns the second element in a node set. |
id(string) | A node set containing all elements in the document with the specified string. |
local-name(node set ) | The name of the first node in node set. Without an argument, it returns the local name of the context node. |
namespace uri( ) | The namespace URI of the context node. |
name( ) | The name of the context node, including the namespace prefix. |
You can use these functions for Boolean mathematics.
Function | Returns |
---|---|
boolean ( ) | Evaluates an expression to be true or false. |
false ( ) | Always returns false |
true ( ) | Always returns true |
lang ( ) | Returns true or false depending on whether the language of the context node as specified by xml:lang attributes is the same as, or is a sub-language of the language specified by the argument string. |
not ( ) | Negates the value of the Boolean expression: true if the expression is false, otherwise false. |
You can use the following functions to work with strings.
Functions | Returns |
---|---|
concat( ) | The concatenation of its arguments. For example, concat ('This is', ' ', 'my string') returns "This is my string" |
contains( ) | An indication if one string contains the contents of a second strong. For example, contains ("This is my string", "is my") returns true, because the string "This is my string" does contain the string "is my". |
normalize-space( ) | The argument string with whitespace normalized by stripping leading and trailing whitespace and replacing sequences of whitespace characters by a single space. |
starts-with( ) | An indication whether a string starts with the contents of a second string. For example, starts-with ("This is my string", "This") returns true , because the string "This is my string" does start with the string "This" . |
string( ) | Converts any value to a string. |
string-length( ) | The number of characters in the string, including spaces. |
substring( ) | Takes a specified number of characters out of a string. For example, substring ('This is my string' ,9, 2 ) returns my because we told it to start at the ninth character and take two characters. |
substring-after( ) | All the characters after a certain character. For example, substring-after ('This is my string','s' ) returns all the characters after the first occurrence of the letter "s", in other words "is my string". |
substring-before( ) | All the characters before a certain character. For example, substring-before ('This is my string','s' ) returns all the characters before the first occurrence of the letter "s", in other words "Thi". |
translate (string, to-match, replace-with ) | The string with all occurrences of the substring to-match replaced with the string replace-with . |
You can use these functions for dealing with numbers.
Function | Returns |
---|---|
ceiling ( ) | The value of the expression rounded up to an integer value. |
floor ( ) | The value of the expression rounded down to an integer value. |
round ( ) | The value of the expression rounded to the nearest integer. |
number ( ) | Converts PCDATA text to a numeric value. |
sum ( ) | Adds together all of the numeric values in a node set. |
XSLT uses the XPath syntax heavily and supports all functions defined in XPath. In addition, it defines ten extra functions.
Function | Returns |
---|---|
current( ) | A node set containing a single node, the current node. |
document( ) | Allows access to XML documents other than the main source document. |
element-available( ) | true if the argument identifies an XSLT element the processor recognizes, false otherwise. |
format-number (number x, string pattern ) | Converts the number x to a string using the string pattern specified by the second argument. |
function-available( ) | true if the argument identifies a function in the processor's function library, false otherwise. |
generate-id( ) | A string that can be used as the value of an ID type attribute. |
key (string keyName, object value ) | A node set containing all nodes in the source document that have a key with the name given by the first argument and the value given by the second argument. |
unparsed-entity-uri( ) | The URI of the unparsed entity with the specified name declared in the source document's DTD. |
system-property( ) | The value of the named property. |
Any user defined functions that you can use in your XPath expression will be listed here.