Project

Profile

Help

Bug #3959

closed

Spurious warning: the attribute axis starting at a text node will never select anything

Added by Michael Kay over 5 years ago. Updated over 5 years ago.

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

100%

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

Description

This arises in the XSLT 3.0 test driver written in XSLT (runner/compare.xsl in the W3C test suite). The following two messages appear:

Warning at char 5 in xsl:copy-of/@select on line 156 column 50 of compare.xsl:
  SXWN9000: The attribute axis starting at a text node will never select anything
Warning at char 5 in xsl:copy-of/@select on line 161 column 50 of compare.xsl:
  SXWN9000: The attribute axis starting at a text node will never select anything

There are two problems:

(a) the messages appear repeatedly; warnings should only appear once.

(b) there's nothing wrong with the code in question. Line 156 is the xsl:copy-of instruction in

            <d:_1>
                <xsl:copy select="$a">
                    <xsl:copy-of select="$a/@*"/>
                </xsl:copy>
            </d:_1>

where $a has a declared type of node()?.

Actions #1

Updated by Michael Kay over 5 years ago

The reason for the warning is that the function has been inlined; although $a is declared as node()?, in a particular invocation (from line 50) the supplied value is known to be a text node, and the calling function is being type-checked after inlining of the called function.

The reason for the multiple warnings, similarly, is that the function has been inlined by several callers and each one is being typechecked independently.

The AxisExpression has flags doneTypeCheck and doneOptimize designed to prevent multiple warnings, but it looks like the expression was copied (during inlining) before these flags were set, and so the flags are false on each copy of the expression, and once this has happened there is no remaining connection between the multiple instances.

Actions #2

Updated by Michael Kay over 5 years ago

  • Status changed from New to Resolved
  • Priority changed from Low to Normal
  • Applies to branch 9.9 added
  • Fix Committed on Branch 9.9 added

I have fixed the spurious warnings by adding a flag in ExpressionVisitor that allows warnings to be suppressed, and setting this flag while doing the second type-checking of an inlined function.

While I was at it, I added an optimization rewrite so xsl:copy is replaced by xsl:copy-of if the type is known to be a childless node kind; this causes the body of the xsl:copy to be discarded, which can pave the way for further optimizations, for example if it means that variables are now unreferenced.

Actions #3

Updated by O'Neil Delpratt over 5 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.9.0.2 added

Bug fix applied to the Saxon 9.9.0.2 maintenance release.

Please register to edit this issue

Also available in: Atom PDF