[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] XSLT 3.0: What is the correct "Deep Skip" template rule code ?


Subject: [xsl] XSLT 3.0: What is the correct "Deep Skip" template rule code ?
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 2 Jan 2015 21:08:07 -0000

Let me start with wishing to everyone a Happy and Safe New Year!


To continue with more routine, daily stuff :

In section "6.7.4 Built-in Templates: Deep Skip" of the 2nd Last Call
of the W3C "XSLT 3.0" specification
(http://www.w3.org/TR/2014/WD-xslt-30-20141002/#built-in-templates-deep-skip),
we read:

 'The effect of processing a tree using a mode that specifies
on-no-match="deep-skip" is that where no explicit template rule is
specified for an element, that element and all its descendants are
ignored, and are not copied to the result tree.

The effect of choosing on-no-match="deep-skip" is as follows:

The built-in rule for document nodes is equivalent to calling
xsl:apply-templates with no select attribute, and with the mode
attribute set to #current. If the built-in rule was invoked with
parameters, those parameters are passed on in the implicit
xsl:apply-templates instruction.

In the case where there are no parameters, this is equivalent to the
following rule:

<xsl:template match="document-node()" mode="M">
  <xsl:apply-templates mode="#current"/>
</xsl:template>

The built-in rule for all items other than document nodes (that is,
for all other kinds of node, as well as atomic values and functions,
including maps) is to do nothing, that is, to return an empty sequence
(without applying templates to any children or ancestors).

This is equivalent to the following rule:

<xsl:template match="." mode="M"/> '


This definition raises some questions:

1. Why should there be inside a "deep skip" template, an
<xsl:apply-templates> instruction?  If the purpose is really "deep
skip", isn't this most directly accomplished by:

      <xsl:template match="document-node()" mode="M"/>

    And why pass parameters, if they wouldn't be used at all?

2. Why are there two separate "deep skip" built-in templates -- one
for matching document nodes and one for matching any item? Why not
just have a single template that matches any item (document node
included):

     <xsl:template match="." mode="M"/>



-- 
Cheers,
Dimitre Novatchev


Current Thread