Page 1 of 1

More detailed result view for XPath/XQuery constructing XML on the fly with e.g. json-to-xml

Posted: Fri Jun 17, 2022 12:12 pm
by Martin Honnen
If I have an XML sample containing JSON e.g.

Code: Select all

<root>{
	"key": "val"
}</root>
then, in XPath 3.1 or XQuery 3.1 I can write path expressions constructing XML "on the fly" with e.g. expressions like

Code: Select all

/root/json-to-xml(.)
However, if I do that in the XPath selector input or even in the XPath/XQuery builder and evaluate the expression, the result I get displayed is nothing more like

Code: Select all

Description: #document
XPath location: /
Is there some way to have the result pane show the actual document e.g.

Code: Select all

<map xmlns="http://www.w3.org/2005/xpath-functions"><string key="key">val</string></map>
without using e.g. `!serialize()` additionally in the XPath expression?

I understand the XPath input and XPath/XQuery builder, for paths selecting nodes in the input XML, just highlight the selected nodes in the editor pane so there you can see the visual representation of the result evaluation, but I wonder whether, with XPath 3.1 where we can construct nodes on the fly with json-to-xml and parse-xml/parse-xml-fragment, there shouldn't be some way to see the actually created nodes.

Re: More detailed result view for XPath/XQuery constructing XML on the fly with e.g. json-to-xml

Posted: Fri Jun 17, 2022 3:15 pm
by tavy
Hello Martin,

If you select the Saxon XQuery processor in the XPath/XQuery Builder view and run the /root/json-to-xml(.) expression, you will obtain the actual document in the result.
You can also create an XQuery document containing the /root/json-to-xml(.) expression and run it over the XML document.

Best Regards,
Octavian

Re: More detailed result view for XPath/XQuery constructing XML on the fly with e.g. json-to-xml

Posted: Fri Jun 17, 2022 5:01 pm
by Martin Honnen
Thanks.
I take it their is currently no way when I do pure XPath (3.1) evaluation?

Of course in the editor it is easy to switch to XQuery but then of course one might write some non XPath expressions in the editor without necessarily noticing while wanting to "develop" some XPath code you later want to feed to a pure XPath API.

Perhaps you can add a feature request.

Re: More detailed result view for XPath/XQuery constructing XML on the fly with e.g. json-to-xml

Posted: Mon Jun 27, 2022 3:45 pm
by tavy
Hi Martin,

I added an issue on our issue tracker to analyze this situation better. When the issue will be solved we will update this thread.
Thanks again for the feedback.

Best Regards,
Octavian

Re: More detailed result view for XPath/XQuery constructing XML on the fly with e.g. json-to-xml

Posted: Sat Oct 15, 2022 1:46 pm
by Martin Honnen
It appears the new release 25 has quite improved, now the result is shown in the results pane as an "unnamed node" with the serialization of e.g.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<map xmlns="http://www.w3.org/2005/xpath-functions">
   <string key="key">val</string>
</map>
As far as I am concerned, this is kind of the result display I was looking for. Congrats for introducing this feature in the new release.