eXist-db / exist

eXist Native XML Database and Application Platform
https://exist-db.org
GNU Lesser General Public License v2.1
428 stars 179 forks source link

XPath evaluation ending in function gives incorrect result #2158

Open vincentml opened 6 years ago

vincentml commented 6 years ago

What is the problem

This is a possible bug which was found at the XML Summer School in the XQuery class taught by @adamretter

An XQuery that attempts to match a path and return either the result of a function or the empty sequence, using an idiom for "if present then something else empty sequence", appears to be returning incorrect results in eXist-db 4.3.1.

What did you expect

Using this query:

let $doc := <root><example>test</example></root>
return (
  $doc/element(example)/true(),
  $doc/example/true(),
  $doc/element(other)/true(),
  $doc/other/true(),
  $doc/example/string('hello'),
  $doc/other/string('hello')
)

The expected result, as produced by BaseX 9.0.2, is:

true
true
hello

The result produced by eXist-db 4.3.1 is:

true
true
true
true
hello
hello

Describe how to reproduce or add a test

As above.

Context information

eXist Version: | 4.3.1 eXist Build: | 201807241821 Operating System: | Windows 7 6.1 amd64 Java Version: | 1.8.0_172 Installed using JAR installer. No customization of conf.xml

dizzzz commented 6 years ago

alaso Saxon returns

true true hello
line-o commented 4 years ago

exist 5.3.0 still affected