Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6174431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:45:07+00:00 2026-05-23T23:45:07+00:00

I am not that bright in XSL. I have an XML as below: <?xml

  • 0

I am not that bright in XSL.
I have an XML as below:

<?xml version="1.0" ?>
    <accountitem>
         <Entry_Date>2011-06-24T00:00:00-05:00</Entry_Date>
         <Contract>4570000010</Contract>
         <Account>0</Account>
         <general_desc>Systematic Withdrawal</general_desc>
         <net>1108.3700</net>
         <gross>1108.3700</gross>
         <Person_Name>WHITEY HOUSE</Person_Name>
         <Last_Name>HOUSE</Last_Name>
         <agent_name>BROWN, JACK</agent_name>
         <Legal_Verb>N</Legal_Verb>
         <Payeename>NONE</Payeename>
         <Closed_Flag>0</Closed_Flag>
    </accountitem>
    <accountitem>
         <Entry_Date>2011-06-24T00:00:00-05:00</Entry_Date>
         <Contract>4570000010</Contract>
         <Account>0</Account>
         <general_desc>Systematic Withdrawal</general_desc>
         <net>1108.3700</net>
         <gross>1196.5400</gross>
         <Person_Name>WHITEY HOUSE</Person_Name>
         <Last_Name>HOUSE</Last_Name>
         <agent_name>BROWN, JACK</agent_name>
         <Legal_Verb>N</Legal_Verb>
         <Payeename>NONE</Payeename>
         <Closed_Flag>0</Closed_Flag>       
    </accountitem>
    <accountitem>
         <Entry_Date>2011-06-20T00:00:00-05:00</Entry_Date>
         <Contract>4570000009</Contract>
         <Account>0</Account>
         <general_desc>Systematic Withdrawal</general_desc>
         <net>798.4038</net>
         <gross>901.5600</gross>
         <Person_Name>WHITEY HOUSE</Person_Name>
         <Last_Name>HOUSE</Last_Name>
         <agent_name>BROWN, JACK</agent_name>
         <Legal_Verb>N</Legal_Verb>
         <Payeename>NONE</Payeename>
         <Closed_Flag>0</Closed_Flag>
    </accountitem>
    <accountitem>
         <Entry_Date>2011-06-20T00:00:00-05:00</Entry_Date>
         <Contract>4570000009</Contract>
         <Account>0</Account>
         <general_desc>Systematic Withdrawal</general_desc>
         <net>798.4038</net>
         <gross>901.5600</gross>
         <Person_Name>WHITEY HOUSE</Person_Name>
         <Last_Name>HOUSE</Last_Name>
         <agent_name>DUCK, DONALD Q</agent_name>
         <Legal_Verb>N</Legal_Verb>
         <Payeename>NONE</Payeename>
         <Closed_Flag>0</Closed_Flag>
    </accountitem>
    <accountitem>
         <Entry_Date>2011-06-20T00:00:00-05:00</Entry_Date>
         <Contract>4570000009</Contract>
         <Account>0</Account>
         <general_desc>Systematic Withdrawal</general_desc>
         <net>800.3800</net>
         <gross>820.3400</gross>
         <Person_Name>WHITEY HOUSE</Person_Name>
         <Last_Name>HOUSE</Last_Name>
         <agent_name>BROWN, JACK</agent_name>
         <Legal_Verb>N</Legal_Verb>
         <Payeename>NONE</Payeename>
         <Closed_Flag>0</Closed_Flag>
    </accountitem>
    <accountitem>
         <Entry_Date>2011-06-20T00:00:00-05:00</Entry_Date>
         <Contract>4570000009</Contract>
         <Account>0</Account>
         <general_desc>Systematic Withdrawal</general_desc>
         <net>800.3800</net>
         <gross>820.3400</gross>
         <Person_Name>WHITEY HOUSE</Person_Name>
         <Last_Name>HOUSE</Last_Name>
         <agent_name>DUCK, DONALD Q</agent_name>
         <Legal_Verb>N</Legal_Verb>
         <Payeename>NONE</Payeename>
         <Closed_Flag>0</Closed_Flag>
    </accountitem>

