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

Subject: Re: [xsl] copy-of and apply-templates equivalence
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 18 Sep 2020 19:01:32 -0000
On Fri, Sep 18, 2020 at 06:54:32PM -0000, rick@xxxxxxxxxxxxxx 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@xxxxxxxxx
^fs oferiode, pisses swa mfg.
-- Deor  ("That passed, so may this.")

Current Thread