This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Count Nodes
- To: xsl-list at mulberrytech dot com
- Subject: Count Nodes
- From: mxmodi at duke-energy dot com
- Date: Thu, 19 Oct 2000 12:17:29 -0500
- Reply-To: xsl-list at mulberrytech dot com
Hi,
I have the following XML.
<Employees>
<Employee>
<EmpName>Maulik Modi</EmpName>
<EmpUserId>mxmodi</EmpUserId>
<TimeSheets>
<TimeSheet>
<BeginWeek>10/01/2000</BeginWeek>
<EndWeek>10/07/2000</EndWeek>
<WeeklyTotal>40</WeeklyTotal>
<DETMHours>40</DETMHours>
<OtherHours>0</OtherHours>
</TimeSheet>
<TimeSheet>
<BeginWeek>10/08/2000</BeginWeek>
<EndWeek>10/14/2000</EndWeek>
<WeeklyTotal>40</WeeklyTotal>
<DETMHours>35</DETMHours>
<OtherHours>5</OtherHours>
</TimeSheet>
</TimeSheets>
</Employee>
<Employee>
<EmpName>Jeff Damukaitis</EmpName>
<EmpUserId>jddamukaitis</EmpUserId>
<TimeSheets>
<TimeSheet>
<BeginWeek>10/01/2000</BeginWeek>
<EndWeek>10/07/2000</EndWeek>
<WeeklyTotal>42</WeeklyTotal>
<DETMHours>40</DETMHours>
<OtherHours>2</OtherHours>
</TimeSheet>
<TimeSheet>
<BeginWeek>10/08/2000</BeginWeek>
<EndWeek>10/14/2000</EndWeek>
<WeeklyTotal>45</WeeklyTotal>
<DETMHours>35</DETMHours>
<OtherHours>10</OtherHours>
</TimeSheet>
</TimeSheets>
</Employee>
</Employees>
A snippet of the xsl is as follows:
<xsl:template match="/">
<xsl:apply-templates select="//Employee" >
<xsl:sort select="EmpName"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="Employee">
<xsl:attribute name="id">r<xsl:value-of select="position()"/>c1</xsl:attribute>
<table>
<tr>
<xsl:apply-templates select="TimeSheets/TimeSheet" />
</tr>
</table>
</xsl:template>
<xsl:template match="TimeSheet">
<xsl:choose>
<xsl:when test="rownumber=1">
<td>
do this...
</td>
</xsl:when>
<xsl:when test="rownumber=2">
<td>
do this...
</td>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:template>
I am trying to keep a count of the rownumber and pass it down as each one is picked up. And I am having trouble with that. Could anyone throw any
suggestions.
Thanks,
Maulik
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list