Re: [xsl] matching question

Subject: Re: [xsl] matching question
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 6 Aug 2008 12:32:09 +0100
  If my input is like

>   <a>
>      <b/>
>   </a>
> 
>   the above template matches only <a> 

No it also matches b.

The template will only be activated with b as the current node if
templates are applied to b.

initially the current node is the root of the document (/)
your template that matches child::node() does not match / as that is not
the child of anything so the default template is used, which does 
<xsl:apply-templates select="node()"/>

this selects the children of a which is the a element in your example.

your template matches a so will fire.

What happens next depends on what you puit in the ...


> <xsl:template match="node()">
> ...
> </xsl:template>

If you don't apply-templates then that is the end of processing. if you
do apply templates eg have again
<xsl:apply-templates select="node()"/>
or equivalently just
<xsl:apply-templates/>
then templates will be applied to teh children of a which consists of
two white space text nodes and a b element. Your template matching
node() would match all three of those nodes so would be fired a further
three times.


David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread