Support #5214


Ghost function calls in trace listener

Added by Radu Coravu 4 months ago. Updated 3 months ago.

Start date:
Due date:
% Done:


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


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)
                  protected boolean isApplicable(Expression exp) {
                    return exp instanceof FunctionCall || super.isApplicable(exp); 

but now in an XSLT like this:

<xsl:stylesheet xmlns:xsl="" version="2.0">
    <xsl:template match="/">
        <xsl:apply-templates select="//*"/>
    <xsl:template match="*">
        <xsl:variable name="x">
                <xsl:when test="position() = 1">stop</xsl:when>
        <xsl:value-of select="$x"/>

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.

Actions #1

Updated by Radu Coravu 4 months ago

But this is not a blocker, I can just leave things as they are.

Actions #2

Updated by Michael Kay 4 months 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.

Actions #3

Updated by Radu Coravu 4 months ago

Thanks Michael. I understand, we'll leave it like that then.

Actions #4

Updated by Radu Coravu 4 months 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.

Actions #5

Updated by Michael Kay 3 months 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

Also available in: Atom PDF