RE: [xsl] xsl:for-each vs. xsl:apply-templates

Subject: RE: [xsl] xsl:for-each vs. xsl:apply-templates
From: "Evan Lenz" <evan@xxxxxxxxxxxx>
Date: Thu, 11 Nov 2004 09:48:47 -0800
Hello Dimitre and all my long lost pals,

> xsl:apply-templates is much richer and deeper than
> xsl:for-each, even simply because we don't know what code
> will be applied on the nodes of the selection -- in the
> general case this code will be different for different nodes
> of the node-list. Also, the code that will be applied can be
> written way after the xsl:apply templates was written and by
> people that do not know the original author.

You could make some analogies with OOP polymorphism, in that apply-templates
is a polymorphic function. Modes could be compared with method names, and
match patterns could be compared (loosely) with subtyping for dynamic
function resolution. In fact, if you look at the XML source document as
"code" rather than just "data", then you end up with a sort of twice-removed
function resolution. A given element in the source may result in executing
some code in some template rule(s) somewhere. I've found that this
twice-removed nature allows me to express software intentions quite clearly
in XML without being bothered at all by implementation details.

I suspect that my next step will be to finally wrap my brain around your
work on XSLT as a functional language. I seem to be heading in that
direction.

Thanks,
Evan

Current Thread