- From: <bugzilla@jessica.w3.org>
- Date: Wed, 20 Jul 2016 05:07:06 +0000
- To: public-qt-comments@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29743 Bug ID: 29743 Summary: XPath 3.1 maps recursive descent Product: XPath / XQuery / XSLT Version: Working drafts Hardware: PC OS: All Status: NEW Severity: normal Priority: P2 Component: XPath 3.1 Assignee: jonathan.robie@gmail.com Reporter: jorge.williams@rackspace.com QA Contact: public-qt-comments@w3.org Target Milestone: --- We use JSONPath (http://goessner.net/articles/JsonPath/) along side of XPath, when working with JSON data. Now that XPath supports maps and JSON, I've started evaluating whether it may be worth consolidating around XPath exclusively. This would certainly make our lives easier especially as JSONPath implementations vary wildly. One feature that appears to be missing, but which is used quite often by our lazy developers is recursive decent ( .. in JSONPath). Notice the examples here: http://goessner.net/articles/JsonPath/ it's a bit of a challenge to replicate them with XPath 3.1. I've created a function in XQuery which I believe captures what JSONPath is doing and it looks like this: declare function r:d($m as item()) as item()* { let $funs := $m?*[. instance of map(*) or . instance of array(*)] let $mps := $funs[. instance of map(*)] return ($mps, $funs ! r:d(.)) }; Given that I can replicate all of the examples : | Description | JSONPath | XPath 3.1 | |------------------------------------+-------------------------+-------------------------------------| | All of the authors of a book | $.store.book[*].author | $_?store?book?*?author | | All authors | $..author | r:d($_)?author | | All things in the store | $.store.* | $_?store?* | | The price of everything in a store | $.store..price | r:d($_?store)?price | | The third book | $..book[ 2 ] | r:d($_)?book?3 | | The last book in order | $..book[(@.length-1)] | r:d($_)?book?*[position() = last()] | | | $..book[-1:] | | | The first two books | $..book[0,1] | r:d($_)?book?(1, 2) | | | $..book[:2] | r:d($_)?book?(1 to 2) | | Filter all books with isbn number | $..book[?(@.isbn)] | r:d($_)?book?*[?isbn] | | Filtar all books cheaper than 10 | $..book[?(@.price< 10)] | r:d($_)?book?*[?price < 10] | | All members of JSON structure | $..* | r:d($_) | Defining a function to do this doesn't seem right though. I must be missing something...or there is a gap. Thanks. -- You are receiving this mail because: You are the QA Contact for the bug.
Received on Wednesday, 20 July 2016 05:07:20 UTC