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

Re: counting help

Subject: Re: counting help
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 17 Oct 2003 00:36:21 -0700 (PDT)
counting cars
Use:

count(/*/Cars/Car[OutTo 
                 = 
                  /*/Employees/Employee
                              [@DeptName = current()]
                                         /@Name
                 ])


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



---- <goob05@xxxxxxxxxxxx> wrote:

I have the following xml document:
<DBC>
 <Depts>
  <Dept DeptName="Bread">
   <Boss>Bruce</Boss>
   <Owes>1000</Owes>
  </Dept>
  <Dept DeptName="Cake">
   <Boss>Cathy</Boss>
   <Owes>1500</Owes>
  </Dept>
  <Dept DeptName="Finance">
   <Boss>Phil</Boss>
   <Owes>60000</Owes>
  </Dept>
 </Depts>
 <Employees>
  <Employee Name="Bruce" DeptName="Bread"/>
  <Employee Name="Bob" DeptName="Bread"/>
  <Employee Name="Betty" DeptName="Bread"/>
  <Employee Name="Bill" DeptName="Bread"/>
  <Employee Name="Cathy" DeptName="Cake"/>
  <Employee Name="Carol" DeptName="Cake"/>
  <Employee Name="Chris" DeptName="Cake"/>
  <Employee Name="Phil" DeptName="Finance"/>
  <Employee Name="Frank" DeptName="Finance"/>
  <Employee Name="Fred" DeptName="Finance"/>
 </Employees>
 <Cars>
  <Car>
   <CarNr>1</CarNr>
   <Make>Ford</Make>
   <Cost>50</Cost>
   <OutTo>Bob</OutTo>
   <OutOn>17-Feb-2005</OutOn>
  </Car>
  <Car>
   <CarNr>2</CarNr>
   <Make>Ford</Make>
   <Cost>80</Cost>
   <OutTo>Cathy</OutTo>
   <OutOn>17-Feb-2005</OutOn>
  </Car>
  <Car>
   <CarNr>3</CarNr>
   <Make>Mazda</Make>
   <Cost>80</Cost>
  </Car>
  <Car>
   <CarNr>4</CarNr>
   <Make>BMW</Make>
   <Cost>100</Cost>
  </Car>
  <Car>
   <CarNr>5</CarNr>
   <Make>BMW</Make>
   <Cost>200</Cost>
  </Car>
  <Car>
   <CarNr>6</CarNr>
   <Make>BMW</Make>
   <Cost>250</Cost>
   <OutTo>Frank</OutTo>
   <OutOn>4-Feb-2005</OutOn>
  </Car>
  <Car>
   <CarNr>7</CarNr>
   <Make>Benz</Make>
   <Cost>250</Cost>
  </Car>
  <Car>
   <CarNr>8</CarNr>
   <Make>Benz</Make>
   <Cost>350</Cost>
   <OutTo>Phil</OutTo>
   <OutOn>09-Dec-2004</OutOn>
  </Car>
  <Car>
   <CarNr>9</CarNr>
   <Make>Ford</Make>
   <Cost>150</Cost>
  </Car>
  <Car>
   <CarNr>10</CarNr>
   <Make>Honda</Make>
   <Cost>150</Cost>
  </Car>
 </Cars>
 <Today>19-Feb-2005</Today>
</DBC>

and need to output the following:

Department    Owes    Cars Out
--------------------------------
Bread        1000        1
Cake         1500        1
Finance     60000        2


So far i have the following xsl.
I'm having trouble trying to calculate the cars out
column.
Here's my xsl document so far:

<?xml version="1.0"?>
<!-- edited with XMLSPY v5 rel. 4 U
(http://www.xmlspy.com) by Registred (Registred) -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1">
<xsl:template match=" / ">
  <html>
   <title>Liability Report</title>
   <center>
    <table border="7">
     <tr>
      <th colspan="5" align="left">Departmental
Liability Report</th>
     </tr>
     <body style="margin-left: 50px;
     margin-top: 100px;
  font-family: Comic Sans MS;
  background-color: #ffffbb;
  color: maroon">
      <tr>
       <th>Dept</th>
       <th>Owes</th>
       <th>Cars Out</th>
       <xsl:for-each
select="//DBC/Depts/Dept/@DeptName">
        <tr>
         <td><xsl:value-of
select="../@DeptName"/></td>
         <td><xsl:value-of select="../Owes"/></td>

        </tr>

     </xsl:for-each> 
      </tr>
     </body>
    </table>
   </center>
  </html>
 </xsl:template>
</xsl:stylesheet>

Any help would be much appreciated.



__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • counting help
    • Gavin Dornbusch - Fri, 17 Oct 2003 00:43:31 -0400 (EDT)
      • <Possible follow-ups>
      • Dimitre Novatchev - Fri, 17 Oct 2003 03:37:01 -0400 (EDT) <=

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.