This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Variable scope issue.


Hi!

I will appritiate if anybody could spare some time and reply to this query.

The XML structure looks like:
<List>
     <reports>
          <Currency>CA</Currency>
          <ChequeDate>05-16-2001</ChequeDate>
          <DepositAmt>12.0</DepositAmt>
     </reports>
     <reports>
          <Currency>CA</Currency>
          <ChequeDate>05-16-2001</ChequeDate>
          <DepositAmt>14.0</DepositAmt>
     </reports>
     <reports>
          <Currency>CA</Currency>
          <ChequeDate>05-20-2001</ChequeDate>
          <DepositAmt>18.0</DepositAmt>
     </reports>
     <reports>
          <Currency>CA</Currency>
          <ChequeDate>05-20-2001</ChequeDate>
          <DepositAmt>16.0</DepositAmt>
     </reports>
     <reports>
          <Currency>US</Currency>
          <ChequeDate>05-16-2001</ChequeDate>
          <DepositAmt>12.0</DepositAmt>
     </reports>
     <reports>
          <Currency>US</Currency>
          <ChequeDate>05-16-2001</ChequeDate>
          <DepositAmt>14.0</DepositAmt>
     </reports>
</List>

And the requirement is to generate the report like this:

Currency: CA
Date      Amount
05-16-2001     12.0
05-16-2001     14.0
SubTotal  26.0

Date      Amount
05-20-2001     18.0
05-20-2001     16.0
SubTotal  34.0
Total          60.0

Currency: US
Date      Amount
05-16-2001     12.0
05-16-2001     14.0
SubTotal  26.0
Total          26.0

The XML data is presorted.( wrt currency type and date )

So for this I have a subTotal variable which I declared before the
template. And when I loop within reports, after printing the first subTotal
correctly in the second (and subsequent) subTotals it prints incorrect
values.
And the reason is that I try to reset the variable to zero when a new date
entry is found. But to my surprise the variable is not resseted.

Please suggest what is a workaround.

Thanks and Regards,
Nitin Jain


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]