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

Counting elements in parent node

Subject: Counting elements in parent node
From: mxmodi@xxxxxxxxxxxxxxx
Date: Mon, 23 Oct 2000 09:36:59 -0500
count elements in node

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

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.