On Fri, 2010-05-28 at 15:09 +0100, Nick Leaton wrote:
On the apply templates versus call, I've never been able to get my
head round the apply-templates bit, particular because of the need to
use a mode. I personally read apply-templates as, "something happens
here, but I don't know what" !!
When the XSLT processor sees apply-templates, conceptually, this is
what happens:
(1) it makes a list of all the child nodes (elements & text) of the
current element; you can override this using the select= attribute
to apply-templates.
(2) for each child node, xsl:apply-templates looks for the best
template that matches that node, and uses it.
You can restrict the search of templates to ones that have a
particular "mode" attribute value.
If none of the templates you have written match a particular node,
a built-in default template is used.
(3) the results of those templates are joined together and replace the
"xsl:apply-templates" instruction in the current template.
This is the single most important thing to understand about XSLT. Or,
at least, I think it is :)
Note, there are some additional complexities e.g. to do with importing
stylesheets and to do with priority and precedence, so this isn't a
complete picture, but it is enough for understanding what happnens most
of time.
Liam
--
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org
--~------------------------------------------------------------------
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>
--~--