XPath
Paradigm(s) Query language
Appeared in 1999
Developer W3C
Stable release 2.0 (2007-01-23)
Major implementations C#, Java, JavaScript
Influenced by XSLT, XPointer
Influenced XML Schema, XForms

XPath, the XML Path Language, is a query language for selecting nodes from an XML document. In addition, XPath may be used to compute values (e.g., strings, numbers, or Boolean values) from the content of an XML document. XPath was defined by the World Wide Web Consortium (W3C) [1].

Contents

History [link]

The XPath language is based on a tree representation of the XML document, and provides the ability to navigate around the tree, selecting nodes by a variety of criteria.[2] In popular use (though not in the official specification), an XPath expression is often referred to simply as an XPath.

Originally motivated by a desire to provide a common syntax and behavior model between XPointer and XSLT, subsets of the XPath query language are used in other W3C specifications such as XML Schema, XForms and the Internationalization Tag Set (ITS).

XPath has been adopted by a number of XML processing libraries and tools, many of which also offer CSS Selectors, another W3C standard, as a simpler alternative to XPath.

Versions [link]

Two versions of XPath are currently in use.

  • XPath 2.0 is the current version of the language; it became a Recommendation on 23 January 2007. A number of implementations exist but are not as widely used as XPath 1.0. The XPath 2.0 language specification is much larger than XPath 1.0 and changes some of the fundamental concepts of the language such as the type system.

The most notable change is that XPath 2.0 has a much richer type system.[3] Every value is now a sequence (a single atomic value or node is regarded as a sequence of length one). XPath 1.0 node-sets are replaced by node sequences, which may be in any order.

To support richer type sets, XPath 2.0 offers a greatly expanded set of functions and operators.

XPath 2.0 is in fact a subset of XQuery 1.0. They share the same query data model (XDM). It offers a for expression which is a cut-down version of the "FLWOR" expressions in XQuery. It is possible to describe the language by listing the parts of XQuery that it leaves out: the main examples are the query prolog, element and attribute constructors, the remainder of the "FLWOR" syntax, and the typeswitch expression.

References [link]

External links [link]


https://wn.com/XPath

XPath 2.0

XPath 2.0 is a version of the XPath language defined by the World Wide Web Consortium, W3C. It became a recommendation on 23 January 2007. As a W3C Recommendation it was superseded by XPath 3.0 on 10 April 2014.

XPath is used primarily for selecting parts of an XML document. For this purpose the XML document is modelled as a tree of nodes. XPath allows nodes to be selected by means of a hierarchic navigation path through the document tree.

The language is significantly larger than its predecessor, XPath 1.0, and some of the basic concepts such as the data model and type system have changed. The two language versions are therefore described in separate articles.

XPath 2.0 is used as a sublanguage of XSLT 2.0, and it is also a subset of XQuery 1.0. All three languages share the same data model (the XDM), type system, and function library, and were developed together and published on the same day.

Data model

Every value in XPath 2.0 is a sequence of items. The items may be nodes or atomic values. An individual node or atomic value is considered to be a sequence of length one. Sequences may not be nested.

XPath 3

XPath 3 is the latest version of the XML Path Language, a query language for selecting nodes in XML documents. It supersedes XPath 1.0 and XPath 2.0.

XPath 3.0 became a W3C Recommendation on 8 April 2014, while XPath 3.1 became a W3C Candidate Recommendation on 18 December 2014.

New features in XPath 3.0

Compared to XPath 2.0, XPath 3.0 adds the following new features:

New features in XPath 3.1

XPath 3.1 mainly adds support for array and map (associative array) data types. These types and their associated functionality are intended to ease working with JSON data.

Another innovation is the arrow operator => for function chaining. For example the XPath 2.0 expression

can now be written

References

  • "XML Path Language (XPath) 3.0". World Wide Web Consortium. 8 April 2014. 
  • "XML Path Language (XPath) 3.1". World Wide Web Consortium. 18 December 2014. 
  • Podcasts:

    PLAYLIST TIME:
    ×