xsl-list
[Top] [All Lists]

Re: [xsl] deep copy without attributes

2013-05-21 04:52:42
On Tue, May 21, 2013 at 01:35:54AM +0100, Ihe Onwuka scripsit:
On Tue, May 21, 2013 at 12:02 AM, Graydon <graydon(_at_)marost(_dot_)ca> 
wrote:
<xsl:template match="node()">
    <xsl:copy>
        <xsl:apply-templates select="node()"/>
    </xsl:copy>
</xsl:template>

does that; it's not recursive, it's a single template.  It'll get
applied to all the nodes, but that's the magic of the XSLT declarative

if it were only about  whether cognoscenti can think up an elegant
solution - we'd still all be doing Muenchian Grouping.

To know about Muenchian Grouping, which is not, alas, elegant, merely
effective, and not know about the identity template seem really odd.

I would also note that understanding the xsl:for-each-group instruction
is in no way obviously easier than understanding Muenchian Grouping!
More capable, more readily applied, I think more powerful even in the
fully formal sense, yes, but it's not an easy instruction to understand.

Identity template processing is surely basic; one of the four basic
patterns for an XSLT program, and I'd argue the _most_ basic of those
four.

Really not wanting to deal with the declarative model, well, yes.  That
is certainly widely observed.  But XSLT _is_ the declarative model.

I've not been paying attention to 3.0 but I'd be looking at copy-of
and thinking it is ripe for accepting an anonymous function/template
that is applied as it traverses it's hierarchy. which would be another
way of addressing the issue.

Which would be a horrible mistake; copy-of is useful in significant part
because it is a way to say "the whole subtree, you don't have to think
about it" to the optimizer.

Thinking of XSLT programming as a conversation with the optimizer isn't
entirely basic, but it's a good habit all the same.

-- 
Graydon Saunders
graydon(_at_)marost(_dot_)ca

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--