Support #5214
closedGhost function calls in trace listener
0%
Description
Whenever there are function calls in the XSLT like for example:
<xsl:value-of select="substring(local-name(), 2)"/>
I want the trace listener to also give callbacks for the function calls. So I patched the method "net.sf.saxon.Configuration.setCompileWithTracing(boolean)" to also inject a trace expression around function calls:
defaultXsltCompilerInfo.setCodeInjector(new XSLTTraceCodeInjector() {
//OXYGEN PATCH FOR EXM-46382, trace inside function calls.
/**
* @see net.sf.saxon.trace.XSLTTraceCodeInjector#isApplicable(net.sf.saxon.expr.Expression)
*/
@Override
protected boolean isApplicable(Expression exp) {
return exp instanceof FunctionCall || super.isApplicable(exp);
}
});
but now in an XSLT like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<xsl:apply-templates select="//*"/>
</xsl:template>
<xsl:template match="*">
<xsl:variable name="x">
<xsl:choose>
<xsl:when test="position() = 1">stop</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="$x"/>
</xsl:template>
</xsl:stylesheet>
on this line:
<xsl:value-of select="$x"/>
I get a ghost callback for a fn:string-join inside the select attribute value, probably because Saxon does that internally to compose the value-of but somehow it's not 100% ok to show that to the end user.
Updated by Radu Coravu about 2 years ago
But this is not a blocker, I can just leave things as they are.
Updated by Michael Kay about 2 years ago
Can't immediately see how to avoid that. We can avoid some optimisation rewrites to make trace output comprehensible, but where there are two different surface syntaxes for the same functionality (like xsl:if
vs xsl:choose
) it's hard to retain the distinction. xsl:value-of
and other simple node constructor instructions generate a string-join call internally and it's hard to distinguish this from a user-written call.
Updated by Radu Coravu about 2 years ago
Thanks Michael. I understand, we'll leave it like that then.
Updated by Radu Coravu about 2 years ago
Possibly similar problem for a very plain xsl:message:
xsl:messagesecond breakpoint</xsl:message>
The trace listener receives two callbacks, one for the message and one for a "value-of" which is artificially built for the text content inside the message.
Updated by Michael Kay about 2 years ago
- Status changed from New to Closed
In fact any literal text in the stylesheet that implicitly creates a text node (and also xsl:text) will turn into an xsl:value-of instruction.
I don't think there's much we can usefully do about this issue, so I'm going to close it for now.
Please register to edit this issue