[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

access multiple entries of same tag in single template

Subject: access multiple entries of same tag in single template
From: himanshu padmanabhi <himanshu.padmanabhi@xxxxxxxxx>
Date: Thu, 16 Apr 2009 14:36:26 +0530
 access multiple entries of same tag in single template
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.