Project

Profile

Help

New Bug and Fix: Repeat Eval in GlobalParam

Added by Anonymous almost 20 years ago

Legacy ID: #2887516 Legacy Poster: Gunther Schadow (gschadow)

Between Saxon 7.6 and Saxon 8.1.1 a new bug has emerged. This one is rather subtle but I think it is clearly a bug. Saxon evaluates param expressions repeatedly, when it should only evaluate them once. Here is an example: <?xml version="1.0" encoding="utf-8"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sys="java:java.lang.System" xmlns:ps="java:java.io.PrintStream"> <xsl:param name="stream" select="(ps:println(sys:err(),'param evaluated'),sys:err())[last()]"/> <xsl:template match="/"> <xsl:value-of select="ps:println($stream,'pong 1')"/> <xsl:value-of select="ps:println($stream,'pong 2')"/> </xsl:template> </xsl:transform> The output should be param evaluated pong 1 pong 2 as it happens with saxon 7.6. But with saxon 8.1.1 it is: param evaluated pong 1 param evaluated pong 2 Interrestingly this happens only with global parameters, not with local parameters nor with local or global variables. So, I expect this bug sits somewhere in the instruct/GlobalParam.java ... And BINGO here is the bug: You say: if (wasSupplied) { return b.getGlobalVariableValue(this); } else { ... // This is the first reference to a global variable; try to evaluate it now. ... where you never check whether you already have it evaluated. Change this code to Value v = b.getGlobalVariableValue(this); if (wasSupplied || v != null) { return v; } else { ... // This is the first reference to a global variable; try to evaluate it now. ... and everything will be fine again. I'll reply to your recent mail soon. If I reply by email, will it get to the email list that you named even if I'm not signed up? regards, -Gunther


Replies (1)

RE: New Bug and Fix: Repeat Eval in GlobalPar - Added by Anonymous almost 20 years ago

Legacy ID: #2887613 Legacy Poster: Michael Kay (mhkay)

Thanks. It's not actually a conformance issue - processors are allowed to evaluate variables repeatedly, and if doing so calls extension functions that have side effects, so be it - however, it's a coding error and I will fix it. Michael Kay

    (1-1/1)

    Please register to reply