Re: [xsl] XSL Dominos

Subject: Re: [xsl] XSL Dominos
From: Liam R E Quin <liam@xxxxxx>
Date: Fri, 28 May 2010 21:43:06 -0400
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 Quin - XML Activity Lead, W3C,
Pictures from old books:

Current Thread