<xslTutorial creator="nicmila@idoox.com">
<index keywords='ancestor ancestor-or-self attribute child descendant descendant-or-self following following-sibling namespace parent preceding preceding-sibling self '/>
<description>Axes play a very important role in XSLT. Study following examples and click on the name of each axis to get some insight. Links to preceding and namespace axis does not work yet as they were not implemented in XT so far.Compare: child axis (<stylesheet id='id2'/>), descendant axis (<stylesheet id='id3'/>), parent axis (<stylesheet id='id4'/>), ancestor axis (<stylesheet id='id5'/>), following-sibling axis (<stylesheet id='id6'/>), preceding-sibling axis (<stylesheet id='id7'/>), following axis (<stylesheet id='id8'/>), preceding axis (<stylesheet id='id9'/>), attribute axis (<stylesheet id='id10'/>), namespace axis (<stylesheet id='id11'/>), self axis (<stylesheet id='id12'/>), descendant-or-self axis (<stylesheet id='id13'/>), ancestor-or-self axis (<stylesheet id='id14'/>).</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'>
<CCC id='c2'/>
</CCC>
<BBB id='b5'>
<CCC id='c3'/>
</BBB>
</AAA>
</xmlSource>
<attValues>
<value match="">
</value>
</attValues>
<xslStylesheet id="id2">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: child</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="child::*">
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id3">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: descendant</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="descendant::*">
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id4">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: parent</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="parent::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id5">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: ancestor</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="ancestor::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id6">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: following-sibling</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="following-sibling::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id7">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: preceding-sibling</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="preceding-sibling::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id8">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: following</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="following::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id9">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: preceding</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="preceding::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id10">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: attribute</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="attribute::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id11">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: namespace</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="namespace::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id12">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: self</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="self::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id13">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: descendant-or-self</TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="descendant-or-self::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id14">
<xsl:template match="/">
<TABLE border="1" cellpadding = "6">
<TR><TH colspan="2">Axis: ancestor-or-self </TH></TR>
<TR><TH>Element</TH><TH>Node-set</TH></TR>
<xsl:for-each select="/xslTutorial//*">
<xsl:call-template name="print"/>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="print">
<TR>
<TD>
<xsl:value-of select="name()"/>
<xsl:text> id = </xsl:text>
<xsl:value-of select="./@id"/>
</TD><TD>
<xsl:for-each select="ancestor-or-self ::*">
<xsl:if test="not(@id)">
<xsl:value-of select="name()"/>
</xsl:if>
<xsl:value-of select="./@id"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</TD>
</TR>
</xsl:template>
</xslStylesheet>
</xslTutorial>