xsl-list
[Top] [All Lists]

Re: [xsl] matching question

2008-08-06 04:37:52
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/

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>