Re: [xsl] XSLT Dead?

Subject: Re: [xsl] XSLT Dead?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 18 Apr 2007 00:11:19 +0100
> Well the answer I look for is that with xsl:apply-templates the
> processing is controlled by the structure of the input document, while
> with xsl:for-each the processing is controlled by the stylesheet.

I think I'd fail the test:-)

if I'm in an xhtml document and processing a p(aragraph) and do
<xsl:template match="h:p">
  <xsl:apply-templates select="/h:html/h:head/h:title"/>
  <xsl:for-each select="node()">
    <a id="generate-id()"/><xsl:copy-of select="."/>
  </xsl:for-each>
</xsl:template>

Then I'd say that the first part is "pull" style where you have gone
off and fetched data from elsewhere in the document, but it's coded with
apply-templates, and the second part is "push" style where you are
walking the children in document order, letting the input drive the
result.

so I think that the "pulliness" or "pushiness" of a stylesheet depends
mostly on the nature of the xpaths used in select
attributes. apply-templates select defaults to node() which is the
canonical "push" example, and for-each has no default select so is
often used for "pull" things. Also of course for-each is far more
limited as it's equivaent to an apply template where every node is
matched by the same template.


David

Current Thread