XPath Expressions
XPath Expressions are statements that can extract useful information from the XPath tree. Instead of just finding nodes, one can count them, add up numeric values, compare strings, and more. They are much like statements in a functional programming language. Every XPath expression evaluates to a single value.
There are four types of expressions in XPath. They are:
- Node-set: A node-set is an unordered group of nodes from the input document that match an expression’s criteria.
- Boolean: A Boolean has one of two values: true of false. XSLT allows any kind of data to be transformed into a Boolean. This is often done implicity when a string or a number or a node-set used where a Boolean is expected.
- Number: XPath numbers are numeric values useful for counting nodes and performing simple arithmetic. The numbers such as 43 or -7000 that look like integers are stored as doubles. Non-number values, such as strings and Booleans, are converted to numbers automatically as necessary.
- String: A string is a sequence of zero or more Unicode characters. Other data types can be converted to strings using the string() function.
XPath Funcitons
XPath defines various functions required for XPath 2.0, XQuery 1.0 and XSLT 2.0. The different functions and Accessor, AnyURI, Node, Error and Trace, Sequence, Context, Boolean, Duration/Date/Time, String, QName and Numeric.
XML Path Language (XPath) functions can be used to refine XPath queries and enhance the programming power and flexibility of XPath. Each function in the function library is specified using a function prototype that provides the return type, function name, and argument type. If an argument type is followed by a question mark, the argument is optional; otherwise, the argument is required. Function names are case-sensitive.
The default prefix for the function namespace is fn.