troubleshooting Question

Summation in XSLT

Avatar of Sridhar Lenkala
Sridhar Lenkala asked on
XML* XSLT
7 Comments1 Solution39 ViewsLast Modified:
Hello Experts,

 created an xslt to transform xml to CSV. its working fine but user got back asking me with a modification which i am not sure how to accomplish.

Below is the output I am getting for attached xml. also attached xslt i am using.

Co Code,Batch ID,File #,Reg Hours,O/T Hours,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount
VDT,HRLY0609,138784,31.97,,HOL,8,PDL,1,BER,16,BER,16,PTO,10.27,SIC,16,

New requirement is to add hours for duplicate code. I mean in the above output we have two BER codes in XML with 16 hours each but we want only one BER code in output with 32 hours. same thing applies for other codes aswell but in the example i mentioned there is only BER as duplicate code.

So output I want is  like below.

Co Code,Batch ID,File #,Reg Hours,O/T Hours,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount,Hours 3 Code,Hours 3 Amount
VDT,HRLY0609,138784,31.97,,HOL,8,PDL,1,BER,32,PTO,10.27,SIC,16,

Thanks in advance for help,
MyXSLT.xsl
TextXML.xml
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros