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 7788397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:59:12+00:00 2026-06-01T20:59:12+00:00

I need to group by two different elements in my XML using XSLT. Here

  • 0

I need to group by two different elements in my XML using XSLT. Here is sample XML:

<root>
<name>Joe</name>
<classYear>1996</classYear>
<deathDate>September 10, 2010</deathDate>
<monthName>September 2010</deathDate>
<moreInfo></moreInfo>
<link><a href="http://somelink.com">Details available here.</a></link>
</root>
<root>
<name>Sam</name>
<classYear>1981</classYear>
<deathDate>January 1, 2003</deathDate>
<monthName>January 2003</deathDate>
<moreInfo>He played on the baseball team.</moreInfo>
<link><a href="http://anotherlink.com">Details available here.</a></link>
</root>

I need to group by monthName and then classYear within that. I need to sort by monthName, classYear, and then day part of deathDate. If there is only one death announcement for the class year, I want it to display inline and then display block if there are multiple announcements for one class year in the same month.

Here is what I have so far. It groups by monthName successfully but not by classYear.

<xsl:variable name="vMonthNamesCaps" select="'|JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER'"/>
<xsl:for-each select="//monthName[not(. = following::monthName)]">
  <xsl:sort select="string-length(substring-before($vMonthNamesCaps,substring-before(.,' ')))" data-type="number" order="ascending" />
  <H2><xsl:value-of select="."/></H2>
  <xsl:for-each select="//root[monthName=current()]">
    <xsl:sort select="classYear"/>
    <xsl:sort select="substring-after(substring-before(deathDate,', '),' ')" data-type="number" order="ascending" />
    <strong>Class of <xsl:value-of select="classYear"/>:  </strong><span class="name"><xsl:value-of select="name"/></span> died on <xsl:value-of select="deathDate"/>. <xsl:value-of select="moreInfo"/>
    <xsl:choose>
      <xsl:when test='count(link/a) &gt; 0'>
        <xsl:copy-of select="link/a" />
      </xsl:when>
      <xsl:otherwise></xsl:otherwise>
    </xsl:choose>
    <br /><br />

  </xsl:for-each>
</xsl:for-each>
  • 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-06-01T20:59:14+00:00Added an answer on June 1, 2026 at 8:59 pm

    you’ll want to check xsl:key as a simple way to have one or more “groupBy” cursors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that has a group of 3 text_fields. I need two
Given the XML below, I need to group by InputItem and sum the costs
I need to get two summations in the same query based on different criteria.
I have a controller with two different actions, but both need this same code,
I have a project which i need to build in two different configurations. One
I need to synchronize a path animation on two different layers (one is used
I need to return two different results in a single query. When I run
I have a query where I need to pull information from two different dates
I need to compare the final balances of two tables from different clients grouped
I need add a new user group for mediawiki. The new group has more

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.