This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Funky Summation
Nate Austin wrote:
>
> Greetings. I've thrashed around with a few ideas to no avail, so finally to
> here. Here's the problem:
>
> <record>
> <header>
> <name>ralph</name>
> <dest_acct_no>2222222</dest_acct_no>
> </header>
> <detail>
> <name>george</name>
> <acct_no>123456789</acct_no>
> </detail
> <detail>
> <name>bob</name>
> <acct_no>987654321</acct_no>
> </detail>
> </record>
>
> I have a large number of records in similar fashion to this There is one
> header record and many detail records. I need to compute a checksum of the
> account numbers that is as follows:
>
> If the number is less than 11 digits, pad it on the right with zeros. (ie.
> 12345678900). Take the first 6 digits minus the 2nd 6 digits. Do this for
> the header record and the detail records. The checksum for each detail
> record is computed by taking the absolute value of the value of the header
> record minus the value of the detail record. Add each detail record's
> checksum to come up with a total checksum. The example here would be:
>
> abs((222222 - 20000) - (123456 - 78900)) + abs((222222 - 20000) - (987654 -
> 32100)) + ... = 157666 + 753332 = 910998.
>
> I looked into using sum() to come up with this and a for-each. I couldn't
> work it through to the end either way. If anyone could help it'd be much
> appreciated!
>
AND A BIT MORE GENERAL QUESTION:
Is it possible to implement running counters in pure 100% XSLT, without
using proprietary extensions?
Regards,
Alexey
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list