This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: XSLT Processing Model Questions
- From: "Dietrich Ayala" <dietrich at ganx4 dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Sat, 13 Apr 2002 17:12:54 -0700
- Subject: RE: [xsl] XSLT Processing Model Questions
- Reply-to: xsl-list at lists dot mulberrytech dot com
Thanks Peter, your explanation was quite helpful. I have a couple more questions:
> The reason it works is because there is a different between *match*
> expressions and *select* expressions. In match expressions (template
> match="..."), the context node does not affect the result. Here,
> match="doc/title" simply means to match <title> elements that are immediate
> children of a <doc> element, regardless of what the current context is. Once
> the <title> is matched, the <title> becomes the context node within the
> template; the "doc/" is only a restriction on which <title>s can be matched.
>
> Think of match expressions as going in reverse. Here are the basic steps:
>
> * apply-templates selects a <title> node (as a child of the context node).
> * The template tries to match "title" to the selected node. So far so good.
> * The template looks to see if the <title> also has a <doc> parent. So far so
> good.
> * Everything has matched successfully, so the template executes with the
> <title> as the context node.
My next question is: What precurses the above steps? The processor retrieves all <title> children of the root node, and then goes
through the steps above?
>
> On the other hand, in expressions like in
> <xsl:apply-templates select="child::node()"/> (the equivilant of what you
> have), are relative to the context node, as you know. But this only selects
> the nodes; the act of matching them to a template is a totally different
> process (read the XPath spec; these two types of expressions even have
> different grammars, although they are very similar).
So, given the example:
<xsl:apply-templates select="child::node()"/>
The processor would:
* take the nodeset returned from evaluating "child::node()" against the source tree context node
* follow the steps in 5.4 (applying template rules) and 5.5 (conflict resolution for template rules) to determine which is the best
template
* apply the chosen template to the nodeset?
Thanks,
Dietrich
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list