OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] XPath 3.1 introduction ?



Thanks Dave !




Le 2016-06-22 13:01, Dave Pawson a écrit :

https://www.pluralsight.com/authors/dimitre-novatchev  is the only
comprehensive one I've seen.
Dimitre certainly knows his stuff.


On 22 June 2016 at 10:43,  <cmarchand@oxiane.com> wrote:

Thanks Ghislain ! This is very clear an understandable !

In fact, I need also an introduction to XPath 3.0 ...

Best regards,


Le 2016-06-22 11:35, Ghislain Fourny a écrit :

Hi Christophe

The most prominent add to XPath 3.1 is maps and arrays.

Here's a very abstract overview (which of course misses plenty of smaller
details). It also applies to XQuery 3.1, which supports them as well.

In short:
- Items in sequences can now also be maps or arrays.
- Maps are associative arrays. Keys are any atomic value. Values are any
sequences of items (including arrays and maps, so they can nest).
- Arrays are ordered lists of values. A values is any sequence of items
(including arrays and maps, so they can nest).
- Values put into maps and arrays are *not* copied, so you can use maps,
say, for indexing. This is different from XML node constructors.

To build them:
- One syntax for objects, looking a bit like JSON but more generic (since
you can of course nest expressions) and with a keyword "map", like node

map { "foo" : "bar", "bar" : (1, 2, 3) }

- Two syntaxes for arrays:

Syntax 1 similar to that of maps, with an "array" keyword. It simply takes
the sequence and each item in it becomes a value of the array (So you can't
construct arrays with sequences of more than one item with this one):
array { 1, (2, 3, 4), (), 5 }
creates an array with 5 values, 1, 2, 3, 4 and 5.

Syntax 2 similar to JSON, but it's comma-sensitive in the sense that they
delimit the values (so it's not a comma expression inside: the commas are
part of the constructor)
[ 1, 2, 3, 4, (), (5, 6) ]
creates an array with 5 values : 1, 2, 3, 4, the empty sequence, and the
sequence (5,6)

Alternative 1: Use maps and arrays as function items:
let $map := map { "foo" : "bar" }
return $map("foo")

let $array := array { 1, 2, 3 }
return $array(2)

Alternative 2: Use the ? operator (for NCNames and integers):
let $map := map { "foo" : "bar" }
return $map?foo

let $array := array { 1, 2, 3 }
return $array?2

The ? operator works with wildcards to "unbox" arrays or maps to a sequence:
let $array := array { 1, 2, 3 }
return $array?*

(it also exists as a unary operator, which implicitly assumes the context
item on the left-hand-side)

There are plenty of new functions for maps and arrays documented here:

There are item type notations such as map(*), map(xs:integer, node()),
array(xs:integer), array(*), etc.

I hope it helps you get started!

Feel free to correct me if I got anything wrong in the above.

Kind regards,


XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS