Subject: Re: [xsl] XSLT Dead? From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Wed, 18 Apr 2007 09:32:12 +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.
I've only ever considered push to be an empty <xsl:apply-templates/> - as soon as you use a select it becomes pull.
Maybe this description is better: there are three trees in a line, the leftmost tree is the input document, the middle tree is the stylesheet and the right hand tree is the result document. With push a _single node_ is "pushed" across from the input document to the stylesheet, where it is processed. With pull a _selection_ of nodes is pulled (built) by the stylesheet, and then processed. Push can only be invoked by <xsl:apply-templates/>, all others are pull.
So in your example above, I would consider both pull because the stylesheet is driving the transform.
So maybe the one-liner definition is: "push processes the input one node at a time in document order, pull processes a selection of node from the input in a user defined order; push can only be invoked by <xsl:apply-templates/>"...
...with a caveat that DC can make an xsl:for-each behave like an <xsl:apply-templates/> :)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT Dead?, David Carlisle | Thread | Re: [xsl] XSLT Dead?, Abel Braaksma |
Re: [xsl] Condition Based Count of , Ragulf Pickaxe | Date | Re: [xsl] Condition Based Count of , J. S. Rawat |
Month |