I want it to be converted it as below:

 <?xml version="1.0" ?>
 <accountitem>
    <Entry_Date>2011-06-24T00:00:00-05:00</Entry_Date>
    <Contract>4570000010</Contract>
    <Account>0</Account>
    <general_desc>Systematic Withdrawal</general_desc>
    <net>1108.3700</net>
    <gross>1108.3700</gross>
    <Person_Name>WHITEY HOUSE</Person_Name>
    <Last_Name>HOUSE</Last_Name>
    <agent_name>BROWN, JACK</agent_name>
    <Legal_Verb>N</Legal_Verb>
    <Payeename>NONE</Payeename>
    <Closed_Flag>0</Closed_Flag>
 </accountitem>
 <accountitem>
    <Entry_Date>2011-06-24T00:00:00-05:00</Entry_Date>
    <Contract>4570000010</Contract>
    <Account>0</Account>
    <general_desc>Systematic Withdrawal</general_desc>
    <net>1108.3700</net>
    <gross>1196.5400</gross>
    <Person_Name>WHITEY HOUSE</Person_Name>
    <Last_Name>HOUSE</Last_Name>
    <agent_name>BROWN, JACK</agent_name>
    <Legal_Verb>N</Legal_Verb>
    <Payeename>NONE</Payeename>
    <Closed_Flag>0</Closed_Flag>
 </accountitem>
 <accountitem>
    <Entry_Date>2011-06-20T00:00:00-05:00</Entry_Date>
    <Contract>4570000009</Contract>
    <Account>0</Account>
    <general_desc>Systematic Withdrawal</general_desc>
    <net>798.4038</net>
    <gross>901.5600</gross>
    <Person_Name>WHITEY HOUSE</Person_Name>
    <Last_Name>HOUSE</Last_Name>
    <agent_name>BROWN, JACK; DUCK, DONALD Q</agent_name>
    <Legal_Verb>N</Legal_Verb>
    <Payeename>NONE</Payeename>
    <Closed_Flag>0</Closed_Flag>
 </accountitem>
 <accountitem>
    <Entry_Date>2011-06-20T00:00:00-05:00</Entry_Date>
    <Contract>4570000009</Contract>
    <Account>0</Account>
    <general_desc>Systematic Withdrawal</general_desc>
    <net>800.3800</net>
    <gross>820.3400</gross>
    <Person_Name>WHITEY HOUSE</Person_Name>
    <Last_Name>HOUSE</Last_Name>
    <agent_name>BROWN, JACK; DUCK, DONALD Q</agent_name>
    <Legal_Verb>N</Legal_Verb>
    <Payeename>NONE</Payeename>
    <Closed_Flag>0</Closed_Flag>
 </accountitem>

or in short, I want the agent_name to be concatenated based on contract, account, net, gross combination.

My current XSL is like below:

           <?xml version="1.0" ?>
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:key name="kContractAccountNetGross" match="accountitem" use="concat(contract,account,format-number(net, '$#,###.00'),format-number(gross, '$#,###.00'))"/>

      <xsl:template match="accountitem">
      <xsl:variable name="agentInfo">
       <xsl:choose>
         <xsl:when test="count(key('kContractAccountNetGross',concat(contract,account,format-number(net, '$#,###.00'),format-number(gross, '$#,###.00')))) > 1">
           <xsl:value-of select="concat(agent_name,';',accountitem/agent_name)"/>
         </xsl:when>
         <xsl:otherwise>
           <xsl:value-of select="agent_name"/>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <xsl:choose>
       <xsl:when test="count(key('kContractAccountNetGross',concat(contract,account,format-number(net, '$#,###.00'),format-number(gross, '$#,###.00')))) = 1">
         <tr>
           <xsl:attribute name="class">
             <xsl:choose>
               <xsl:when test="position() mod 2=0">
                 <xsl:text>altItem     </xsl:text>
               </xsl:when>
               <xsl:otherwise>
                 <xsl:text>item     </xsl:text>
               </xsl:otherwise>
             </xsl:choose>
           </xsl:attribute>
           <xsl:attribute name="onmouseover">
             <xsl:text>this.className='mouseover'     </xsl:text>
           </xsl:attribute>
           <xsl:attribute name="onmouseout">
             <xsl:choose>
               <xsl:when test="position() mod 2=0">
                 <xsl:text>this.className='altItem'     </xsl:text>
               </xsl:when>
               <xsl:otherwise>
                 <xsl:text>this.className='item'     </xsl:text>
               </xsl:otherwise>
             </xsl:choose>
           </xsl:attribute>
           <xsl:attribute name="rowid">
             <xsl:value-of select="position()"/>
           </xsl:attribute>
           <td class="date">
             <xsl:attribute name="colName">
               <xsl:text>date     </xsl:text>
             </xsl:attribute>
             <xsl:value-of select="concat(substring(Entry_Date,6,2),'/', substring(Entry_Date,9,2), '/',substring(Entry_Date,1,4))" />
           </td>
           <td class="contract">
             <xsl:attribute name="colName">
               <xsl:text>contract     </xsl:text>
             </xsl:attribute>
             <xsl:choose>
               <xsl:when test="Closed_Flag = 1">
                 <xsl:value-of select="Contract"/>
               </xsl:when>
               <xsl:otherwise>
                 <a>
                   <xsl:attribute name="href">
                     <xsl:text>?hash=1&amp;contract=     </xsl:text>
                     <xsl:value-of select="Contract"/>
                     <xsl:text>&amp;account=     </xsl:text>
                     <xsl:value-of select="Account"/>
                   </xsl:attribute>
                   <xsl:value-of select="Contract"/>
                 </a>
               </xsl:otherwise>
             </xsl:choose>

           </td>
           <td class="account" colName="account">
             <xsl:if test="not($showAccount)">
               <xsl:attribute name="style">display:none     </xsl:attribute>
             </xsl:if>
             <xsl:if test="Account!=0">
               <xsl:value-of select='Account'/>
             </xsl:if>
           </td>
           <td class="tblOwner">
             <xsl:attribute name="colName">
               <xsl:text>owner     </xsl:text>
             </xsl:attribute>
             <xsl:value-of select='Person_Name'/>
           </td>
           <td class="tblOwner">
             <xsl:attribute name="colName">
               <xsl:text>Financial Advisor     </xsl:text>
             </xsl:attribute>
             <xsl:value-of select='$agentInfo'/>
           </td>
           <td class="general_desc">
             <xsl:attribute name="colName">
               <xsl:text>general_desc     </xsl:text>
             </xsl:attribute>
             <xsl:value-of select='general_desc'/>
           </td>
           <td align="right" class="value">
             <xsl:attribute name="colName">
               <xsl:text>net     </xsl:text>
             </xsl:attribute>
             <xsl:value-of select="format-number(net, '$#,###.00')"/>
           </td>
           <td align="right" class="value">
             <xsl:attribute name="colName">
               <xsl:text>gross     </xsl:text>
             </xsl:attribute>
             <xsl:value-of select="format-number(gross, '$#,###.00')"/>
           </td>
           <xsl:if test="Payeename!='NONE'">
             <td class="general_desc">
               <xsl:attribute name="colName">
                 <xsl:text>Payeename     </xsl:text>
               </xsl:attribute>
               <xsl:value-of select='Payeename'/>
             </td>
           </xsl:if>
         </tr>
       </xsl:when>
     </xsl:choose>
   </xsl:template>
 </xsl:stylesheet>

