Nic Miloslav     Example 4    KEYWORDS      EXAMPLES      AUTHORS     

// is very common in location paths. When it is used at the beginning of location path, it means: select all nodes in the document of the specified type. (Stylesheet 1). In the middle of a location path it means: select all nodes which appear in a node selected with the first part of location path. (Stylesheet 2


     XML     HOME     XSL 1     XSL 2      
<xslTutorial >
<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>  
</xslTutorial>

     XSL 1     HOME     XML     HTML 1     OUTPUT 1     
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:template match="/">
<xsl:apply-templates select="//BBB"/>
<xsl:apply-templates select="//CCC"/>
<xsl:apply-templates select="//DDD"/>
<xsl:apply-templates select="//AAA"/>
</xsl:template>
<xsl:template match="AAA">
<DIV style="color:navy">
<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:purple">
<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:red">
<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:blue">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
</xsl:stylesheet>

     HTML 1     HOME     XML     XSL 1     OUTPUT 1     
<HTML>
<HEAD> </HEAD>
<BODY>
<DIV style="color:purple">BBB id=b1</DIV>
<DIV style="color:purple">BBB id=b2</DIV>
<DIV style="color:purple">BBB id=b3</DIV>
<DIV style="color:purple">BBB id=b4</DIV>
<DIV style="color:purple">BBB id=b5</DIV>
<DIV style="color:red">CCC id=c1</DIV>
<DIV style="color:red">CCC id=c2</DIV>
<DIV style="color:blue">DDD id=d1</DIV>
<DIV style="color:navy">AAA id=a1</DIV>
<DIV style="color:navy">AAA id=a2</DIV> </BODY> </HTML>

     OUTPUT 1     HOME     XML     XSL 1     HTML 1     
BBB id=b1
BBB id=b2
BBB id=b3
BBB id=b4
BBB id=b5
CCC id=c1
CCC id=c2
DDD id=d1
AAA id=a1
AAA id=a2

     XSL 2     HOME     XML     HTML 2     OUTPUT 2     
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:template match="/">
<xsl:apply-templates select="/xslTutorial/AAA//CCC"/>
<xsl:apply-templates select="/xslTutorial//AAA/BBB//*"/>
</xsl:template>
<xsl:template match="AAA">
<DIV style="color:navy">
<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:purple">
<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:red">
<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:blue">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
</xsl:stylesheet>

     HTML 2     HOME     XML     XSL 2     OUTPUT 2     
<HTML>
<HEAD> </HEAD>
<BODY>
<DIV style="color:red">CCC id=c1</DIV>
<DIV style="color:red">CCC id=c2</DIV>
<DIV style="color:red">CCC id=c2</DIV> </BODY> </HTML>

     OUTPUT 2     HOME     XML     XSL 2     HTML 2     
CCC id=c1
CCC id=c2
CCC id=c2