Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Prevent spurious warnings on attempting access to child axis of text() or attributes #19

Open
rjelliffe opened this issue Jan 10, 2017 · 2 comments
Labels
bug Description of a bug fix Solution for a bug or enhancement review wanted Needs review before acceptance

Comments

@rjelliffe
Copy link
Member

rjelliffe commented Jan 10, 2017

From Sebastian Rahtz
I am reading iso_schematron_skeleton_for_saxon.xsl, with lots of DPC good bits.

My problem is that when we have rules which match text() or attributes, we get
fake warnings like:

     [xslt] /Users/rahtz/TEI/Sourceforge/trunk/P5/Exemplars/tei_jtei.xsl:1605: Warning! The child axis starting at an attribute node will never select anything

from a generated “apply-template select=‘*’”

My crude fix is below, if you’re interested. I can’t really tell whether this code is maintained somewhere formal?

--- ../Utilities/iso_schematron_skeleton_for_saxon.xsl  (revision 13161)
+++ ../Utilities/iso_schematron_skeleton_for_saxon.xsl  (working copy)
@@ -1638,11 +1638,20 @@
                                        <xsl:with-param name="subject" select="@subject" />
                        </xsl:call-template>

-
-                       <xsl:apply-templates/>
-                       <!-- DPC introduce context-xpath and select-contexts variables -->
-                       <xsl:if test="not($select-contexts)">
-                         <axsl:apply-templates select="{$context-xpath}" mode="M{count(../preceding-sibling::*)}"/>
+                         <xsl:apply-templates/>
+                         <!-- DPC introduce context-xpath and select-contexts variables -->
+                         <xsl:if test="not($select-contexts)">
+                           <xsl:choose>
+                           <xsl:when
+                               test="starts-with(@context,'text(')"/>
+                           <xsl:when
+                               test="starts-with(@context,'@')"/>
+                           <xsl:otherwise>
+                             <axsl:apply-templates
+                                 select="{$context-xpath}"
+                             mode="M{count(../preceding-sibling::*)}"/>
+                           </xsl:otherwise>
+                           </xsl:choose>
                        </xsl:if>
                </axsl:template>
@rjelliffe
Copy link
Member Author

A note Rick made perhaps relating to this:

At end of handling PATTERN has

xsl:commentHousekeeping: SAXON warns if attempting to find the attribute of an attribute</xsl:comment>

          <axsl:when test="not(@*)">

but @* will not test if current node is attribute (or /).

So this should be (self::*) because an element is the only thing that can recurse.

@rjelliffe
Copy link
Member Author

N.b. I have complained in the past to Saxonica that they generate spurious warning messages. It is maddening. But SAXON is a great product.

@tgraham-antenna tgraham-antenna added bug Description of a bug fix Solution for a bug or enhancement review wanted Needs review before acceptance labels Feb 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Description of a bug fix Solution for a bug or enhancement review wanted Needs review before acceptance
Projects
None yet
Development

No branches or pull requests

2 participants