[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT 3.0: What is the correct "Deep Skip" template

Subject: Re: 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 22:10:25 -0000
 Re: XSLT 3.0: What is the correct "Deep Skip" template
Thank you, Dr. Kay,

> 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

I see the rationale behind this decision. I believe that this
explanation would be better included in the document.

> it has to be overridden.

Some use cases come to mind immediately, where skipping document nodes
would be convenient -- such as when wanting to process only certain
documents from a collection (as matched by the pattern of a specific
template) and filter out all the rest -- without having to write a
template for this filtering.

--
Cheers,
Dimitre Novatchev



On Fri, Jan 2, 2015 at 2:00 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> 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@xxxxxxxxxxxx
> +44 (0) 118 946 5893
>
>
>
>
> On 2 Jan 2015, at 21:07, Dimitre Novatchev <dnovatchev@xxxxxxxxx> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.