https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2023-05-25T10:57:23ZSaxonica Developer CommunitySaxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=238842023-05-25T10:57:23ZMichael Kaymike@saxonica.com
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Rejected</i></li><li><strong>Assignee</strong> set to <i>Michael Kay</i></li></ul><p>Thanks.</p>
<p>But Saxon appears to give the correct result.</p>
<p>Test case fn-exists-101 added to qt4tests.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=238852023-05-25T15:48:33ZMichael Kaymike@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Rejected</i> to <i>In Progress</i></li></ul><p>Reopening. <del>The test is working from the command line but not in the test driver.</del></p>
<p>The test is working in 12.x but not in 11.x. In 11.x, the predicate is being rewritten to <code>[exists(data(@n1) ge -1)]</code> which is incorrect; the <code>ge</code> operator returns <code>()</code> when one of the operands is <code>()</code>.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=238862023-05-25T16:21:04ZMichael Kaymike@saxonica.com
<ul></ul><p>In 11.x, GeneralComparison.typeCheck() line 305 rewrites the comparison to a value comparison like this:</p>
<pre><code> Expression vun = makeCompareUntypedToNumeric(getLhsExpression(), getRhsExpression(), singletonOperator);
return vun.typeCheck(visitor, contextInfo);
</code></pre>
<p>In 12.x this has been changed to:</p>
<pre><code> setAtomicComparer(new UntypedNumericComparer());
return this;
</code></pre>
<p>Git Blame dates this as 19/08/22 and attributes it to bytecode changes, I suspect a bug fix mixed into the same commit as something else.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=238872023-05-25T16:47:44ZMichael Kaymike@saxonica.com
<ul></ul><p>I've done a fair bit of digging in the history and I can't find any record of what motivated this code change on 2022-08-19. So I'm going to have to deal with it from first principles.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=238882023-05-25T17:04:21ZChristian Grünchristian.gruen@gmail.com
<ul></ul><p>Coincidental bug fixes are not the worst ;)</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=238892023-05-25T17:05:17ZMichael Kaymike@saxonica.com
<ul><li><strong>Category</strong> set to <i>XPath conformance</i></li><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Resolved</i></li><li><strong>Priority</strong> changed from <i>Low</i> to <i>Normal</i></li><li><strong>Applies to branch</strong> <i>11</i> added</li><li><strong>Fix Committed on Branch</strong> <i>11</i> added</li><li><strong>Platforms</strong> <i>.NET, Java</i> added</li></ul><p>I've retrofitted the code change from 12.x to 11.x and it seems to regression test OK.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=238902023-05-25T17:07:47ZJohn Lumleyjohn@saxonica.com
<ul></ul><p>The worst I’ve had was where a bug went away when run under the debugger, due to a bug in the debugger!</p>
<p>Sent from my iPad</p>
<blockquote>
<p>On 25 May 2023, at 18:04, Saxonica Developer Community <a href="mailto:notifications@plan.io" class="email">notifications@plan.io</a> wrote:<br>
</p>
</blockquote> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=238922023-05-25T18:31:12ZChristian Grünchristian.gruen@gmail.com
<ul></ul><p>…must have been a heisen(de)bugger!</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=238972023-05-26T06:54:45ZMichael Kaymike@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>In Progress</i></li></ul><p>Reopened because there are reports that this fails on 12.2 see <a href="https://github.com/BaseXdb/basex/issues/2212" class="external">https://github.com/BaseXdb/basex/issues/2212</a></p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239772023-06-06T21:27:29ZMichael Kaymike@saxonica.com
<ul><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Resolved</i></li><li><strong>Applies to branch</strong> <i>9.7</i> added</li><li><strong>Applies to branch</strong> deleted (<del><i>11</i></del>)</li></ul><p>Closing this again. I have checked carefully, and I'm convinced Saxon 12.2 returns the correct result.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239812023-06-07T02:46:58ZShuxin Li
<ul></ul><p>Thanks for the update! I checked again and I think it might be the influence of other Jar files which I included in the project which is pretty strange. When I remove the jar file of eXist-core the problem indeed disappeared. Thanks again!</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239822023-06-07T05:04:56ZShuxin Li
<ul></ul><p>Hi, today I found another case which seems to be very similar to this issue about non-existing attributes (I verified through the command line that this is reproducible for Saxon-HE 12.2)
XML:</p>
<pre><code class="xml syntaxhl" data-language="xml"><span class="nt"><Q1/></span>
</code></pre>
<p>XPath:</p>
<pre><code>//Q1[(@p1 ! (. > 1)) = false()]
</code></pre>
<p>Saxon returned empty result set. Should return Q1.</p>
<p>This is the what I executed from the cmd:</p>
<pre><code class="shell syntaxhl" data-language="shell">java <span class="nt">-cp</span> saxon-he-12.2.jar net.sf.saxon.Query <span class="nt">-t</span> <span class="nt">-s</span>:test.xml <span class="nt">-q</span>:xq.xq <span class="nt">-o</span>:out.txt
</code></pre>
<p>In out:</p>
<pre><code class="xml syntaxhl" data-language="xml"><span class="cp"><?xml version="1.0" encoding="UTF-8"?></span>
</code></pre> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239832023-06-07T05:05:28ZShuxin Li
<ul></ul><p>Perhaps there is another part of the source code where this bug still exists?</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239872023-06-07T11:07:08ZMartin Honnenmartin.honnen@gmx.de
<ul></ul><p>Shuxin Li wrote in <a href="#note-12">#note-12</a>:</p>
<blockquote>
<p>Hi, today I found another case which seems to be very similar to this issue about non-existing attributes (I verified through the command line that this is reproducible for Saxon-HE 12.2)
XML:</p>
<pre><code class="xml syntaxhl" data-language="xml"><span class="nt"><Q1/></span>
</code></pre>
<p>XPath:</p>
<pre><code>//Q1[(@p1 ! (. > 1)) = false()]
</code></pre>
<p>Saxon returned empty result set. Should return Q1.</p>
</blockquote>
<p>Can you explain why?</p>
<p>The predicate in my view evaluates to false (as <code>() = false()</code> is <code>false()</code>) so <code>//Q1[false()]</code> correctly doesn't select anything.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239882023-06-07T11:13:29ZMichael Kaymike@saxonica.com
<ul></ul><p>I agree with Martin's analysis.</p>
<p>Note however that if XPath 1.0 compatibility mode is enabled, comparing an empty sequence to <code>false()</code> returns true, whereas without 1.0 compatibility mode, it returns false. Of course an XPath 1.0 processor doesn't understand the "!" operator, but a 2.0 processor running in 1.0 mode will give a different result.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239892023-06-07T11:44:31ZShuxin Li
<ul></ul><p>Hi Martin, I'm not very sure about the semantics because I didn't actually find where it is documented.</p>
<p>I derived this from the discussion here: <a href="https://github.com/BaseXdb/basex/issues/2212" class="external">https://github.com/BaseXdb/basex/issues/2212</a></p>
<p>It was mentioned that () >= -1 returns false(), therefore I thought that in this case (. > 1) is (() > 1) should return false(), and false() = false() should return true(). So the node should be selected. I don't know if this is correct?</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239902023-06-07T11:47:52ZShuxin Li
<ul></ul><p>For in this test BaseX did return the node as expected, and I thought it should be the case.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239912023-06-07T12:21:12ZMartin Honnenmartin.honnen@gmx.de
<ul></ul><p>Shuxin Li wrote in <a href="#note-16">#note-16</a>:</p>
<blockquote>
<p>Hi Martin, I'm not very sure about the semantics because I didn't actually find where it is documented.</p>
<p>I derived this from the discussion here: <a href="https://github.com/BaseXdb/basex/issues/2212" class="external">https://github.com/BaseXdb/basex/issues/2212</a></p>
<p>It was mentioned that () >= -1 returns false(), therefore I thought that in this case (. > 1) is (() > 1) should return false(), and false() = false() should return true(). So the node should be selected. I don't know if this is correct?</p>
</blockquote>
<p>As <code>@p1</code> gives the empty sequence the result of <code>@p1 ! (. > 1)</code> is the empty sequence.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239922023-06-07T12:50:51ZShuxin Li
<ul></ul><p>Hi Martin, I could understand that if take map as a streaming process, empty sequence will result in an empty sequence. So is it correct that it's the map that changed the situation? Still it seems a bit confusing though, for in previous case () >= 1 returns false() and here () > 1 returns the empty sequence.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239932023-06-07T12:53:47ZShuxin Li
<ul></ul><p>I get the idea that with map Saxon takes the input as a sequence, and if no item is in the sequence it will result in an empty sequence instead of giving the empty sequence as an input to the following functions. That makes a lot of sense! Thank you very much.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239942023-06-07T13:42:22ZMichael Kaymike@saxonica.com
<ul></ul><p>An expression using the "=" operator is called a General Comparison, and the rules are found at</p>
<p><a href="https://www.w3.org/TR/xpath-31/#id-general-comparisons" class="external">https://www.w3.org/TR/xpath-31/#id-general-comparisons</a></p>
<p>To summarise, if you compare <code>S = T</code> when S and T are sequences, the comparison is true if there is an item <code>$s</code> in <code>S</code> and an item <code>$t</code> in T such that $s equals $t. That means if either S or T is an empty sequence, the result is necessarily false: <code>() = X</code> is false regardless what <code>X</code> is.</p>
<p>So given the expression</p>
<pre><code>`(@p1 ! (. > 1)) = false()`
</code></pre>
<p>@p1 is an empty sequence</p>
<p>Therefore <code>@p1 ! X</code> is an empty sequence (regardless what X is)</p>
<p>So you are comparing an empty sequence with <code>false()</code>, which is always false.</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=239972023-06-07T15:30:12ZShuxin Li
<ul></ul><p>Thank you for the detailed explanation! I get that :)</p> Saxon - Bug #6051: Bug on exist() with non-existing attributehttps://saxonica.plan.io/issues/6051?journal_id=246572023-08-24T11:41:40ZDebbie Lockettdebbie@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li><li><strong>Applies to branch</strong> <i>11</i> added</li><li><strong>Applies to branch</strong> deleted (<del><i>9.7</i></del>)</li><li><strong>Fixed in Maintenance Release</strong> <i>11.6</i> added</li></ul><p>Bug fix applied in the Saxon 11.6 maintenance release.</p>