Hello, it's been a few weeks since my last post, and I have come far since then but have got bogged with the treatment of variables in xsl.
I have xml data that looks like this:
<record num="3">
<Header>03</Header>
<DrCr>400011111111</DrCr>
<date>015</date>
<BankCode>-2480646</BankCode>
<extr1>100</extr1>
<extr2>2449398</extr2>
<extr3>23</extr3>
<extr5>400</extr5>
<extr6>47721117</extr6>
<extr7>2</extr7>
<extr9>900</extr9>
<extr10>1463</extr10>
<extr13>901</extr13>
<extr14>000</extr14>
</record>
<record num="4">
<Header>16</Header>
<DrCr>399</DrCr>
<Amount>30000</Amount>
<BankCode>AGN</BankCode>
<agent>133120</agent>
<Narration>1</Narration>
....
<record num="30">
<Header>03</Header>
<DrCr>400033333333</DrCr>
<date>015</date>
<BankCode>9927637</BankCode>
<extr1>100</extr1>
<extr2>8126809</extr2>
<extr3>3</extr3>
<extr5>400</extr5>
<extr6>71966500</extr6>
<extr7>3</extr7>
<extr9>900</extr9>
<extr10>000</extr10>
<extr13>901</extr13>
<extr14>000</extr14>
</record>

What I am needing is to find the first <record> that has a <Header> of 03, then add all the <Amounts> of the records from after that record to the next point that has a <Header> of 03 again. I have managed this with a non-recursive template, which is fine.
Where I have trouble is when I wish to get a total for all <Amounts> (with Headers =16 or 30) in the file, but this total has to deduct one group of <records> that has a particular <DrCr>. I try to set this total in a template, but I cannot make the total (that I fill to a variable) carry back to my main template.
Perhaps it is a question of persistence? I am unsure how variables persist from "lower" level templates to higher ones.
If anyone has worked on a similar design, I'd be interested to hear how you handled such an issue.