https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2020-05-12T13:57:44ZSaxonica Developer CommunitySaxon - Bug #4552: Incorrect output for streamed xsl:message callhttps://saxonica.plan.io/issues/4552?journal_id=153502020-05-12T13:57:44ZMichael Kaymike@saxonica.com
<ul><li><strong>Status</strong> changed from <i>New</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>10</i> added</li><li><strong>Fix Committed on Branch</strong> <i>10</i> added</li></ul><p>The difference in warning messages is spurious: it only occurs because I was running the tests with <a class="source download" href="https://saxonica.plan.io/projects/saxon/repository/he/raw/on">export:on</a>. But the failure also occurs with <a class="source download" href="https://saxonica.plan.io/projects/saxon/repository/he/raw/off">export:off</a>.</p>
<p>The relevant change seems to be a change to <code>Message.java</code> for bug <a class="issue tracker-1 status-3 priority-2 priority-default closed" title="Bug: Poor serialization of XML-format xsl:message output (Closed)" href="https://saxonica.plan.io/issues/4506">#4506</a>, which changed the evaluation of <code>xsl:message</code> from pull mode to push mode.</p>
<p>The problem here is that Expression.process() uses the expression's <code>evaluateItem()</code> method if <code>getImplementationMethod()</code> includes <code>Expression.EVALUATE</code>, which class <code>ConsumingOperand</code> does; this is only suitable when the expression returns a singleton, and if used in other cases it truncates the sequence to a single item, which is what we see happening.</p>
<p>There are other expression classes that support <code>Expression.EVALUATE</code> even though they might evaluate to a sequence. But others are more careful: for example <code>CardinalityChecker</code> has the logic:</p>
<pre><code>public int getImplementationMethod() {
int m = ITERATE_METHOD | PROCESS_METHOD | ITEM_FEED_METHOD;
if (!Cardinality.allowsMany(requiredCardinality)) {
m |= EVALUATE_METHOD;
}
return m;
}
</code></pre>
<p>I think the safest thing to do, however, is for <code>Expression.process()</code> to only use the <code>evaluateItem()</code> method after doing a cardinality check on the expression.</p> Saxon - Bug #4552: Incorrect output for streamed xsl:message callhttps://saxonica.plan.io/issues/4552?journal_id=153532020-05-14T11:09:07ZMichael Kaymike@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>In Progress</i></li></ul><p>Reopening. The fix caused a regression: test math-1201 (when run with -<a class="source download" href="https://saxonica.plan.io/projects/saxon/repository/he/raw/on">export:on</a>) fails</p>
<pre><code>java.lang.AssertionError: process() is not implemented in the subclass class net.sf.saxon.expr.NegateExpression
</code></pre>
<p>The code for a unary minus expression uses a defaulted method to compute the cardinality of the expression: specifically, it returns the cardinality of the operand expression. So the computed cardinality for <code>-child::price</code> might be zero-or-more. But actually a unary minus expression can only ever return a singleton.</p>
<p>If we evaluate this expression in push mode (e.g because it appears as the body of an element constructor) then we first try the evaluateItem() method, but we're rejecting that because of the incorrect cardinality.</p> Saxon - Bug #4552: Incorrect output for streamed xsl:message callhttps://saxonica.plan.io/issues/4552?journal_id=153542020-05-14T11:29:34ZMichael Kaymike@saxonica.com
<ul><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Resolved</i></li></ul><p>Two parts to fixing this.</p>
<p>First, NegateExpression (which implements unary minus) should return a static cardinality of (0 or 1).</p>
<p>Secondly, the new fallback code for Expression.process() should be made more robust. There must be either an evaluateItem() method or an iterate() method or both; if both are available then the one we choose should depend on the static cardinality.</p>
<p>Committed these additional changes.</p> Saxon - Bug #4552: Incorrect output for streamed xsl:message callhttps://saxonica.plan.io/issues/4552?journal_id=154052020-05-14T15:46:22ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li><li><strong>Fixed in Maintenance Release</strong> <i>10.1</i> added</li></ul><p>Bug fix committed in the Saxon 10.1 maintenance release.</p> Saxon - Bug #4552: Incorrect output for streamed xsl:message callhttps://saxonica.plan.io/issues/4552?journal_id=154262020-05-14T15:50:12ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li></ul>