Re: [xsl] matching question

Subject: Re: [xsl] matching question
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 06 Aug 2008 13:37:07 +0200
Garvin Riensche wrote:
Thanks for your answer. So, if my stylesheet only consists of one template without an apply-templates:

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

I guess there's a build-in template with a call of apply-templates so that this template is executed.

If my input is like

<a>
  <b/>
</a>

the above template matches only <a> although <b> is also a node that is "children of some parent". What's the reason for that?

The built-in template for the root nodes looks like this
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
see http://www.w3.org/TR/xslt#built-in-rule so it processes all child nodes (which in your sample document is the 'a' element).
The a matching template for the 'a' element is used which is your template above where you omitted the template body. If that does <xsl:apply-templates/> respectively <xsl:apply-templates select="node()"/> or <xsl:apply-templates select="*"/> then the 'b' element is processed too.


--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread