https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2021-03-22T13:15:55ZSaxonica Developer CommunitySaxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=175662021-03-22T13:15:55ZMichael Kaymike@saxonica.com
<ul></ul><p>I haven't been able to reproduce this. Can you give us more details about how you are running the code, including the platform you are running on?</p> Saxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=175672021-03-22T13:49:48ZPavel Vítkovský
<ul><li><strong>File</strong> <a href="/attachments/49250">issue4944.zip</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/49250/issue4944.zip">issue4944.zip</a> added</li><li><strong>File</strong> <a href="/attachments/49251">stacktrace.txt</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/49251/stacktrace.txt">stacktrace.txt</a> added</li></ul><p>Manifests both on my Windows 10 machine and on our production Linux server (locally tested on Java 8 and Java 11, on server with Java 11 only). I have attached zip archive I'm using on mu local machine. Both Saxon builds are downloaded from Maven central. Added also exception stack trace of the actual production stylesheet having this issue.</p> Saxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=175682021-03-22T16:44:36ZMichael Kaymike@saxonica.com
<ul></ul><p>Problem now reproduced - but not in my normal debugging environment!</p>
<p>The specification says that xsl:value-of, when the select expression returns an empty sequence, should deliver a zero-length text node, but the function is actually returning an empty sequence. Because the static type analysis inferred a type of text() for the function result, the code for the comparison is assuming that it won't get an empty sequence, and fails when it does. There is some interplay here with the precise way in which the transformation is run; the function has to be executed in push mode for the failure to occur.</p> Saxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=175692021-03-22T17:06:21ZMichael Kaymike@saxonica.com
<ul></ul><p>I'm going to have to create a new IntelliJ project based on the Saxon10.3 HE code as issued in order to get to the bottom of this one.</p> Saxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=175732021-03-22T22:37:08ZMichael Kaymike@saxonica.com
<ul></ul><p>The optimisations carried out at compile time appear to be correct. The body of the function is reduced to</p>
<pre><code>ValueOf(lastOf(tokenize((), "/", "")))
</code></pre>
<p>which should be OK: when the operand of <code>ValueOf</code> is an empty sequence, the result of <code>ValueOf</code> should be a single zero-length text node, However, the push-mode evaluation of this instruction, which has changed in 10.x to stream the result to the serializer, actually delivers an empty sequence rather than a single zero-length text node.</p>
<p>I don't know why this path is only taken in these particular circumstances, but there's a flaw in the logic here, and it's not immediately obvious how to fix it.</p> Saxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=175742021-03-23T00:09:16ZMichael Kaymike@saxonica.com
<ul></ul><p>This bug is proving surprisingly difficult. I've made various attempts at fixing it by detecting the case where the xsl:value-of/select selects an empty sequence and emitting a zero-length text node in this case; all my attempts cause regression to significant numbers of other tests.</p> Saxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=175752021-03-23T00:28:25ZMichael Kaymike@saxonica.com
<ul></ul><p>The only fix I've found that causes no regression is to suppress the optimisation in ValueOf (specifically, pushing the output of the select expression directly to the serializer) in the case where the select expression is capable of returning an empty sequence.</p> Saxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=175762021-03-23T07:07:13ZPavel Vítkovský
<ul></ul><p>So far there is only a single location in one of the stylesheets that is affected by it in our case and since it is trivial to avoid it (and in fact improve the stylesheet, there really is no reason to use value-of) we're sticking with upgrade. Thanks for the insights.</p> Saxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=175772021-03-23T07:33:38ZMichael Kaymike@saxonica.com
<ul></ul><p>Indeed, basic good practice like (a) declaring the types of the parameters and return value of <code>xsl:function</code>, and (b) using <code>xsl:sequence</code> rather than <code>xsl:value-of</code> to return the function result, would have prevented the problem from occurring. But of course we have to treat it as a bug anyway.</p> Saxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=176282021-03-29T12:01:21ZMichael Kaymike@saxonica.com
<ul><li><strong>Category</strong> set to <i>XSLT conformance</i></li><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li><li><strong>Assignee</strong> set to <i>Michael Kay</i></li><li><strong>Priority</strong> changed from <i>Low</i> to <i>Normal</i></li><li><strong>Applies to branch</strong> <i>trunk</i> added</li><li><strong>Fix Committed on Branch</strong> <i>10, trunk</i> added</li></ul><p>I have applied the change proposed: the optimisation no longer takes place if the expression is capable of returning an empty sequence.</p> Saxon - Bug #4944: Error XPTY0004 on Saxon-HE 10.3 (not on 9.9.1-8)https://saxonica.plan.io/issues/4944?journal_id=178392021-04-14T15:50:05ZO'Neil Delprattoneil@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>Fixed in Maintenance Release</strong> <i>10.5</i> added</li></ul><p>Bug fix applied to Saxon 10.5 maintenance release.</p>