Project

Profile

Help

Support #5650

closed

Question about finding value for global variable in debugger binding [Saxon 11.4]

Added by Radu Coravu over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2022-08-18
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

I have this XSLT stylesheet

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:variable name="gv" select="'gv'"/>
    <xsl:template match="/">
        <xsl:value-of select="$gv"/>
        <xsl:message>first breakpoint</xsl:message>
    </xsl:template>
</xsl:stylesheet>

when I receive in the trace listener the xsl:message, I find the net.sf.saxon.expr.instruct.GlobalVariable object corresponding to $gv and then I look in the corresponding net.sf.saxon.expr.instruct.Bindery for its value but the value is null. Also none of the methods "net.sf.saxon.expr.instruct.GlobalVariable.evaluateVariable(XPathContext)" have been called on the variable. Does this mean the variable has been inlined by some kind of optimization? How can I find out the value of the variable if it's not found in the bindery?

Actions #1

Updated by Radu Coravu over 1 year ago

I have the OptimizerOptions set to 0

Actions #2

Updated by Michael Kay over 1 year ago

Yes, the value has been inlined.

This is happening in VariableReference.typeCheck() and isn't under the control of any optimization flags.

Actions #3

Updated by Radu Coravu over 1 year ago

Could this be controlled in the future by the existing optimization flag which controls inlining variables? Can I add some kind of small patch somewhere to avoid this? Or starting from the net.sf.saxon.expr.instruct.GlobalVariable object can I find out somehow its constant value if I do not find a value in the binding?

Actions #4

Updated by Radu Coravu over 1 year ago

I managed to obtain the constant value using the net.sf.saxon.style.XSLGlobalVariable.getSourceBinding().getConstantValue() method. Seems ok, I'll see how that goes.

Actions #5

Updated by Michael Kay over 1 year ago

Should be fine until you start getting into packages and overridden variables. But I think if a global variable is overridable then we shouldn't be treating it as having a constant value, so it should be OK.

Actions #6

Updated by Radu Coravu over 1 year ago

Thanks for the confirmation.

Actions #7

Updated by Michael Kay over 1 year ago

  • Category set to Diagnostics
  • Status changed from New to Closed
  • Assignee set to Michael Kay

Decided to close this with no action, but thanks for raising it.

Please register to edit this issue

Also available in: Atom PDF