Questions tagged [xpath-3.1]

XPath 3.1 is the current version of XPath, finalized in March of 2017. It adds maps and arrays to XPath 3.0, as well as the arrow operator. Maps and arrays allow for JSON processing support. Use this tag for questions specific to XPath 3.1.

XPath 3.1 is the current version of XPath, it was finalized in March 2017, consisting of three specifications:

It builds on XPath 3.0, finalized in 2014.

The main new features in XPath 3.1 are the addition of maps and arrays to facilitate JSON processing and the arrow operator => which allows writing nested function calls like

tokenize((normalize-unicode(upper-case($string))),"\s+")

as

$string => upper-case() => normalize-unicode() => tokenize("\s+")

instead.

XPath 3.1 is supported on various platforms and with various host languages by implementations like

As XPath 3.1 is basically a subset of XQuery 3.1, any XQuery 3.1 implementation like BaseX also supports XPath 3.1.

Resources

36 questions
1
vote
1 answer

Is a string value "yes/no" allowed as value for the indent parameter of the serialize function?

Using BaseX 8.6 the following use of the serialize function with a map as the second argument works fine: serialize(test, map { 'indent' : 'yes'}) and outputs the indented code test
Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
0
votes
1 answer

How to iterate a json array in xslt

I have the belowjson as input **sample.json** { "publishers": [ { "sellers": { "books": [ { "test": { "count": 1 }, "Name":…
0
votes
1 answer

How to iterate Json Array in Xslt 4.0

sample.json: { "publishers": [ { "sellers": { "books": [ { "test": { "count": 1 }, "Name": "C", "Type":…
0
votes
2 answers

How to extract value from json object in xslt mapping

I have the below json file sample.json { "books": [ { "test": { "count": 1 }, "Name": "C", "Type": "String" }, { "test": { …
0
votes
1 answer

Xpath - multiple "or conditions" with if else

Using the below XML example, what's the best way to write the Xpath3 expression If fruit is apple and quantity is less than 12 or if fruit is watermelon and quantity is less than 2) then return "in-store shopping" otherwise "online"` …
senywork7
  • 3
  • 1
0
votes
1 answer

Execute XPath 3.1 on Java map

I am upgrading from XPath 1.0 to XPath 3.1. I used the library javax.xml.xpath for XPath 1.0 and am now using the Saxon-HE library. It was fairly straightforward to migrate the code and I used the S9API interface for the evaluation of the…
Tim
  • 445
  • 5
  • 19
0
votes
4 answers

XPath sorting not persistent?

I have a following XML: 123456789 111111111 1
Macin
  • 391
  • 2
  • 6
  • 20
0
votes
1 answer

Can an array of atomic values be a node name in an XPath query?

For the query "PROJECT[1]/PROPOSAL[1]/SOLUTION[1]/UNIT[1]/distinct-values(LANDING_DOOR_FRAME_FINISH_FRONT/LANDING_DOOR_FRAME_FINISH_FRONT_VALUE)" this appears to work if distinct-values() returns exactly one value, but throw an exception otherwise.…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
0
votes
2 answers

Does JSON to XML lose me anything?

We have a program that accepts as data XML, JSON, SQL, OData, etc. For the XML we use Saxon and its XPath support and that works fantastic. For JSON we use the jsonPath library which is not as powerful as XPath 3.1. And jsonPath is a little…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
0
votes
1 answer

What is the best way to define all the namespaces for a Saxon XPathCompiler?

When we load an XML file, if it uses namespaces we have to pass all those namespaces to the compiler. First off, is there some call that tells the compiler to read the XML file itself and use the prefixes/URIs declared in the file? It's always…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
0
votes
1 answer

How do I load a JSON file into the DOM in Saxon running in Java?

In my Java code I am trying to create a Saxon document (DOM) that is the contents of a JSON file. This should be possible but the code I have fails. The full code for this is at SaxonQuestions.zip, TestLoadJson.java and is also listed below. In this…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
0
votes
1 answer

How can I read the schema (XSD) from Saxon after loading an XML & XSD file?

Our program displays a tree control showing the metadata structure of the XML file they are using as a datasource. So it displays all elements & attributes in use in the XML file, like this: Employees Employee FirstName LastName Orders …
David Thielen
  • 28,723
  • 34
  • 119
  • 193
0
votes
0 answers

Is this the best way to get all elements & attributes in an XML file using Saxon?

Our program displays a tree control showing the metadata structure of the XML file they are using as a datasource. So it displays all elements & attributes in use in the XML file, like this: Employees Employee FirstName LastName Orders …
David Thielen
  • 28,723
  • 34
  • 119
  • 193
0
votes
1 answer

How do I call fn:sort() in Saxon from Java with multiple sort keys

How do I use the sort function in Saxon when calling it from Java (not from XSLT). For example, for the query (data modeled on the Northwind database) I can get unsorted data using: /windward-studios/Employees/Employee But I want to get it sorted…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
0
votes
1 answer

Is there a way in XPath 3.1 (not XQuery) to sort the results?

I've looked through the spec and can't find anything. But I thought sorting was supported in 3.1. Update (sorry, I have a tendency to assume people can read my mind and I don't list enough details): We're doing this in Java so we…
David Thielen
  • 28,723
  • 34
  • 119
  • 193