xsl-list
[Top] [All Lists]

Re: [xsl] copy-of and apply-templates equivalence

2020-09-18 14:08:55
Thank you. But if I have an identity transform template, then the results of
both should be the same, correct?

-----Original Message-----
From: Graydon graydon(_at_)marost(_dot_)ca 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 
Sent: Friday, September 18, 2020 3:02 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] copy-of and apply-templates equivalence

On Fri, Sep 18, 2020 at 06:54:32PM -0000, rick(_at_)rickquatro(_dot_)com 
scripsit:
Providing I have an identity transform template, are these two 
basically equivalent?

Nope.

<xsl:copy-of select="doc($file)/*/*" />

Creates a node that's a complete -- "deep" -- copy of the element node
returned by the XPath in the select.  Nothing else happens; no templates
will match on the contents of the elements returned by the XPath in the
select attribute.

<xsl:apply-templates select="doc($file)/*/*"/>

Applies templates -- uses the template matching process to see if there are
any matching templates for -- the element nodes returned by the XPath in the
select attribute.  With an identity transform happening, this will apply
templates (in the default mode) to all the descendant nodes of the element
nodes returned by the XPath in the select.

If you want to match any of those descendant nodes with other templates, you
can do that with apply-templates and you can't do that with copy-of.

--
Graydon Saunders  | graydonish(_at_)gmail(_dot_)com Þæs oferéode, ðisses swá 
mæg.
-- Deor  ("That passed, so may this.")
--~----------------------------------------------------------------
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>