[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Funky Summation

Subject: Funky Summation
From: Nate Austin <naustin@xxxxxxxxxxxxxxx>
Date: Fri, 15 Sep 2000 18:50:16 -0500
summation absolute value
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!


Nate Austin
naustin@xxxxxxxxxxxxxxx
Phone: (612) 277-2523

The opinions expressed are my own and do not reflect those of Decision
Systems, Inc.


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.