Greetings!
While working on some large but fairly simple data, I encountered BaseX using the underscore "_" as an element name when importing JSON.
Not leaving well enough alone for present purposes, I encountered this post about anonymous objects in MarkLogic and how they resolve the problem.
https://developer.marklogic.com/recipe/query-array-anonymous-objects/
Is there already a recommended solution for this problem?
Or should I wait until I actually encounter it and ask again?
Hope everyone is at the start of a great week!
Patrick
Hi Patrick,
Which problem would you like to solve exactly? Maybe I should read the MarkLogic article in more detail, though.
Best, Christian
On Tue, Mar 22, 2022 at 12:15 AM Patrick Durusau patrick@durusau.net wrote:
Greetings!
While working on some large but fairly simple data, I encountered BaseX using the underscore "_" as an element name when importing JSON.
Not leaving well enough alone for present purposes, I encountered this post about anonymous objects in MarkLogic and how they resolve the problem.
https://developer.marklogic.com/recipe/query-array-anonymous-objects/
Is there already a recommended solution for this problem?
Or should I wait until I actually encounter it and ask again?
Hope everyone is at the start of a great week!
Patrick
-- Patrick Durusau patrick@durusau.net Technical Advisory Board, OASIS (TAB) Editor, OpenDocument Format TC (OASIS), Project Editor ISO/IEC 26300 Co-Editor, ISO/IEC 13250-1, 13250-5 (Topic Maps)
Another Word For It (blog): http://tm.durusau.net Homepage: http://www.durusau.net Twitter: patrickDurusau
I'm anticipating incorporation of JSON sources with anonymous nodes and if they all appear with the element name _, how do I distinguish one from another, structurally speaking?
MarkLogic offers some specific workarounds but those are unique (I suspect) to MarkLogic.
The MarkLogic post has an example of the problem I anticipate hitting, especially in biblical studies.
Thanks!
Patrick
On 3/22/22 16:32, Christian Grün wrote:
Hi Patrick,
Which problem would you like to solve exactly? Maybe I should read the MarkLogic article in more detail, though.
Best, Christian
On Tue, Mar 22, 2022 at 12:15 AM Patrick Durusau patrick@durusau.net wrote:
Greetings!
While working on some large but fairly simple data, I encountered BaseX using the underscore "_" as an element name when importing JSON.
Not leaving well enough alone for present purposes, I encountered this post about anonymous objects in MarkLogic and how they resolve the problem.
https://developer.marklogic.com/recipe/query-array-anonymous-objects/
Is there already a recommended solution for this problem?
Or should I wait until I actually encounter it and ask again?
Hope everyone is at the start of a great week!
Patrick
-- Patrick Durusau patrick@durusau.net Technical Advisory Board, OASIS (TAB) Editor, OpenDocument Format TC (OASIS), Project Editor ISO/IEC 26300 Co-Editor, ISO/IEC 13250-1, 13250-5 (Topic Maps)
Another Word For It (blog): http://tm.durusau.net Homepage: http://www.durusau.net Twitter: patrickDurusau
On 22.03.2022 21:48, Patrick Durusau wrote:
I'm anticipating incorporation of JSON sources with anonymous nodes and if they all appear with the element name _, how do I distinguish one from another, structurally speaking?
Are you not able to use XPath/XQuery 3.1 map/array lookup operators directly on your JSON e.g.
?parties[exists(?*[?name = 'name1' and ?role = 'CN'])]
I would write it as follows:
let $string := '{ "parties": [ { "id": 0, "role": "CN", "name": "name1" }, { "id": 1, "role": "SH", "name": "name2" } ] }' let $data := json:parse($string) return $data/json/parties[_[name = 'name1'][role = 'CN']]
Martin provided the solution for the XQuery map/array format:
let $data := json:parse($string, map { 'format': 'xquery'}) return $data?parties[exists(?*[?name = 'name1'][?role = 'CN'])]
On Tue, Mar 22, 2022 at 9:48 PM Patrick Durusau patrick@durusau.net wrote:
I'm anticipating incorporation of JSON sources with anonymous nodes and if they all appear with the element name _, how do I distinguish one from another, structurally speaking?
MarkLogic offers some specific workarounds but those are unique (I suspect) to MarkLogic.
The MarkLogic post has an example of the problem I anticipate hitting, especially in biblical studies.
Thanks! Patrick
Thanks!
Appreciate the quick response!
Patrick
On 3/22/22 17:08, Christian Grün wrote:
I would write it as follows:
let $string := '{ "parties": [ { "id": 0, "role": "CN", "name": "name1" }, { "id": 1, "role": "SH", "name": "name2" } ] }' let $data := json:parse($string) return $data/json/parties[_[name = 'name1'][role = 'CN']]
Martin provided the solution for the XQuery map/array format:
let $data := json:parse($string, map { 'format': 'xquery'}) return $data?parties[exists(?*[?name = 'name1'][?role = 'CN'])]
On Tue, Mar 22, 2022 at 9:48 PM Patrick Durusau patrick@durusau.net wrote:
I'm anticipating incorporation of JSON sources with anonymous nodes and if they all appear with the element name _, how do I distinguish one from another, structurally speaking?
MarkLogic offers some specific workarounds but those are unique (I suspect) to MarkLogic.
The MarkLogic post has an example of the problem I anticipate hitting, especially in biblical studies.
Thanks! Patrick
basex-talk@mailman.uni-konstanz.de