-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XSLT code coverage incorrectly marks contents of xsl:choose as missed #939
Comments
xsl:choose
as missed
I tested quickly on v1.0.0, v1.2.0 and v1.6.0 with your sample and Saxon-EE 9.9.1.7. The problem was reproduced on all of them. Setting |
With #941, you can see every N:\xspec-939>set DEBUG_XSLT_COVERAGE_TRACE_LISTENER=1
N:\xspec-939>set SAXON_CUSTOM_OPTIONS=-opt:0
N:\xspec-939>set SAXON_CP=...\SaxonHE9-9-1-7J\saxon9he.jar
N:\xspec-939>...\bin\xspec.bat -c coverage_choose.xspec
...
Running Tests...
Collecting test coverage data...
****************************************
...
enter() : file:/M:/Scripts/XSpec/issue/xspec-939/coverage_choose.xsl:3
...
enter() : file:/M:/Scripts/XSpec/issue/xspec-939/coverage_choose.xsl:5
... So, probably this is a very fundamental optimization by Saxon or its stylesheet interpretation we can't suppress. I also took a look at an output from |
Thanks for the due diligence.
I've asked Saxonica if they can take a look, and I'll report back here if I find out anything. |
With #1833 and Saxon-HE 12.4, I still see this behavior, even with I didn't end up finding out anything from Saxonica back in 2020. Their usual policy is not to debug third-party applications, nothing obvious jumped out at Michael Kay, and I don't know how to reproduce the problem outside of XSpec. |
So, when I modified your stylesheet as follows <?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> and ran it with this command line
|
Thanks for the information. I'll try to put together a question to ask Saxonica about this in the next week or so. |
I created this issue report for Saxonica: https://saxonica.plan.io/issues/6295 |
In XSLT code coverage reports, I'm seeing cases where
xsl:choose
is correctly marked as hit, but the contents ofxsl:choose
are incorrectly marked as missed. The problem seems to be in the trace file, not the interpretation of the trace or the formatting of the coverage report.I'm not sure if the problem in the trace file is due to a bug in Saxon or the XSpec trace listener. Does anyone know? The problem exists when I use Saxon-EE version 9.9.1.7 (which is the latest 9.9.x.x version right now) or 9.8.0.15.
I also tried using XSpec 1.2 to see if the issue is new for XSpec. I got an error message during report formatting (something not quite right about my environment, maybe) but the trace did get generated and it shows the same set of lines being hit.
Sample XSLT
Sample XSpec
Coverage report shows hit on
xsl:choose
on line 5 (see<h l="5" m="0" c="142"/>
below) but none of its descendants, not evenxsl:otherwise
. This is reflected in the trace file as follows:The text was updated successfully, but these errors were encountered: