Page 1 of 1

Using an XQuery //foo/@bar gives "Your query returned an empty sequence."

Posted: Fri Sep 16, 2016 6:56 pm
by Martin Honnen
Using XML Editor 18.0, build 2016081012, when I use a simple path expression //foo/@bar in the XQuery/XPath query builder against an XML document

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<root>
<foo bar="1"/>
<foo bar="2"/>
</root>
I get a notice "Your query returned an empty sequence." at the bottom of the builder when I execute as XQuery 1.0 or 3.0. When I select XPath I get the two selected attributes.

Is the "Your query returned an empty sequence." for XQuery the intended result?

I understand that an XQuery returning attribute nodes without any parent is not serializable as XML but I think if that if a serialization problem is the reason that the query does not return anything that such an explanation should be displayed instead of the claim that the result sequence is empty.

Re: Using an XQuery //foo/@bar gives "Your query returned an empty sequence."

Posted: Sat Sep 17, 2016 10:30 pm
by Dill
I have the same problem.

imo error "XPTY0004: Cannot create an attribute node whose parent is a document node" should be returned.

Re: Using an XQuery //foo/@bar gives "Your query returned an empty sequence."

Posted: Mon Sep 19, 2016 10:29 am
by adrian
Hi,

Thank you for reporting this.

"Your query returned an empty sequence." is a bit of a generic warning that Oxygen returns when there is no result.
The error should be (as shown by Saxon in the command line):

Code: Select all

SENR0001: Cannot serialize a free-standing attribute node (bar)
I've logged this on our issue tracking tool to be addressed in a future version of Oxygen.

Regards,
Adrian

Re: Using an XQuery //foo/@bar gives "Your query returned an empty sequence."

Posted: Mon Sep 19, 2016 1:01 pm
by Martin Honnen
I wonder whether there is an option or should be an option to have oXygen indicate (like oXygen does in the case of using XPath instead of XQuery) that the query selected a sequence of attribute nodes and display each node in the sequence, instead of attempting a serialization. I very much would welcome such a feature.

Re: Using an XQuery //foo/@bar gives "Your query returned an empty sequence."

Posted: Tue Sep 20, 2016 5:10 pm
by adrian
I wonder whether there is an option or should be an option to have oXygen indicate (like oXygen does in the case of using XPath instead of XQuery) that the query selected a sequence of attribute nodes and display each node in the sequence, instead of attempting a serialization. I very much would welcome such a feature.
I've logged a feature request for this. However, it seems impractical to implement this for XQuery since such a script is unusable in practice. IMHO, for XQuery the correct behavior would be to raise an error.
In addition, this is already available for the XPath engine. If you want XPath results for complex scripts, why not simply switch to XPath 3.0, which already does what you want?

Regards,
Adrian

Re: Using an XQuery //foo/@bar gives "Your query returned an empty sequence."

Posted: Wed Sep 21, 2016 12:22 pm
by Martin Honnen
In general XQuery is more powerful and expressive than pure XPath so when I query a document I prefer directly doing that with XQuery. For the simple path //foo/@bar obviously it does not matter.

As for implementing that, I can't judge that in terms of practicality other than that http://saxonica.com/html/documentation/ ... l#iterator() seems to offer that feature for Saxon.

Re: Using an XQuery //foo/@bar gives "Your query returned an empty sequence."

Posted: Thu Apr 06, 2017 2:25 pm
by Radu
Hi,

Just to update this thread, Oxygen 19.0 should have a fix for the problem.

Regards,
Radu