Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XQuery: Bug of operation on non-existing attribute #2190

Closed
Twilight-Shuxin opened this issue Mar 17, 2023 · 2 comments
Closed

XQuery: Bug of operation on non-existing attribute #2190

Twilight-Shuxin opened this issue Mar 17, 2023 · 2 comments
Labels

Comments

@Twilight-Shuxin
Copy link

Description of the Problem

Given this XML document:

<T1 id="1">1</T1>

and XPath Query

//T1[(@t1 <= 0) or (@t1 >= -10)]

BaseX give result

<T1 id="1">1</T1>

Expected Behavior

Should return empty result set as Saxon & Exist db.

Steps to Reproduce the Behavior

  1. Create database create database test
  2. Insert XML file into database put test.xml path/to/file
  3. Execute XPath query xquery //T1[(@t1 <= 0) or (@t1 >= -10)]

Do you have an idea how to solve the issue?

No response

What is your configuration?

BaseX version: 10.5 latest stable snapshot on Windows

@ChristianGruen
Copy link
Member

ChristianGruen commented Mar 17, 2023

Good catch. The comparisons were rewritten to true(), no matter if @t1 returned a result. It’s now rewritten as follows:

//T1[@t1 <= 0 or @t1 >= -10]
→ //T1[exists(@t1)]
→ //T1[@t1]

Please note that <x/>[. <= 0 or . >= 0] will not raise an error, even though the input cannot be converted to a double value. Both results are correct: The language specification allows code to be simplified if valid input would always yield the same result.

Another example is <x/>[exists(xs:double(.))], which gives different results depending on the query processor you use.

ChristianGruen added a commit that referenced this issue Mar 17, 2023
@Twilight-Shuxin
Copy link
Author

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants