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

Incrementaing a variable in for-each

Subject: Incrementaing a variable in for-each
From: Surendranath reddy <reddy.surendra@xxxxxxxxx>
Date: Wed, 1 Dec 2004 12:31:33 +0530
surendranath reddy
Hi Gyes i found many people facing problems from incrementing a
varible in for-each.Here i have a sample.Hope this is helpful for all.

The xml structure is--

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="dcsWeekly.xsl"?>
<page>
<dcsCalenderView>
<visits>
<weekday>
<dayno>1</dayno>
<day>sunday March 14,2004</day>
<ps>
<id>1</id>
<visitStartTime>9:30 AM </visitStartTime>
<visitEndTime>10:30 AM</visitEndTime>
<firstName>John</firstName>
<mi>King</mi>
<lastName>Rojer</lastName>
<caretype>Bath</caretype>
</ps>
<ps>
<id>1</id>
<visitStartTime>11:30 AM </visitStartTime>
<visitEndTime>11:30 AM</visitEndTime>
<firstName>John</firstName>
<mi>King</mi>
<lastName>Rojer</lastName>
<caretype>Bath</caretype>
</ps>
<avilable>
<free>3:30 Pm - 12:00Am </free>
<free>1:30 Pm - 2:00Am </free>
</avilable>
</weekday>
<weekday>
<dayno>2</dayno>
<day>Monday March 15,2004</day>
<ps>
<id>2</id>
<visitStartTime>9:30 AM </visitStartTime>
<visitEndTime>10:30 AM </visitEndTime>
<firstName>Aranold</firstName>
<mi>James</mi>
<lastName>Donald</lastName>
<caretype>Happy</caretype>
</ps>
<avilable>
<free>3:30 Pm - 12:00Am </free>
<free>1:30 Pm - 2:00Am </free>
</avilable>
</weekday>
<weekday>
<dayno>3</dayno>
<day>Tuesday March 16,2004</day>
<ps>
<id>3</id>
<visitStartTime>9:30 AM </visitStartTime>
<visitEndTime>10:30 AM </visitEndTime>
<firstName>Wanted</firstName>
<mi>Balde</mi>
<lastName>John</lastName>
<caretype>Sleep</caretype>
</ps>
<avilable>
<free>3:30 Pm - 12:00Am </free>
<free>1:30 Pm - 2:00Am </free>
</avilable>
</weekday>
<weekday>
<dayno>4</dayno>
<day>Wednesday March 17,2004</day>
<ps>
<id>4</id>
<visitStartTime>9:30 AM </visitStartTime>
<visitEndTime>10:30 AM </visitEndTime>
<firstName>Nani</firstName>
<mi>Reddy</mi>
<lastName>Surendra</lastName>
<caretype>Eat</caretype>
</ps>
<avilable>
<free>3:30 Pm - 12:00Am </free>
<free>1:30 Pm - 2:00Am </free>
</avilable>
</weekday>
<weekday>
<dayno>5</dayno>
<day>Thrusday March 18,2004</day>
<ps>
<id>5</id>
<visitStartTime>9:30 AM </visitStartTime>
<visitEndTime>10:30 AM </visitEndTime>
<firstName>Murthy</firstName>
<mi>Son</mi>
<lastName>Johnson</lastName>
<caretype>ActIng</caretype>
</ps>
<avilable>
<free>3:30 Pm - 12:00Am </free>
<free>1:30 Pm - 2:00Am </free>
</avilable>
</weekday>
<weekday>
<dayno>6</dayno>
<day>Friday March 19,2004</day>
<ps>
<id>6</id>
<visitStartTime>09:30 Am</visitStartTime>
<visitEndTime>10:30 Am</visitEndTime>
<firstName>Ron</firstName>
<mi>JohnSon</mi>
<lastName>Soin</lastName>
<caretype>JumpIng</caretype>
</ps>
<avilable>
<free>3:30 Pm - 12:00Am </free>
<free>1:30 Pm - 2:00Am </free>
</avilable>
</weekday>
<weekday>
<dayno>7</dayno>
<day>Saterday March 20,2004</day>
<ps>
<id>7</id>
<visitStartTime>09:30 Am</visitStartTime>
<visitEndTime>10:30 Am</visitEndTime>
<firstName>Hendry</firstName>
<mi>Hill</mi>
<lastName>Mario</lastName>
<caretype>Bath</caretype>
</ps>
<avilable>
<free>3:30 Pm - 12:00Am </free>
<free>1:30 Pm - 2:00Am </free>
</avilable>
</weekday>
</visits>
<dcs>
<id>2</id>
<firstName>Peeter</firstName>
<mi>Rojer</mi>
<lastName>Federer</lastName>
</dcs>
</dcsCalenderView>
</page>