I selected only the XSL section applicable for the transformation. Any thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:45:09+00:00Added an answer on May 23, 2026 at 11:45 pm

    This is just an example to show you how to do what you want. The main point here is application of Meunchian method to perform grouping. I’ve minimized in the transform the produced output so that you can easily see that the wanted result is obtained.

    NOTE XML is case sensitive. Your current key is not built properly.

    <xsl:stylesheet version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
        <xsl:output indent="yes"/>
    
        <xsl:key name="k-accounts" match="accountitem" 
            use="concat(Contract,Account,format-number(net, '$#,###.00'),format-number(gross, '$#,###.00'))"/>
    
        <xsl:template match="so">
            <xsl:apply-templates select="accountitem
                [generate-id()
                = generate-id(key('k-accounts', concat(Contract,Account,format-number(net, '$#,###.00'),format-number(gross, '$#,###.00')))
                [1])]"/>
        </xsl:template>
    
        <xsl:template match="accountitem">
            <xsl:copy>
                <xsl:copy-of select="Contract|Account|net|gross"/>
                <agent_name>
                    <xsl:value-of select="agent_name"/>
                    <xsl:apply-templates select="key('k-accounts',
                        concat(Contract,Account,format-number(net, '$#,###.00'),format-number(gross, '$#,###.00')))/agent_name
                        [.!=current()/agent_name]"
                        mode="agent_name"/>
                </agent_name>
            </xsl:copy>
        </xsl:template>
    
        <xsl:template match="agent_name" mode="agent_name">
            <xsl:value-of select="concat('; ',.)"/>
        </xsl:template>
    
    </xsl:stylesheet>
    

    Given this input (slightly modified to make it well formed):

    <so>
        <accountitem>
            <Entry_Date>2011-06-24T00:00:00-05:00</Entry_Date>
            <Contract>4570000010</Contract>
            <Account>0</Account>
            <general_desc>Systematic Withdrawal</general_desc>
            <net>1108.3700</net>
            <gross>1108.3700</gross>
            <Person_Name>WHITEY HOUSE</Person_Name>
            <Last_Name>HOUSE</Last_Name>
            <agent_name>BROWN, JACK</agent_name>
            <Legal_Verb>N</Legal_Verb>
            <Payeename>NONE</Payeename>
            <Closed_Flag>0</Closed_Flag>
        </accountitem>
        <accountitem>
            <Entry_Date>2011-06-24T00:00:00-05:00</Entry_Date>
            <Contract>4570000010</Contract>
            <Account>0</Account>
            <general_desc>Systematic Withdrawal</general_desc>
            <net>1108.3700</net>
            <gross>1196.5400</gross>
            <Person_Name>WHITEY HOUSE</Person_Name>
            <Last_Name>HOUSE</Last_Name>
            <agent_name>BROWN, JACK</agent_name>
            <Legal_Verb>N</Legal_Verb>
            <Payeename>NONE</Payeename>
            <Closed_Flag>0</Closed_Flag>       
        </accountitem>
        <accountitem>
            <Entry_Date>2011-06-20T00:00:00-05:00</Entry_Date>
            <Contract>4570000009</Contract>
            <Account>0</Account>
            <general_desc>Systematic Withdrawal</general_desc>
            <net>798.4038</net>
            <gross>901.5600</gross>
            <Person_Name>WHITEY HOUSE</Person_Name>
            <Last_Name>HOUSE</Last_Name>
            <agent_name>BROWN, JACK</agent_name>
            <Legal_Verb>N</Legal_Verb>
            <Payeename>NONE</Payeename>
            <Closed_Flag>0</Closed_Flag>
        </accountitem>
        <accountitem>
            <Entry_Date>2011-06-20T00:00:00-05:00</Entry_Date>
            <Contract>4570000009</Contract>
            <Account>0</Account>
            <general_desc>Systematic Withdrawal</general_desc>
            <net>798.4038</net>
            <gross>901.5600</gross>
            <Person_Name>WHITEY HOUSE</Person_Name>
            <Last_Name>HOUSE</Last_Name>
            <agent_name>DUCK, DONALD Q</agent_name>
            <Legal_Verb>N</Legal_Verb>
            <Payeename>NONE</Payeename>
            <Closed_Flag>0</Closed_Flag>
        </accountitem>
        <accountitem>
            <Entry_Date>2011-06-20T00:00:00-05:00</Entry_Date>
            <Contract>4570000009</Contract>
            <Account>0</Account>
            <general_desc>Systematic Withdrawal</general_desc>
            <net>800.3800</net>
            <gross>820.3400</gross>
            <Person_Name>WHITEY HOUSE</Person_Name>
            <Last_Name>HOUSE</Last_Name>
            <agent_name>BROWN, JACK</agent_name>
            <Legal_Verb>N</Legal_Verb>
            <Payeename>NONE</Payeename>
            <Closed_Flag>0</Closed_Flag>
        </accountitem>
        <accountitem>
            <Entry_Date>2011-06-20T00:00:00-05:00</Entry_Date>
            <Contract>4570000009</Contract>
            <Account>0</Account>
            <general_desc>Systematic Withdrawal</general_desc>
            <net>800.3800</net>
            <gross>820.3400</gross>
            <Person_Name>WHITEY HOUSE</Person_Name>
            <Last_Name>HOUSE</Last_Name>
            <agent_name>DUCK, DONALD Q</agent_name>
            <Legal_Verb>N</Legal_Verb>
            <Payeename>NONE</Payeename>
            <Closed_Flag>0</Closed_Flag>
        </accountitem>
    </so>
    

    The following output (minimized to show that correct results are achieved) is obtained:

    <accountitem>
       <Contract>4570000010</Contract>
       <Account>0</Account>
       <net>1108.3700</net>
       <gross>1108.3700</gross>
       <agent_name>BROWN, JACK</agent_name>
    </accountitem>
    <accountitem>
       <Contract>4570000010</Contract>
       <Account>0</Account>
       <net>1108.3700</net>
       <gross>1196.5400</gross>
       <agent_name>BROWN, JACK</agent_name>
    </accountitem>
    <accountitem>
       <Contract>4570000009</Contract>
       <Account>0</Account>
       <net>798.4038</net>
       <gross>901.5600</gross>
       <agent_name>BROWN, JACK; DUCK, DONALD Q</agent_name>
    </accountitem>
    <accountitem>
       <Contract>4570000009</Contract>
       <Account>0</Account>
       <net>800.3800</net>
       <gross>820.3400</gross>
       <agent_name>BROWN, JACK; DUCK, DONALD Q</agent_name>
    </accountitem>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a narrow header in corporate colour, bright red, with the content below
Not that I'm doing something like that, but I am kind of interested how
Not that it is seriously burdensome to type :My_custom_foobar() instead of just :my_custom_foobar() but
Not that I'm trying to prevent 'View Source' or anything silly like that, but
Not that I would ever need to do this, but I want to understand
Not that level of failure indeed. I just completed the 4 part tutorial from
Not that it matters strictly, and maybe I just don't yet fully understand how
Please not that I fully understand this is a dumb ass idea, but its
I'm not that up on VB.NET, the application I'm working on was not written
I am not that hot at regular expressions and it has made my little

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.