Project

Profile

Help

Bug #6415

closed

Saxon-HE 12.4J trace for unreferenced XSLT variables seems off

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

Status:
Closed
Priority:
Normal
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2024-05-05
Due date:
% Done:

100%

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

Description

The XSLT transformation below declares some global and local variables without referencing them. The trace behavior I'm seeing looks incorrect because the name of a trace element doesn't always match the line/column data.

XSLT Stylesheet, unreferenced-vars.xsl

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:variable name="global-var1"><a/></xsl:variable>
  <xsl:variable name="global-var2"><b/></xsl:variable>
  <xsl:variable name="global-var3"><c/></xsl:variable>
  
  <xsl:template name="xsl:initial-template">
    <xsl:variable name="var1"><a/></xsl:variable>
    <xsl:variable name="var02"><b/></xsl:variable>
    <xsl:variable name="var003"><c/></xsl:variable>
    <root/>
  </xsl:template>
</xsl:stylesheet>

(The zeros in the variable names are just to make it easier to distinguish, in the trace, between line/column pointing to a different instruction and line being off by one.)

Trace

The trace includes mention of the lines that declare var02 and var003 but not var1.

Further examination shows that in trace, @name does not match @line and @column. For instance, <trace name="var1" line="10" column="32"...> has a mismatch because line 10 column 32 is the declaration of var02, not var1.

  
<trace saxon-version="12.4" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template name="xsl:initial-template" line="8" column="45" module="unreferenced-vars.xsl">
  <trace name="var1" line="10" column="32" module="unreferenced-vars.xsl">
   <trace name="var02" line="11" column="33" module="unreferenced-vars.xsl">
    <trace name="var003" line="12" column="12" module="unreferenced-vars.xsl">
     <LRE name="root" line="12" column="12" module="unreferenced-vars.xsl">
     </LRE>
    </trace>
   </trace>
  </trace>
 </xsl:template>
</trace>

Command using Saxon-HE 12.4J:

java -cp "%SAXON_CP%" net.sf.saxon.Transform -T -it -xsl:unreferenced-vars.xsl >output.xml

Question

In general, should users expect unreferenced variables to be traced? In this stylesheet, the unreferenced global variables are not traced, but the unreferenced local variables are.

If I modify the XSLT to reference the variables, I still get the trace elements with data mismatches and I also get xsl:document and LRE elements that look correct.

Please register to edit this issue

Also available in: Atom PDF