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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:59:34+00:00 2026-05-12T08:59:34+00:00

I’ve read with interest the techniques available on the web to extract a unique

  • 0

I’ve read with interest the techniques available on the web to extract a unique list of items from a XML file containing duplicates using XSL.

These range into 2 categories:
1) The Muenchian method (example: http://www.jenitennison.com/xslt/grouping/)
2) Or the previous-sibling look-up
These both rely on an XPath expression to select the data to group by.

However, in the XML file that I’m trying to work out, the data is not present “natively” in the XML file. I am using a xsl:template to compute some aggregated data from my elements. And I would like to group based on the aggregated data.

For example I have:

<filmsreview>
    <record><data name='movie'>Star Wars</data><data name='ratings'>John:Good, Mary:Good</data></record>
    <record><data name='movie'>Indiana Jones</data><data name='ratings'>John:Good, Mary:Bad, Helen:Average</data></record>
    <record><data name='movie'>Titanic</data><data name='ratings'>John:Bad, Helen:Good</data></record>
</filmsreview>

I know that the structuration of data is not perfect and that by creating sub-elements I could do something easier, but I cannot change the data source easily, so let’s take this as a challenge.

And I would like to build a recap where I have John’s distinct ratings:
John’s ratings:
Good
Bad

I have a xsl:template that can take a record element and return John’s rating for this record:
Example:

<xsl:template name="get_rating">
   <xsl:param name="reviewer" />
     <!-- I use some string manipulation, and xsl:value-of to return the review for John-->
</xsl:template>

I can just call it under a xsl:for-each to get the exhaustive list of John’s review. But I cannot combine this call with any of the methods to get unique values.

Do I have to use an intermediary XSL to convert my XML file to a more structured way? Or can I do in a single step?

Many thanks
Gerard

  • 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-12T08:59:34+00:00Added an answer on May 12, 2026 at 8:59 am

    Hmm… This should be possible using xslt variables and the nodeset method, perhaps something like this:

    <xsl:variable name="_johnsRatings">
       <xsl:apply-templates select="/" mode="johnsRatings" />
    </xsl:variable>
    <xsl:variable name="johnsRatings" select="msxsl:node-set($_johnsRatings)" />
    
    <xsl:template match="/" mode="johnsRatings">
        <Ratings>
             <xsl:for-each select="/filmsReview/record/data[@name='ratings']">
                  <Rating><xsl:call-template name="get_rating" /></Rating>
             </xsl:for-each>
        </Ratings>
    </xsl:template>
    

    At this point, it should be possible to query the $johnsRatings variable using standard XPath queries, and you can use either of the two methods you mentioned above to retrieve unique values from it…

    Hope that helps

    EDIT:
    I don’t know what XSLT engine you are using, I assumed you have access to the msxsl:node-set() function. However, most XSLT processors have similar methods, so you might have to search around for an equivalent method in your processor

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

Sidebar

Ask A Question

Stats

  • Questions 184k
  • Answers 184k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you want something like this: CSS: div#navBar {… May 12, 2026 at 4:52 pm
  • Editorial Team
    Editorial Team added an answer If I understand you correctly, this should work: SELECT 'There… May 12, 2026 at 4:52 pm
  • Editorial Team
    Editorial Team added an answer What kind of console are you using? If it's derived… May 12, 2026 at 4:52 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS
I am currently running into a problem where an element is coming back from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.