[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Counting elements in parent node
Subject: Counting elements in parent node From: mxmodi@xxxxxxxxxxxxxxx Date: Mon, 23 Oct 2000 09:36:59 -0500 |
Hi, I am trying to count the number of times the <TimeSheet> element appears in the following XML. The code for the variable I have defined is shown after that and how I call it from the xsl:template. I want to count the number of <TimeSheet> elements in the source tree and capture it whenever I call the <xsl:template match="Employee"> WHat I do get is the total number of unique Employees. That's not what I want. I do get the unique number of <TimeSheet> from the source tree when I define the variable in the <xsl:template match ="TimeSheet">. I am sure this is easy for someone who has done it before. I went through the FAQ but could not find anything similar. Your help is appreciated. Thanks. XML file: <Employees> <Employee> <EmpName>some name</EmpName> <EmpUserId>someid</EmpUserId> <TimeSheets> <TimeSheet> <BeginWeek>10/01/2000</BeginWeek> <EndWeek>10/07/2000</EndWeek> <WeeklyTotal>40</WeeklyTotal> </TimeSheet> <TimeSheet> <BeginWeek>10/08/2000</BeginWeek> <EndWeek>10/14/2000</EndWeek> <WeeklyTotal>40</WeeklyTotal> </TimeSheet> </TimeSheets> </Employee> <Employee> <EmpName>employee 2</EmpName> <EmpUserId>someid-2</EmpUserId> <TimeSheets> <TimeSheet> <BeginWeek>10/01/2000</BeginWeek> <EndWeek>10/07/2000</EndWeek> <WeeklyTotal>40</WeeklyTotal> </TimeSheet> <TimeSheet> <BeginWeek>10/08/2000</BeginWeek> <EndWeek>10/14/2000</EndWeek> <WeeklyTotal>40</WeeklyTotal> </TimeSheet> </TimeSheets> </Employee> </Employees> XSL file: ... <xsl:template match="Employee"> <xsl:variable name="weekselected"> <xsl:number from="child::TimeSheets/TimeSheet" level="any"/> </xsl:variable> ...(some instructions) <xsl:value-of select="$weekselected" /> ...(some instructions) <xsl:apply-templates select="TimeSheets/TimeSheet" /> ...(some instructions) </xsl:template> <xsl:template match="TimeSheet"> <xsl:variable name="weekselected"> <xsl:number level="any" /> </xsl:variable> ...(some instructiuons) </xsl:template> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: versions and forwards compatibi, Kay Michael | Thread | RE: Counting elements in parent nod, Kay Michael |
Re: matching elements only once, Michael Hoffmann | Date | RE: How to pad space to a text node, Nate Austin |
Month |