Re: [xsl] "sum" of "substring"

Subject: Re: [xsl] "sum" of "substring"
From: Larry Kollar <kollar@xxxxxxxxxx>
Date: Sat, 25 Oct 2003 20:20:15 -0400
Colin Simpson wrote:

My problem:
I have a flat text file that has to be transformed into a predetermined XML
file.


Example:
TYPE1Field1AnotherField12.00YetAnotherField445.26FinalField
TYPE1ABCDEFABCDEFGHIJKL45.00ABCDEFGHIJKLMNO123.45ABCDEFGHIJ
TYPE2FieldAnother987.65Final

where the first 5 characters indicate which one of two record layouts it is.

...


I need to total up certain numeric values within the record of a specific
layouts.
For example, I want to total up the values that occupy positions 24 thru 28
from all records of "TYPE1".

MHO, this is really the realm of a flat-text processing program like awk or perl. You have a wonderful XSLT hammer, but you're trying to use it on a screw. Use awk to grind the threads off the screw & make it into a nail that you can pound on with XSLT. :-)

(I would post an entire awk script but it would be off-topic.)

I need to total up certain numeric values within the record of a specific
layouts.
For example, I want to total up the values that occupy positions 24 thru 28
from all records of "TYPE1".
Is there any way of doing this?

An awk script could handle that too. You could create a <total> element containing the sum at the end.

--
Larry Kollar k o l l a r @ a l l t e l . n e t
"The hardest part of all this is the part that requires thinking."
-- Paul Tyson, on xml-doc



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



Current Thread