Project

Profile

Help

Bug #4970

line/column number in trace listener

Added by Air Quick about 1 month ago. Updated 6 days ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2021-04-16
Due date:
% Done:

0%

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

Description

Line and column numbers obtained in Saxon 9.9.1.8 trace listener:

$ cat in.xml
<?xml version="1.0" encoding="UTF-8"?>
<iron weight="1" />
$ java -jar ${SAXON_JAR} -s:in.xml -xsl:'https://github.com/xspec/xspec/raw/v2.0.7/tutorial/coverage/demo.xsl' -T
<trace saxon-version="9.9.1.8" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <source node="/iron" line="2" file="in.xml">
  <xsl:template match="iron" line="11" column="50" module="demo.xsl">
   <LRE name="shield" line="12" column="11" module="demo.xsl">
    <xsl:apply-templates line="13" column="48" module="demo.xsl">
     <source node="/iron/@weight" line="2" file="in.xml">
      <xsl:template match="@* | node()" line="8" column="48" module="demo-imported.xsl">
       <xsl:copy line="9" column="13" module="demo-imported.xsl">
       </xsl:copy>
      </xsl:template>
     </source><!-- /iron/@weight -->
    </xsl:apply-templates>
   </LRE>
  </xsl:template>
 </source><!-- /iron -->
<?xml version="1.0" encoding="UTF-8"?><shield weight="1"/></trace>

are different from 10.5:

$ java -jar ${SAXON_JAR} -s:in.xml -xsl:'https://github.com/xspec/xspec/raw/v2.0.7/tutorial/coverage/demo.xsl' -T
<trace saxon-version="10.5" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <source node="/iron" line="2" file="in.xml">
  <xsl:template match="iron" line="11" module="demo.xsl">
   <LRE name="shield" line="12" column="11" module="demo.xsl">
    <xsl:apply-templates line="13" column="3" module="demo.xsl">
     <source node="/iron/@weight" line="2" file="in.xml">
      <xsl:template match="@* | node()" line="8" module="demo-imported.xsl">
       <xsl:copy line="10" column="3" module="demo-imported.xsl">
       </xsl:copy>
      </xsl:template>
     </source><!-- /iron/@weight -->
    </xsl:apply-templates>
   </LRE>
  </xsl:template>
 </source><!-- /iron -->
<?xml version="1.0" encoding="UTF-8"?><shield weight="1"/></trace>

It looks to me 10.5 is incorrect or less consistent at best.

History

#1 Updated by Michael Kay 6 days ago

  • Category set to Diagnostics
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal

It seems there was a change in design for tracing in 10.x - instead of wrapping each expression/instruction in a TraceExpression as it is created, we post process the compiled code adding trace expressions into the tree on completion. The effect is that the TraceExpression for an ApplyTemplates instruction (for example), now takes the location information from the compiled ApplyTemplates instruction in the expression tree, not from the source xsl:apply-elements element in the source tree. This turns out to be inaccurate, because we are not systematically transferring the location information from source instructions to compiled instructions - instead, it is being inferred from parent instructions or child expressions.

#2 Updated by Michael Kay 6 days ago

  • Status changed from New to Resolved
  • Applies to branch 10, trunk added
  • Fix Committed on Branch 10, trunk added

The location information used to be set in StyleElement.makeTraceInstruction(), which still exists in vestigial form although it no longer does anything useful. I think we can probably fix it by repurposing (and renaming) this method, since it is called in all the right places.

This fixes the two cases where instruction information is inaccurate (xsl:apply-templates and xsl:copy). It doesn't fix the remaining difference in this example, namely the lack of a column number for xsl:template. This omission is unlikely to matter for most people, but I guess we should try and provide it for consistency.

So I've added a column number attribute to TemplateRule and Actor.

Please register to edit this issue

Also available in: Atom PDF