Re: every tenth row change bgcolor
2003-06-09 09:37:55
At 05:52 AM 6/9/2003, Larry wrote:
Sorry to be picky, but here you mention 'pushing' nodes to a template
using <xsl:apply-templates select="foo"/>, I've always regarded that as
pulling... is that right? I've always thought the only way you can use
'push' is through a basic <xsl:apply-templates/> where the next node to
process is decided by document order, with any select statement
(apply-templates or for-each) pulling nodes through (e.g. the nodes to
process are decided by the stylesheet).
I may be missing one of the fundamentals here :)
Having ushered for one of Ken's talks where he talks about push vs. pull
(Hi Ken! <g>), I think the best way to break it down is push =
apply-templates, while pull = value-of. The key being the ORDER of
elements in push being decided by the order in the source document, while
the order of elements in the pull method being decided by the
stylesheet. You're "pulling in" the value, as opposed to letting the XSLT
processor "push" the value to you in the order it finds it. The match
attribute is just a filter.
With all respect, I think this discussion indicates how far short of a
clean, technical distinction is made by "push/pull". It's a handy
distinction to make, but a rough one.
If "pull" is apply-templates, and "push" is value-of (a useful indicator, I
agree), what about for-each? Pull, I think we'd mostly say -- but from the
processing point of view, as we've also observed more than once, there's
really hardly a difference between using a for-each and a template in a
special mode.
If "pull" is when you contrain the order, and "push" is when you let
document order proceed (again a useful indicator), what if you use
apply-templates with xsl:sort?
What makes it worse is that I have heard from experienced technologists
who've been working with these kinds of things since well before XSL, XSLT
is, itself, just plain pull, since its process is driven by the building of
the result tree, not on the processing of the input tree. (In
contradistinction to DSSSL, for example, I am told.)
Yet in a language when you can let apply-templates select a node's
children, in document order, by default, and in which you can leave out
entire templates and let a built-in template fire ... the whole thing in
its most natural, stripped-down form does look an awful lot like "push".
The bottom line is that, while I find the distinction is a very useful one
for characterizing differences of approach between different stylesheets,
and even when one approach is better than another for a particular problem,
nonetheless it's really not the hard-and-fast kind of distinction that you
really have to have clear in your mind to make the language work (such as
the distinction between a node and a string, or in XSLT 1.0, between a node
set and a result tree fragment). When Ken says the apply-templates "pulls"
when it does a select, he's really saying little more than that the select
chooses particular nodes from the source tree to process.
Nowhere in the XSLT Rec is anything said about "push". The word "pull"
occurs once, but in a way that doesn't make any explicit distinction from
"push" (although it does move from explaining how templates can pull values
to describe what we have come to call "pull" stylesheets).
Cheers,
Wendell
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
|