XML information pipe

Ihre Spezialisten für XML

Banner Werbung

XPath 2.0 reference

The reference is based on W3C recommendations XML Path Language (XPath) 2.0 and XQuery 1.0 and XPath 2.0 Functions and Operators. Both texts and examples has been extracted from these recommendations.

Standard excerpt:
XPath 2.0 is an expression language that allows the processing of values conforming to the data model defined in XQuery/XPath Data Model (XDM). The data model provides a tree representation of XML documents as well as atomic values such as integers, strings, and booleans, and sequences that may contain both references to nodes in an XML document and atomic values. The result of an XPath expression may be a selection of nodes from the input documents, or an atomic value, or more generally, any sequence allowed by the data model. The name of the language derives from its most distinctive feature, the path expression, which provides a means of hierarchic addressing of the nodes in an XML tree. XPath 2.0 is a superset of XPath 1.0, with the added capability to support a richer set of data types, and to take advantage of the type information that becomes available when documents are validated using XML Schema.

The usage of the W3C standards is covered by W3C DOCUMENT LICENSE.

XPaths  |  functions

abs | adjust-date-to-timezone | adjust-dateTime-to-timezone | attribute | avg | base-uri | boolean | ceiling | codepoint-equal | codepoints-to-string | collection | comment& | compare | concat | contains | count | current-date | current-dateTime | current-time | data | day-from-date | day-from-dateTime | days-from-duration | deep-equal | default-collation | distinct-values | doc | doc-available& | document-node | document-uri | element | empty | empty-sequence | encode-for-uri | ends-with | error | escape-html-uri | exactly-one | exists | false | floor | hours-from-dateTime | etc etc etc.


XPaths  |  expressions

!= | > | >> | >= | < | << | <= | (::) | * | + |  |  |  | ⋅⋅ | ⁄⁄ | = | @ | [] | and | cast as | castable as | etc etc etc.


XPaths  |  axes

ancestor | ancestor-or-self | attribute | child | descendant | descendant-or-self | following | following-sibling | namespace | parent | preceding | preceding-sibling | self |


XPaths  |  functions


abs

abs($arg)
     $arg: numeric
     returns: numeric


Returns the absolute value of $arg. If $arg is negative returns -$arg otherwise returns $arg. If type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.


Example 1:
Input: abs(10.5)
Output: 10.5

Example 2:
Input: abs(-10.5)
Output: 10.5
Locate in the official documentation

XPaths  |  functions

adjust-date-to-timezone

adjust-date-to-timezone($timezone)
     $timezone: xs:date
     returns: xs:date


Adjusts an xs:date value to a specific timezone, or to no timezone at all. If $timezone is the empty sequence, returns an xs:date without a timezone. Otherwise, returns an xs:date with a timezone. For purposes of timezone adjustment, an xs:date is treated as an xs:dateTime with time 00:00:00.


Example 1:
Input: adjust-date-to-timezone(xs:date("2002-03-07"))
Output: 2002-03-07-05:00

Example 2:
Input: adjust-date-to-timezone(xs:date("2002-03-07-07:00"))
Output: 2002-03-07-05:00
etc. etc. etc.
Locate in the official documentation

XPaths  |  functions


etc. etc. etc.



XPaths  |  expressions


!=

!=

Not Equal. General comparisons are existentially quantified comparisons that may be applied to operand sequences of any length. When evaluating a general comparison in which either operand is a sequence of items, an implementation may return true as soon as it finds an item in the first operand and an item in the second operand that satisifies the condition. != is not inverse of =.

Example 1:
Input: (1, 2) != (2, 3)
Output: true

Example 2:
Input: (2, 3) != (3, 4)
Output: true

Example 2:
Input: (1, 2) != (3, 4)
Output: true
Locate in the official documentation

XPaths  |  functions

>

>

Greater then. General comparisons are existentially quantified comparisons that may be applied to operand sequences of any length. When evaluating a general comparison in which either operand is a sequence of items, an implementation may return true as soon as it finds an item in the first operand and an item in the second operand that satisifies the condition.

Locate in the official documentation

XPaths  |  expressions


etc. etc. etc.



XPaths  |  axes


ancestor

ancestor

It contains the ancestors of the context node (the parent, the parent of the parent, and so on). The ancestor axis includes the root node of the tree in which the context node is found, unless the context node is the root node. This is a reverse axis. When using predicates with a sequence of nodes selected using a reverse axis, it is important to remember that the context positions for such a sequence are assigned in reverse document order.

Locate in the official documentation

XPaths  |  axes

ancestor-or-self

ancestor-or-self

The context node and the ancestors of the context node; thus, the ancestor-or-self axis will always include the root node This is a reverse axis. When using predicates with a sequence of nodes selected using a reverse axis, it is important to remember that the context positions for such a sequence are assigned in reverse document order.

Locate in the official documentation

XPaths  |  axes

attribute

attribute

The attributes of the context node; the axis will be empty unless the context node is an element

Locate in the official documentation

XPaths  |  axes


etc. etc. etc.