The xsl is--

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:variable name="index" select="0"/>
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="..\common\preferences.css"/>
<title>Tasks</title>
<script>
</script>
</head>
<body>
<form>
<table width="100%" height="7%" border="0" class="pageheader">
<tr>
<td class="pageheader" width="100%" align="center">Dcs Weeky Calender</td>
</tr>
</table>
<br/>
<table border="1" width="70%" align="center">
<tr>
<td>
<table border="0" width="100%" align="center">
<tr>
<td class="label" width="100%" align="left" colspan="2" border="1">
<b>Dcs Name</b>&#32;&#32;&#32;&#32;&#32;::
<xsl:value-of select="/page/dcsCalenderView/dcs/firstName"/>&#32;
<xsl:value-of select="/page/dcsCalenderView/dcs/mi"/>&#32;
<xsl:value-of select="/page/dcsCalenderView/dcs/lastName"/>&#32;
</td>
</tr>
<tr>
<td width="30%" align="left">
<b>
<A href="JavaScript:funcRefresh()">&lt;&lt; Previous Week</A>
</b>
</td>
<td width="40%" align="center">
<xsl:value-of select="page/dcsCalenderView/visits/weekday/vist/day"/>
</td>
<td width="30%" align="right">
<b>
<A href="JavaScript:funcRefresh()">Next Week &gt;&gt;</A>
</b>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" width="100%" align="center">
<xsl:call-template name="Iterator">
<xsl:with-param name="Count" select="7"/>
<xsl:with-param name="index" select="0"/>
</xsl:call-template>
</table>
</td>
</tr>
</table>
<table align="center" class="tab">
<tr>
<td>
<input type="button" Name="Close" Value="Close"/>
</td>
</tr>
</table>
<br/>
<table width="100%" height="7%" border="0" class="footer">
<tr>
<td class="footer" width="100%" align="center">Copyright 2004,
LoginSoft Inc,VA</td>
</tr>
</table>
</form>
</body>
</html>
</xsl:template>
<xsl:template name="Iterator">
<xsl:param name="Count"/>
<xsl:param name="index"/>
<tr>
<xsl:call-template name="weeklycal">
<xsl:with-param name="index" select="$index+2"/>
</xsl:call-template>
</tr>
<xsl:if test="$Count > 1">
<xsl:call-template name="Iterator">
<xsl:with-param name="Count" select="$Count - 1"/>
<xsl:with-param name="index" select="$index+2"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="weeklycal">
<xsl:param name="index"/>
<td width="50%" valign="top">
<table width="100%">
<xsl:for-each select="page/dcsCalenderView/visits/weekday[dayno=$index - 1]">
<tr>
<td class="listheadings" align="center">
<xsl:value-of select="day"/>
</td>
</tr>
</xsl:for-each>
<xsl:for-each select="page/dcsCalenderView/visits/weekday[dayno=$index - 1]/ps">
<tr>
<td class="tab">
<i>
<u>
<xsl:value-of select="caretype"/>
</u>
</i>
</td>
</tr>
<tr>
<td class="tab">
<xsl:value-of select="firstName"/>&#32;&#32;&#32;,
<xsl:value-of select="lastName"/>&#32;&#32;&#32;--
<xsl:value-of select="visitStartTime"/>&#32;&#32;&#32;To
<xsl:value-of select="visitEndTime"/>&#32;&#32;&#32;
</td>
</tr>
</xsl:for-each>
<xsl:for-each select="page/dcsCalenderView/visits/weekday[dayno=$index]">
<tr>
<td class="tab">aaaaaa<xsl:copy-of select="avilable"/></td>
</tr>
</xsl:for-each>	
</table>
</td>
<td width="50%" valign="top">
<table width="100%">
<xsl:for-each select="page/dcsCalenderView/visits/weekday[dayno=$index]">
<tr>
<td class="listheadings" align="center">
<xsl:value-of select="day"/>
</td>
</tr>
</xsl:for-each>
<xsl:for-each select="page/dcsCalenderView/visits/weekday[dayno=$index]/ps">
<tr>
<td class="tab">
<i>
<u>
<xsl:value-of select="caretype"/>
</u>
</i>
</td>
</tr>
<tr>
<td>
<xsl:value-of select="firstName"/>&#32;&#32;&#32;,
<xsl:value-of select="lastName"/>&#32;&#32;&#32;--
<xsl:value-of select="visitStartTime"/>&#32;&#32;&#32;To
<xsl:value-of select="visitEndTime"/>&#32;&#32;&#32;
</td>
</tr>
</xsl:for-each>
<xsl:for-each select="page/dcsCalenderView/visits/weekday[dayno=$index]/avilable">
<tr>
<td class="tab"><xsl:value-of select="free"/></td>
</tr>
</xsl:for-each>	
</table>
</td>
</xsl:template>
</xsl:stylesheet>

-- 
K.SurendraNath Reddy
LoginSoft India,
Ameerpet,
Hyderabad-28.

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.