[xsl] xsl grouping help

Subject: [xsl] xsl grouping help
From: "Vanessa Pacheco" <vssequeira@xxxxxxxxx>
Date: Fri, 8 Feb 2008 15:21:10 -0500
Hello,

I just joined this group a minute ago, so I hope I'm sending this
message to the right address. I'm a newbie and hence struggling :-(

I need help with grouping. I have the following xml file structure

<!-- Begin xml file -->
<Client>
   <PersonID>
         <PersonIDNum>1290</PersonIDNum>
   </PersonID>
   <Program>
             <ClientHistory>
                    <IncomeCashSource>
                                <a>1</a>
                                <b>1.1</b>
                                <c>
                                     <d>1.3</d>
                                </c>
                    </IncomeCashSource>
                    <IncomeCashSource>
                                <a>2</a>
                                <b>2.1</b>
                                <c>
                                     <d>2.3</d>
                                </c>
                    </IncomeCashSource>
                    <IncomeCashSource>
                                <a>2</a>
                                <b>2.1</b>
                                <c>
                                     <d>2.3</d>
                                </c>
                    </IncomeCashSource>
             </ClientHistory>
   </Program>
   <Program>
             <ClientHistory>
                    <IncomeCashSource>
                                <a>1</a>
                                <b>1.1</b>
                                <c>
                                     <d>1.3</d>
                                </c>
                    </IncomeCashSource>
                    <IncomeCashSource>
                                <a>2</a>
                                <b>2.1</b>
                                <c>
                                     <d>2.3</d>
                                </c>
                    </IncomeCashSource>
                    <IncomeCashSource>
                                <a>3</a>
                                <b>3.1</b>
                                <c>
                                     <d>3.3</d>
                                </c>
                    </IncomeCashSource>
             </ClientHistory>
   </Program>
</Client>
<Client>
   <PersonID>
         <PersonIDNum>1291</PersonIDNum>
   </PersonID>
   <Program>
             <ClientHistory>
                    <IncomeCashSource>
                                <a>1</a>
                                <b>1.1</b>
                                <c>
                                     <d>1.3</d>
                                </c>
                    </IncomeCashSource>
                    <IncomeCashSource>
                                <a>2</a>
                                <b>2.1</b>
                                <c>
                                     <d>2.3</d>
                                </c>
                    </IncomeCashSource>
                    <IncomeCashSource>
                                <a>4</a>
                                <b>4.1</b>
                                <c>
                                     <d>4.3</d>
                                </c>
                    </IncomeCashSource>
             </ClientHistory>
   </Program>
   <Program>
             <ClientHistory>
                    <IncomeCashSource>
                                <a>1</a>
                                <b>1.1</b>
                                <c>
                                     <d>1.3</d>
                                </c>
                    </IncomeCashSource>
                    <IncomeCashSource>
                                <a>2</a>
                                <b>2.1</b>
                                <c>
                                     <d>2.3</d>
                                </c>
                    </IncomeCashSource>
                    <IncomeCashSource>
                                <a>3</a>
                                <b>3.1</b>
                                <c>
                                     <d>3.3</d>
                                </c>
                    </IncomeCashSource>
             </ClientHistory>
   </Program>
</Client>
<!-- End xml file -->

I have to group similar 'IncomeCashSource' records (having values of
<a>, <d> the same), within and across Programs for a single Client.
The resulting file should look something like this

<Clients>
  <Client>
     <Id>1290</Id>
     <IncomeCashSource>
               <a>1</a>
               <b>1.1</b>
               <c>
                    <d>1.3</d>
               </c>
     </IncomeCashSource>
     <IncomeCashSource>
               <a>3</a>
               <b>3.1</b>
               <c>
                    <d>3.3</d>
               </c>
     </IncomeCashSource>
  </Client>
  <Client>
     <Id>1291</Id>
     <IncomeCashSource>
            <a>1</a>
            <b>1.1</b>
            <c>
                 <d>1.3</d>
            </c>
      </IncomeCashSource>
     <IncomeCashSource>
             <a>2</a>
             <b>2.1</b>
             <c>
                <d>2.3</d>
             </c>
     </IncomeCashSource>
     <IncomeCashSource>
             <a>4</a>
             <b>4.1</b>
             <c>
                <d>4.3</d>
             </c>
     </IncomeCashSource>
     <IncomeCashSource>
             <a>3</a>
             <b>3.1</b>
             <c>
               <d>3.3</d>
             </c>
     </IncomeCashSource>
  </Client>
</Clients>

Please help. I'm exhausted and frustrated after trying for 2 days and
coming up with nothing
~Vanessa

Current Thread