xsl-list
[Top] [All Lists]

counting help

2003-10-16 21:43:23
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.

http://personals.yahoo.com.au - Yahoo! Personals
New people, new possibilities. FREE for a limited time.

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



<Prev in Thread] Current Thread [Next in Thread>