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

  • SEARCH
  • Home
  • 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 388735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:47:54+00:00 2026-05-12T15:47:54+00:00

I am new to working with XSLT and am trying to create a pivot

  • 0

I am new to working with XSLT and am trying to create a pivot table using the Muenchian Method (since it appear that IE still doesn’t support XSLT 2.0 I think I’m stuck with this). I am able to get the desired grouping however I am trying to get the sum of an attribute for each group. To do the sum of the attribute can I use the aggregate sum function or do I have to loop through the keys and store the values into a variable? This is what I have so far:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" encoding="UTF-8"/>

<xsl:key name="Person" match="Record" use="@PersonID" />
<xsl:template match="/">
  <html>
  <body>
    <h2>Costs Per Person</h2>
    <table border = "1">
        <thead>
        <tr>
           <th>ID</th>
           <th>Cost</th>
        </tr>
        </thead>
        <tbody>
        <xsl:for-each select="Records/Record[generate-id() = 
         generate-id(key('Person', @PersonID)[1])]">
        <tr>
            <td>
                <xsl:value-of select="@PersonID" />
            </td>

            <td>
                <!-- Sum Of Cost -->
            </td>
        </tr>   
       </xsl:for-each>  
       </tbody>
    </table>
  </body>
  </html>
</xsl:template>
  • 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-12T15:47:54+00:00Added an answer on May 12, 2026 at 3:47 pm

    Easy – you where already there. See full solution below.

    On a different note, I advise against the use of <xsl:for-each> in favor of <xsl:apply-templates>. The code gets a bit longer, but readability and code structure improves, IMHO.

    <xsl:stylesheet 
      version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    >
      <xsl:output method="html" indent="yes" encoding="UTF-8"/>
    
      <xsl:key name="Person" match="Record" use="@PersonID" />
    
      <xsl:template match="/">
        <html>
          <body>
            <h2>Costs Per Person</h2>
            <table border = "1">
              <thead>
                <tr>
                   <th>ID</th>
                   <th>Cost</th>
                </tr>
              </thead>
              <tbody>
                <xsl:apply-templates select="Records/Record" />
              </tbody>
            </table>
          </body>
        </html>
      </xsl:template>
    
      <xsl:template match="Records/Record">
        <xsl:variable name="thisGroup" select"key('Person', @PersonID)" />
    
        <xsl:if test="generate-id() = generate-id($thisGroup[1])">
          <tr>
            <td>
              <xsl:value-of select="@PersonID" />
            </td>
            <td>
              <!-- Sum Of Cost -->
              <xsl:value-of select="sum($thisGroup/@Cost)" />
            </td>
          </tr>   
        </xsl:if>  
      </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I'm pretty new to XSLT's and trying to get my head around using
Still trying to get the navigation control of a new site working the way
I'm trying to write a generic method that can be used to deserialize xml
I'm using web refernce call in new working thread in my application as follow:
I am new to XSLT and have spent hours trying to figure out a
QUESTION: I am trying to create a new XML(filtered XML) depending on the parameters
I am new to XSLT working on XML to XML transformation. I want to
I'm working on XUL and i'm trying to execute XSLT processor function in XUL
I have been working with XSLT lately, but now I got to a new
Right now I am working with XSLT to create a report in XSL-FO. I

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.