J
Jody Greening
Transforming with XSLT, Grouping elements until difference found.
I am seeking some help with the following problem, I am fairly new at
XSLT transformations, and my problem may lie in looking at it from a
traditional programming point of view.
I have did quite a bit of searching but have found no answers to my
particular problem... please read below XML for the problem I am
having.
PS: I have no control over the XML I am trying to transform.
--- I have only spaced the lines for clarity ---
<Amounts>
<Amount date="2004-05-30">5290</Amount>
<Amount date="2004-06-30">5290</Amount>
<Amount date="2004-07-30">5300</Amount>
<Amount date="2004-08-30">5300</Amount>
<Amount date="2004-09-30">5290</Amount>
<Amount date="2004-10-30">5290</Amount>
<Amount date="2004-11-30">5290</Amount>
<Amount date="2004-12-30">1000</Amount>
<Amount date="2005-01-30">5290</Amount>
<Amount date="2005-02-28">5300</Amount>
<Amount date="2005-03-30">5290</Amount>
<Amount date="2005-04-30">5290</Amount>
<Amount date="2004-07-30">5300</Amount>
<Amount date="2004-08-30">5300</Amount>
</Amounts>
I am looking to transform the above XML into the below structure
grouping payments with alike ones util there is a different payment
encountered. I also need to inculde a count of the like payments.
Output should look like this: (in the correct order found in the input
stream) I have had limited success with for-each but the problem lies
in the counting of the LIKE elements.
<Payments>
<Payment amount="5290" numpayments="2" />
<Payment amount="5300" numpayments="2" />
<Payment amount="5290" numpayments="3" />
<Payment amount="1000" numpayments="1" />
<Payment amount="5290" numpayments="1" />
<Payment amount="5300" numpayments="1" />
<Payment amount="5290" numpayments="2" />
<Payment amount="5300" numpayments="2" />
</Payments>
Any help would be greatly appreciated.
Jody Greening
jgreening#AT#cyence#DOT#com
I am seeking some help with the following problem, I am fairly new at
XSLT transformations, and my problem may lie in looking at it from a
traditional programming point of view.
I have did quite a bit of searching but have found no answers to my
particular problem... please read below XML for the problem I am
having.
PS: I have no control over the XML I am trying to transform.
--- I have only spaced the lines for clarity ---
<Amounts>
<Amount date="2004-05-30">5290</Amount>
<Amount date="2004-06-30">5290</Amount>
<Amount date="2004-07-30">5300</Amount>
<Amount date="2004-08-30">5300</Amount>
<Amount date="2004-09-30">5290</Amount>
<Amount date="2004-10-30">5290</Amount>
<Amount date="2004-11-30">5290</Amount>
<Amount date="2004-12-30">1000</Amount>
<Amount date="2005-01-30">5290</Amount>
<Amount date="2005-02-28">5300</Amount>
<Amount date="2005-03-30">5290</Amount>
<Amount date="2005-04-30">5290</Amount>
<Amount date="2004-07-30">5300</Amount>
<Amount date="2004-08-30">5300</Amount>
</Amounts>
I am looking to transform the above XML into the below structure
grouping payments with alike ones util there is a different payment
encountered. I also need to inculde a count of the like payments.
Output should look like this: (in the correct order found in the input
stream) I have had limited success with for-each but the problem lies
in the counting of the LIKE elements.
<Payments>
<Payment amount="5290" numpayments="2" />
<Payment amount="5300" numpayments="2" />
<Payment amount="5290" numpayments="3" />
<Payment amount="1000" numpayments="1" />
<Payment amount="5290" numpayments="1" />
<Payment amount="5300" numpayments="1" />
<Payment amount="5290" numpayments="2" />
<Payment amount="5300" numpayments="2" />
</Payments>
Any help would be greatly appreciated.
Jody Greening
jgreening#AT#cyence#DOT#com