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

Re: [xsl] deep copy without attributes


Subject: Re: [xsl] deep copy without attributes
From: Graydon <graydon@xxxxxxxxx>
Date: Tue, 21 May 2013 05:52:49 -0400

On Tue, May 21, 2013 at 01:35:54AM +0100, Ihe Onwuka scripsit:
> On Tue, May 21, 2013 at 12:02 AM, Graydon <graydon@xxxxxxxxx> 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@xxxxxxxxx


Current Thread
Keywords