Support #5650
closedQuestion about finding value for global variable in debugger binding [Saxon 11.4]
0%
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?
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.
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?
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.
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.
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