Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Incrementaing a variable in for-each

From: Surendranath reddy <reddy.surendra@--------->
To:
Date: 12/1/2004 7:02:00 AM
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.


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent