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

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Martin Honnen
Posts: 96
Joined: Tue Aug 19, 2014 12:04 pm

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

Post 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.
Dill
Posts: 7
Joined: Tue Aug 23, 2016 8:08 pm

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

Post by Dill »

I have the same problem.

imo error "XPTY0004: Cannot create an attribute node whose parent is a document node" should be returned.
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

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

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Martin Honnen
Posts: 96
Joined: Tue Aug 19, 2014 12:04 pm

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

Post 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.
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

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

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Martin Honnen
Posts: 96
Joined: Tue Aug 19, 2014 12:04 pm

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

Post 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.
Radu
Posts: 9048
Joined: Fri Jul 09, 2004 5:18 pm

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

Post by Radu »

Hi,

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

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply