XPath - Functions (all)

XPath is a language for finding information in an XML document.
XPath includes many built-in functions. There are functions for string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values, and more.
- XPath is a syntax for defining parts of an XML document
- XPath uses path expressions to navigate in XML documents
- XPath contains a library of standard functions
- XPath is a major element in XSLT
- XPath is a W3C recommendation
Before Xpath examples, there must be a part of theory and probably a table with path locations axes and functions (number, string, boolean) as a resume after theory!
Note: This document describes Xpath version 1.0 that is implemented in Sterling Integrator.
All the Xpath functions:
Axes
|
Node Set Functions
|
String functions
|
Boolean functions
|
Number functions
|
Child axis contains the children of the context node
|
last()
returns a number equal to the context size from the expression evaluation context
|
string string(object?)
converts an object to a string
|
boolean boolean(object)
converts its argument to a boolean
|
number number(object?)
converts its argument to a number
|
descendant axis contains the descendants of the context node; a descendant is a child or a child of a child and so on
|
position()
function returns a number equal to the context position from the expression evaluation context
|
string concat(string, string, string*)
returns the concatenation of its arguments
|
boolean not(boolean)
returns true if its argument is false, and false otherwise
|
number sum(node-set)
returns the sum, for each node in the argument node-set
|
parent axis contains the parent of the context node
|
count(node-set)
returns the number of nodes in the argument node-set
|
boolean starts-with(string, string)
returns true if the first argument string starts with the second argument string, and otherwise returns false
|
boolean true()
returns true
|
number floor(number)
returns the largest (closest to positive infinity) number that is not greater than the argument and that is an integer
|
ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on
|
node-set id(object)
selects elements by their unique ID
|
boolean contains(string, string)
returns true if the first argument string contains the second argument string, and otherwise returns false
|
boolean false()
returns false
|
returns the smallest (closest to negative infinity) number that is not less than the argument and that is an integer
|
following-sibling axis contains all the following siblings of the context node
|
returns the local part of the expanded-name of the node in the argument node-set that is first in document order
|
string substring-before(string, string)
returns the substring of the first argument string that precedes the first occurrence of the second argument string in the first argument string
|
boolean lang(string)
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 sublanguage of the language specified by the argument string |
number round(number)
returns the number that is closest to the argument and that is an integer
|
preceding-sibling axis contains all the preceding siblings of the context node
|
string namespace-uri(node-set?)
returns the namespace URI of the expanded-name of the node in the argument node-set that is first indocument order
|
string substring-after(string, string)
returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string
|
|
|
following axis contains all nodes in the same document as the context node that are after the context node in document order, excluding any descendants and excluding attribute nodes and namespace nodes
|
string name(node-set?)
returns a string containing a QName representing the expanded-name of the node in the argument node-set that is first in document order
|
string substring(string, number, number?)
returns the substring of thefirst argument starting at the position specified in the second argument with length specified in the third argument
|
|
|
preceding axis contains all nodes in the same document as the context node that are before the context node in document order, excluding any ancestors and excluding attribute nodes and namespace nodes
|
|
number string-length(string?)
returns the number of characters in the string
|
|
|
attribute axis contains the attributes of the context node; the axis will be empty unless the context node is an element
|
|
string normalize-space(string?)
returns the argument string with whitespace normalized by stripping leading and trailing whitespace and replacing sequences of whitespace characters by a single space
|
|
|
namespace axis contains the namespace nodes of the context node; the axis will be empty unless the context node is an element
|
|
string translate(string, string, string)
returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding position in the third argument string
|
|
|
self axis contains just the context node itself
|
|
|
|
|
descendant-or-self axis contains the context node and the descendants of the context node
|
|
|
|
|
ancestor-or-self axis contains the context node and the ancestors of the context node; thus, the ancestor axis will always include the root node
|
|
|
|
|