Project

Profile

Help

Bug #6295

closed

Saxon (HE; Java) trace missing xsl:choose children and xsl:sequence

Added by A Galtman 11 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2023-12-18
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

Using the trace feature in Saxon-HE, I'm seeing cases where lines I expect to be hit are not showing that they were hit. The omissions create a problem for the Code Coverage reporting feature of XSpec, because users of that feature want a reliable report of which lines of XSLT code the tests reached.

Here is how to reproduce the situation outside of XSpec:

Sample XSLT

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:f="myfunctions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
  
  <xsl:template name="xsl:initial-template">
    <xsl:variable name="child1" as="element(child1)"><child1/></xsl:variable>
    <xsl:variable name="child2" as="element(child2)"><child2/></xsl:variable>
    <xsl:variable name="other" as="element(other)"><other/></xsl:variable>
    <xsl:sequence select="($child1, $child2, $other) ! f:fcn(.)" />
  </xsl:template>
  
  <xsl:function name="f:fcn">
    <xsl:param name="node" as="element()"/>
    <xsl:choose>
      <xsl:when test="$node/self::child1">
        <xsl:sequence select="'first'"/>
      </xsl:when>
      <xsl:when test="$node/self::child2">
        <xsl:sequence select="'second'"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:sequence select="'third'"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:function>
</xsl:stylesheet>

Saxon Command

java -cp "%SAXON_CP%" net.sf.saxon.Transform -opt:0 -T -Tlevel:high -it -xsl:choose-trace.xsl 2> trace-result.xml

Output from Saxon-HE 12.4

<trace saxon-version="12.4" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template name="xsl:initial-template" line="4" column="45" module="choose-trace.xsl">
  <xsl:variable name="child1" line="5" column="54" module="choose-trace.xsl">
   <trace name="child1" line="5" column="63" module="choose-trace.xsl">
   </trace>
   <xsl:variable name="child2" line="6" column="54" module="choose-trace.xsl">
    <trace name="child2" line="6" column="63" module="choose-trace.xsl">
    </trace>
    <xsl:variable name="other" line="7" column="52" module="choose-trace.xsl">
     <trace name="other" line="7" column="60" module="choose-trace.xsl">
     </trace>
     <xsl:function arity="1" name="f:fcn" line="11" column="30" module="choose-trace.xsl">
      <choose line="13" column="17" module="choose-trace.xsl">
      </choose>
     </xsl:function>
     <xsl:function arity="1" name="f:fcn" line="11" column="30" module="choose-trace.xsl">
      <choose line="13" column="17" module="choose-trace.xsl">
      </choose>
     </xsl:function>
     <xsl:function arity="1" name="f:fcn" line="11" column="30" module="choose-trace.xsl">
      <choose line="13" column="17" module="choose-trace.xsl">
      </choose>
     </xsl:function>
    </xsl:variable>
   </xsl:variable>
  </xsl:variable>
 </xsl:template>
</trace>

Missing Lines

  1. The line with xsl:choose is included, but all its children are missing from the trace.
  2. The first line with xsl:sequence is missing from the trace.

It seems pretty clear that Saxon is reaching the missing lines. It's just not reporting them in the trace.

Item #1 seems to go way back, because I see it in Saxon-HE 9.9.1.8. Item #2 does not occur in Saxon-HE 9.9.1.8, but it does occur in Saxon-HE 10.9.

Please register to edit this issue

Also available in: Atom PDF