I have a problem where I am attempting to transform some data but at the end of the process I need to know how many segements have been created as part of the transformation process.
Ex: I have data where I can have a random # of child packages per shipment (each shipment consists of 1 or more child packages).
<PACKAGE id=1 shipment=A>
<PACKAGE id=2 shipment=A>
<PACKAGE id=3 shipment=A>
<PACKAGE id=4 shipment=B>
<PACKAGE id=5 shipment=C>
<PACKAGE id=6 shipment=C>
The situation is for every shipment I create an element like:
And for each pacakge I have to create sub-element.
<PACKAGE id=1 /><PACKAGE id=2 /><PACKAGE id=3 /></SHIPMENT>
I need a total count of the elements I've created computed something like this:
Number of shipment elements+((Number of Package elements)*2)+2
To create a final footer like: <SHIPMENTSUMMARY elementcount=## />
Hereien lies the problem. A simple counter I could increment (in ANY programming language) would make quick work of this problem. But is XSLT I'm not seeing a way to solve the same problem. I'm hoping someone will recognize the opertunity to use parent:sibling or something grouping by shipment id's to get correct counts. Otherwise I have to scrap and start over.
Thanks. An instant "A" to anyone that even sends me along the correct path.