xsl-list
[Top] [All Lists]

[xsl] access multiple entries of same tag in single template

2009-04-16 05:06:54
students.xml

<?xml version='1.0'?>
<?xml-stylesheet href="students.xsl" type="text/xsl"?>

  <student>
       <name>Himanshu</ABC>
       <addr>ABC</addr>
       <level1>Languages</level1>
       <level2>C</level2>
       <level2>CPP</level2>
       <level2>PERL</level2>
  </student>
  <student>
       <name>Makhu</ABC>
       <addr>PQR</addr>
       <level1>Oracle Database</level1>
  </student>
   <student>
       <name>John</ABC>
       <addr>XYZ</addr>
       <level1>Subjects</level1>
       <level2>CO</level2>
       <level2>CG</level2>
       <level2>MIS</level2>
       <level2>SE</level2>
       <level2>PPL</level2>
       <level2>CN</level2>
  </student>

name,addr and level1 are unique for each student.
level2 count changes for each student.

students.xsl

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="html" />

<xsl:template match="student">
<table><tr><td>
        <UL>
                   <LI><xsl:value-of select="level1" /></LI>
<!--
I want something like this,
                    <xsl:check if level2 entry is there,if it is enter here>
                          <UL>
                               <xsl:for-each till level2 entries are there>     
                                    <LI><xsl:value-of select="level2" /></LI>
                              </xsl:for-each>
                          </UL>
                   </xsl:check if .. ends>
-->

<!--
 So I tried this,but it is not working as expected -->
                  <xsl:if test="level2">
                        <UL>
<!-- <xsl:apply-templates match="level2"> will work,but is there any
other way to write it in this template only -->
                            <xsl:for-each select="//level2">    
                                        <LI><xsl:value-of select="level2" 
/></LI>
                            </xsl:for-each>
                        </UL>
                  </xsl:if>
       <UL>
</td></tr></table>

</xsl:template>
</xsl:stylesheet>

---------------------------------
Thanks and Regards,
Himanshu Padmanabhi

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