fbpx
Wikipedia

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 Recommendation on 21 March 2017.

New features in XPath 3.0 edit

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

Inline function expressions
Anonymous functions can be created in an expression context. For example, the expression function($a as xs:double, $b as xs:double) as xs:double { $a * $b } creates a function that returns the product of its two arguments. The expression collection()/(let $a := . return function() { $a }) creates a sequence of functions, each one returning a different node from a collection.
Dynamic function calls
Function values may be called without being referenced by name. For example, $f[2]("Hi there") fetches the second item from sequence $f, and invokes it as a function, passing the string "Hi there" as argument.
Union types
Union types, as defined in XML Schema, may be used in type conversions and function type signatures.
Namespace literals
XML namespaces may be referenced using braced URI literals. For example, the qualified name math:pi may be expanded to Q{http://www.w3.org/2005/xpath-functions/math}pi, embedding the namespace URI inside the prefix.
String concatenation operator
The new || operator may be used for string concatenation: $a || $b is equivalent to fn:concat($a, $b).
Mapping operator
The new ! operator performs simple mapping: E1 ! E2 evaluates E2 for each item in the sequence E1, and concatenates the resulting items. This is comparable to the path operator /, but the ! operator does not perform duplicate elimination nor document ordering of the results.

New features in XPath 3.1 edit

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

contains(upper-case(substring-before($in, ' ')), 'X') 

can now be written

$in => substring-before(' ') => upper-case() => contains('X') 

References edit

  • "XML Path Language (XPath) 3.0". World Wide Web Consortium. 8 April 2014.
  • "XML Path Language (XPath) 3.1". World Wide Web Consortium. 21 March 2017.


xpath, this, article, includes, list, references, related, reading, external, links, sources, remain, unclear, because, lacks, inline, citations, please, help, improve, this, article, introducing, more, precise, citations, december, 2022, learn, when, remove, . This article includes a list of references related reading or external links but its sources remain unclear because it lacks inline citations Please help improve this article by introducing more precise citations December 2022 Learn how and when to remove this message 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 Recommendation on 21 March 2017 New features in XPath 3 0 editCompared to XPath 2 0 XPath 3 0 adds the following new features Inline function expressions Anonymous functions can be created in an expression context For example the expression span class nf function span span class p span span class nv span span class n a span span class w span span class k as span span class w span span class kt xs double span span class p span span class w span span class nv span span class n b span span class w span span class k as span span class w span span class kt xs double span span class p span span class w span span class k as span span class w span span class kt xs double span span class w span span class p span span class w span span class nv span span class n a span span class w span span class o span span class w span span class nv span span class n b span span class w span span class p span creates a function that returns the product of its two arguments The expression span class nf collection span span class p span span class k let span span class w span span class nv span span class n a span span class w span span class o span span class w span span class p span span class w span span class k return span span class w span span class nf function span span class p span span class w span span class p span span class w span span class nv span span class n a span span class w span span class p span creates a sequence of functions each one returning a different node from a collection Dynamic function calls Function values may be called without being referenced by name For example span class nv span span class n f span span class p span span class mi 2 span span class p span span class err span span class s2 Hi there span span class p span fetches the second item from sequence f and invokes it as a function passing the string Hi there as argument Union types Union types as defined in XML Schema may be used in type conversions and function type signatures Namespace literals XML namespaces may be referenced using braced URI literals For example the qualified name math pi may be expanded to Q http www w3 org 2005 xpath functions math pi embedding the namespace URI inside the prefix String concatenation operator The new operator may be used for string concatenation a b is equivalent to span class nf fn concat span span class p span span class nv span span class n a span span class p span span class w span span class nv span span class n b span span class p span Mapping operator The new operator performs simple mapping E1 E2 evaluates E2 for each item in the sequence E1 and concatenates the resulting items This is comparable to the path operator but the operator does not perform duplicate elimination nor document ordering of the results New features in XPath 3 1 editXPath 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 gt for function chaining For example the XPath 2 0 expression contains upper case substring before in X can now be written in gt substring before gt upper case gt contains X References edit XML Path Language XPath 3 0 World Wide Web Consortium 8 April 2014 XML Path Language XPath 3 1 World Wide Web Consortium 21 March 2017 nbsp This computing article is a stub You can help Wikipedia by expanding it vte Retrieved from https en wikipedia org w index php title XPath 3 amp oldid 1126932817, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.