Questions tagged [xquery]

XQuery is a functional language designed to query and manipulate XML data. It is a superset of XPath, to which it adds features such as the creation of new nodes and more powerful FLWOR expressions. Although it shares its data model with XSLT, XQuery is optimized for querying rather than transforming data, and as such it has a different design inspired by SQL.

W3C XML Query

XQuery has a rich set of features that allow many different types of operations on data and documents, including:

  • Selecting information based on specific criteria
  • Filtering out unwanted information
  • Updates
  • Searching for information within a document or set of documents
  • Joining data from multiple documents or collections of documents
  • Sorting, grouping, and aggregating data
  • Transforming and restructuring XML data into another XML vocabulary
    or structure
  • Performing arithmetic calculations on numbers and dates
  • Manipulating strings to reformat text

XQuery can be used not just to extract sections of XML documents, but also to manipulate and transform the results.

Modified from O'Reilly XQUERY ISBN-10: 0-596-00634-9 By Priscilla Walmsley.

Relationship to XSLT

XQuery has a large overlap with in terms of purpose but has a syntax and model inspired largely by . Most built in functions are shared with XSLT.

Relationship to XPath

XQuery is mostly a superset of . XQuery version 1 is based on XPath version 2. XQuery version 3 is based on XPath version 3. Version 2 was skipped in order to align the XQuery and XPath version numbers. XQuery 3.1 like XPath 3.1 supports JSON processing through the new map and array types and JSON <--> XML conversion using the xml-to-json and json-to-xml functions as well as parse-json and json-doc functions.

Implementations

  • A list of the current implementations according to the W3C XML Query group.
  • Version 9.8 and later of the Saxon processor support both XSLT 3.0 and XQuery 3.1.
  • BaseX implements all versions of the language and can be use through a CLI.

References

Online training

Books

5333 questions
1
vote
1 answer

Maintaining relationship between XML nodes. SQL. XPath

I am trying to pull data from an XML file using SQL / XPath For my example lets say that the table is called [Books] and the column that contains the XML is called [XML] Example XML: Apology
SQLNoob
  • 13
  • 2
1
vote
1 answer

Need to get the difference in milliseconds between two different timestamps using XQuery in MarkLogic

I need to add milliseconds into the timestamp and need to get the difference in milliseconds. My Code: xquery version "1.0-ml"; let $date1 := xs:dateTime("2022-01-17T21:45:00") let $date2 := xs:dateTime("2022-01-17T22:45:00") let $result :=…
Jayabalan
  • 361
  • 1
  • 7
1
vote
3 answers

How to access the next sibling of an xml tag in openxml sql

So i have an XML file which looks like below declare @xml xml= ' 29-Jun-2019 123 ABC 200
rajsx
  • 61
  • 8
1
vote
1 answer

Option "wildcarded" for "jsonPropertyValueQuery" ctsquery causes the different results called via REST API or in Marklogic Query Console

We have local instance of Marklogic recently downloaded from docker hub with the following bash command: docker run --name marklogic-test -d -it -p 8000:8000 -p 8001:8001 -p 8002:8002 \ -e MARKLOGIC_INIT=true \ -e MARKLOGIC_ADMIN_USERNAME=admin \ …
Nadia
  • 99
  • 6
1
vote
1 answer

How to debug XQuery transformations in OSB 12C?

I am using Oracle Service Bus 12C to translate REST calls between my and third-party servers. I set the REST component on the proxy as well as the business side to use WSDL. I create 4 XSD's (for the proxy request, proxy response, business request…
Hussain Akbar
  • 646
  • 8
  • 25
1
vote
2 answers

Do I need to invoke JavaScript to construct a CTS query from JSON?

In MarkLogic, is there a way to construct a CTS query from a JSON serialization thereof in XQuery (without having to invoke JavaScript)? I only see a JSON example using JavaScript (and XML using XQuery) but not a JSON example using XQuery here:…
Evan Lenz
  • 4,086
  • 1
  • 19
  • 18
1
vote
2 answers

I want to write the XQuery to print the specific keys in JSON and want to except if it has an array value

I want to write the XQuery to print the specific keys in JSON and want to except if it has an array value. Sample JSON: { "id":"743", "transation":{ "101":"success", "102":"rejected", "301":"processing" }, …
Jayabalan
  • 361
  • 1
  • 7
1
vote
2 answers

Xquery - Between two letters

I need the title and position of the books whose title begins between "M" and "Y". XML document: XML Advanced Smith
Cryptter
  • 45
  • 3
1
vote
1 answer

How to do sorting for specific values in Xquery?

AAAAA BBBB CCCC EEEE DDDD I want to do sorting on element "a" but only where name=123,…
anuj_gupta
  • 131
  • 4
1
vote
3 answers

Recursive parent/child combination eliminates all other data

I am relatively new to xQuery and don't use it very often, and I have what's likely a relatively simple question that I just don't know the answer to. How do you apply a function recursively when you have to compare against a parent/child…
medievalmatt
  • 427
  • 2
  • 12
1
vote
1 answer

I want to write the XQuery to print/iterate the keys and values in JSON

This is my sample JSON { "id":"743", "groupName":"group1", "transation":{ "101":"success", "102":"rejected", "301":"processing" } } Expected Result: "101":"success", "102":"rejected", "301":"processing" Can anyone please help me…
Jayabalan
  • 361
  • 1
  • 7
1
vote
1 answer

Is it possible to pass a uri parameter with xi:include in exist-db?

I have an exist-db .xql page where I am wrapping three other .xql pages via xi:include: (:========== Declare namespaces ==========:) declare namespace mwjl = "http://minorworksoflydgate.net/mwjl"; declare namespace m =…
medievalmatt
  • 427
  • 2
  • 12
1
vote
1 answer

xQuery and Saxon. For each value of the parameter a new tag

I got the following sample xml:
Stefan
  • 11
  • 1
1
vote
1 answer

Xquery for inside for

I'm trying to get directly html out from sql query (TSQL, sql server 2008 r2). I have following xml in one of the fields I would need to parse daily schedule by ul list with topic header listed only once, not for each subject. I'm not allowed to…
vipasane
  • 355
  • 2
  • 10
1
vote
1 answer

Convert the JSON attribute from smallcase to uppercase in XQuery and Marklogic 10

I have loaded the below JSON in MarkLogic and I need to convert the Name property value to upper case: { "Name": "User", "Id": "1", "date": "2022-01-01" } Any way to convert the value to upper case in Marklogic and XQuery, looking like below…
Jayabalan
  • 361
  • 1
  • 7