xsl-list
[Top] [All Lists]

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

2015-01-02 16:00:53
We made a conscious decision that deep-skip should work differently for 
document nodes, because it was found that otherwise, the effect of failing to 
supply an explicit template rule for the document node was very bewildering. A 
built-in template rule for document nodes that skips the whole document is 
simply not useful; it has to be overridden.

The change was documented in item 27 of appendix K, though there is no link to 
the rationale used.

Michael Kay
Saxonica
mike(_at_)saxonica(_dot_)com
+44 (0) 118 946 5893




On 2 Jan 2015, at 21:07, Dimitre Novatchev <dnovatchev(_at_)gmail(_dot_)com> 
wrote:

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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>