Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

XPath 3

From Wikipedia, the free encyclopedia
Latest version of the XML Path Language
This article includes alist of references,related reading, orexternal links,but its sources remain unclear because it lacksinline citations. Please helpimprove this article byintroducing more precise citations.(December 2022) (Learn how and when to remove this message)

XPath 3 is the latest version of theXML Path Language, aquery language for selecting nodes inXML documents. It supersedesXPath 1.0 andXPath 2.0.

XPath 3.0 became aW3C Recommendation on 8 April 2014, whileXPath 3.1 became aW3C Recommendation on 21 March 2017.

New features in XPath 3.0

[edit]

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

Inline function expressions
Anonymous functions can be created in anexpression context. For example, the expressionfunction($aasxs:double,$basxs:double)asxs:double{$a*$b} creates a function that returns the product of its two arguments. The expressioncollection()/(let$a:=.returnfunction(){$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 inXML Schema, may be used intype conversions and functiontype signatures.
Namespace literals
XML namespaces may be referenced using bracedURIliterals. For example, the qualified namemath:pi may be expanded toQ{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 forstring concatenation:$a || $b is equivalent tofn:concat($a,$b).
Mapping operator
The new! operator performs simple mapping:E1 ! E2 evaluatesE2 for each item in the sequenceE1, 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 forarray and map (associative array) data types. These types and their associated functionality are intended to ease working withJSON 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]


Stub icon

This computing article is astub. You can help Wikipedia byadding missing information.

Retrieved from "https://en.wikipedia.org/w/index.php?title=XPath_3&oldid=1248732961"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp