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

Merge Similar data nodes using XSL

Subject: Merge Similar data nodes using XSL
From: Sunder Rajan <arun_9033@xxxxxxxxx>
Date: Sun, 15 Feb 2009 23:02:37 -0800 (PST)
 Merge Similar data nodes using XSL
Hi All,

I have posted this after a bit of research and being new to XSLT.

There were similar clarifications in the past(FAQ) that helped me to move
however I would appreciate if any one can suggest me if I am heading in the
right direction.

1. Here is the XML sampple
<Contribution>
         <AccountID>100</AccountID>
         <AccountIDPub>173</AccountIDPub>
         <EmployeeSurname>XXXX</EmployeeSurname>
         <EmployeeFirstName>Sharon</EmployeeFirstName>
         <EmployeeDOB>07/12/1955</EmployeeDOB>
         <DateLastPaidTo>02/01/2009</DateLastPaidTo>
         <ContributionType>Comp Emp</ContributionType>
         <ContributionAmount>400.0</ContributionAmount>
      </Contribution>
<Contribution>
         <AccountID>100</AccountID>
         <AccountIDPub>173</AccountIDPub>
         <EmployeeSurname>XXXX</EmployeeSurname>
         <EmployeeFirstName>Sharon</EmployeeFirstName>
         <EmployeeDOB>07/12/1955</EmployeeDOB>
         <DateLastPaidTo>02/01/2009</DateLastPaidTo>
         <ContributionType>Personal</ContributionType>
         <ContributionAmount>200.0</ContributionAmount>
      </Contribution>

2. Key is <AccountIDPub> in the above nodes

3. The <ContributionType> can have 5 variations value(1,2,3,4,5)
   The XML shows only 2 <ContributionType> it can have uptil 5.
   The other I set them 0 for display (please see below)

The XSL I have written at the moment displays this as follows

AcNo. Name      DOB     Comp Emp   Volu   Salary  Personal Spouse Total
------------------------------------------------------------------------
173   Sharon 07/12/1955 400.0      0        0        0      0    400.0
173   Sharon 07/12/1955   0        0       0       200.0    0    200.0

What would be the ideal way to get an output in a single row?
(Including adding the total)

AcNo. Name     DOB        Comp Emp  Volu  Salary Personal Spouse  Total
-------------------------------------------------------------------------
173  Sharon 07/12/1962     400.0     0       0    200.0      0    600.0

1. Should this be merged into a single XML first and then displayed in
a loop I guess I might need to do this in 2 passes...?

I understand that I can use a key (AcNo) and iterate, wasn't sure if there
were cleaner approach.

Any pointers appreciated....

Regards
Sunder


      Make Yahoo!7 your homepage and win a trip to the Quiksilver
Pro. Find out more

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.