This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Calculate balance
- From: Shabbir Rahman <nitol_shabbir at yahoo dot com>
- To: XSL-List at lists dot mulberrytech dot com
- Date: Mon, 11 Mar 2002 05:35:14 -0800 (PST)
- Subject: [xsl] Calculate balance
- Reply-to: xsl-list at lists dot mulberrytech dot com
my xml file is
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="ledgerbook.xsl"?>
<report>
<date>
<currentdate>11-Mar-2002</currentdate>
<startdate>12-dec-02</startdate>
<enddate>12-dec-02</enddate>
</date>
<ledgerbook>
<openingbalance>-2000.0</openingbalance>
<table>
<row>
<ledgerdate>12-DEC-2002</ledgerdate>
<voucher>V1.1.3</voucher>
<costcenter>Head Office</costcenter>
<lccode />
<description />
<amount type="C">1000</amount>
</row>
<row>
<ledgerdate>12-DEC-2002</ledgerdate>
<voucher>V1.1.2</voucher>
<costcenter>Head Office</costcenter>
<lccode />
<description />
<amount type="C">1000</amount>
</row>
<row>
<ledgerdate>12-DEC-2002</ledgerdate>
<voucher>V1.2.1</voucher>
<costcenter />
<lccode />
<description />
<amount type="D">2000</amount>
</row>
<row>
<ledgerdate>12-DEC-2002</ledgerdate>
<voucher>V1.2.2</voucher>
<costcenter />
<lccode />
<description />
<amount type="D">2000</amount>
</row>
</table>
</ledgerbook>
</report>
and my xsl file is
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:variable name="bal"
select="report/ledgerbook/openingbalance"/>
<xsl:template match="/">
<html>
<title>Ledger Book</title>
<body>
<xsl:apply-templates select="report/date"/>
<xsl:apply-templates
select="report/ledgerbook/openingbalance"/>
<table border="0" width="100%" align="center"
cellspacing="4">
<tr>
<th><u>Date</u></th>
<th><u>Voucher No</u></th>
<th><u>Cost Center</u></th>
<th><u>L/C Code</u></th>
<th>Description</th>
<th><u>Dr.</u></th>
<th><u>Cr.</u></th>
<th><u>Balance</u></th>
</tr>
<xsl:for-each select="report/ledgerbook/table/row">
<tr>
<td><xsl:value-of select="ledgerdate"/></td>
<td><xsl:value-of select="voucher"/></td>
<td><xsl:value-of select="costcenter"/></td>
<td><xsl:value-of select="lccode"/></td>
<td><xsl:value-of select="description"/></td>
<xsl:call-template name="amountplace"/>
</tr>
</xsl:for-each>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="2"><b>Closing Balance</b></td>
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="report/date">
<p align="right"><xsl:value-of
select="currentdate"/></p>
<h1>Ledger Book</h1>
<h3>From <xsl:value-of select="startdate"/> To
<xsl:value-of select="enddate"/></h3>
</xsl:template>
<xsl:template
match="report/ledgerbook/openingbalance">
<p align="right"><b><xsl:text>Opening Balance :
</xsl:text> </b> <xsl:value-of select="$bal"/></p>
</xsl:template>
<xsl:template name="amountplace">
<xsl:choose>
<xsl:when test="amount[@type='D']">
<td align="right"><xsl:value-of
select="amount"/></td>
<td align="right"><xsl:text>-</xsl:text></td>
</xsl:when>
<xsl:otherwise>
<td align="right"><xsl:text>-</xsl:text></td>
<td align="right"><xsl:value-of
select="amount"/></td>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
I want to put calculated value in the Blance column
of the table. I am expalining it in the natural
laguage
x=openingbalance
balance[1]=x-debit[1]+credit[1]
balance[2=balance[1]-debit[2]+credit[2]
balance[3]=balance[2]-debit[3]+credit[3]
...
...
can any one give me the solve.
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list