<xslTutorial creator="nicmila@idoox.com">
<index keywords='/ xsl:apply-templates'/>
<description>Processing always starts with template match="/" . This is the root element and its only child is document element, in our case xslTutorial. Many stylesheets do not contain this element explicitly. When an explicit template does not exist implicit template, which contains <xsl:apply-templates/> instruction is called. This instruction means: processes all of the children of the current node, including text nodes. Compare <stylesheet id='id2'/> and <stylesheet id='id3'/>. When template for a node exists, there is no default processing (<stylesheet id='id4'/>). If you want to include descendants of the node, you have to explicitly request their templates (<stylesheet id='id5'/>).
</description>
<xmlSource id="id1">
<AAA id='a1' pos='start'>
<BBB id='b1'/>
<BBB id='b2'/>
</AAA>
<AAA id='a2'>
<BBB id='b3'/>
<BBB id='b4'/>
<CCC id='c1'>
<DDD id='d1'/>
</CCC>
<BBB id='b5'>
<CCC id='c2'/>
</BBB>
</AAA>
</xmlSource>
<attValues>
<value match=''></value>
</attValues>
<xslStylesheet id="id2">
<xsl:template match="AAA">
<DIV style="color:purple">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id3">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="/xslTutorial">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="AAA">
<DIV style="color:purple">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id4">
<xsl:template match="AAA">
<DIV style="color:purple">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
<xsl:template match="BBB">
<DIV style="color:blue">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
<xsl:template match="CCC">
<DIV style="color:maroon">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
<xsl:template match="DDD">
<DIV style="color:green">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id5">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="/xslTutorial">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="AAA">
<DIV style="color:purple">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="BBB">
<DIV style="color:blue">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="CCC">
<DIV style="color:maroon">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="DDD">
<DIV style="color:green">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
</xslStylesheet>
</xslTutorial>