xsl-list
[Top] [All Lists]

Re: [xsl] XSLT Dead?

2007-04-17 12:20:52
At 2007-04-17 15:14 -0400, Steve wrote:
Ahh, give and take. For-each is given nodes and apply-templates takes
nodes it "wants". I think I see.

The XPath address in each instruction is the same in that it addresses the nodes the stylesheet "wants" to process.

The distinction is in which result tree construction template is used to build the output: in for-each (pull) you supply the template in the instruction, in apply-templates (push) the processor finds the template based on matching the node with the template rules.

Andrew, when can I expect my benefits package?

:{)}

. . . . . . . . . . . Ken

-S

On 4/17/07, G. Ken Holman <gkholman(_at_)cranesoftwrights(_dot_)com> wrote:
At 2007-04-17 15:02 -0400, Steve wrote:
>This one has me kind of stumped. Maybe I'm one of these people. What
>is the difference between for-each and apply-templates? I have a hard
>time even mentally comparing the two.

Think "pull" and "push".

>One function iterates through a node set and the other matches up a
>template with a node based on a given context or passed mode. Is that
>the right answer, or close to it?

With for-each one pulls nodes from the source tree and the
instruction supplies the one result tree construction rule used for
all nodes pulled.

With apply-templates one pushes nodes from the source tree at the
stylesheet and the processor finds the template rule with the result
tree construction rule for each individual node pushed.

These characterizations seem to be received well by my students.

I hope this helps.

. . . . . . . . Ken

>-Steve
>
>On 4/17/07, Andrew Welch <andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> 
wrote:
>
>>so think XSLT is trivial.  I always ask them to explain the difference
>>between xsl:for-each and xsl:apply-templates...


--
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>