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: 44

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

Fri Sep 16, 2016 6:56 pm

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

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

Sat Sep 17, 2016 10:30 pm

I have the same problem.

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

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

Mon Sep 19, 2016 10:29 am

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: 44

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

Mon Sep 19, 2016 1:01 pm

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: 2466

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

Tue Sep 20, 2016 5:10 pm

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: 44

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

Wed Sep 21, 2016 12:22 pm

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/ ... #iterator() seems to offer that feature for Saxon.
Radu
Posts: 5877

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

Thu Apr 06, 2017 2:25 pm

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

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 4 guests