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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:08:23+00:00 2026-06-16T06:08:23+00:00

I have an XML file that looks like this example: <Data> <defect> <record-id>1</record-id> <custom-field-value

  • 0

I have an XML file that looks like this example:

<Data>
  <defect>
    <record-id>1</record-id>
    <custom-field-value field-name="Release Version" field-value="1.0"/>
    <custom-field-value field-name="Other info" field-value=""/>
    <custom-field-value field-name="More info" field-value="blah"/>

    <event include-in-release-notes="yes">
      <notes>This is a release note to include</notes>
    </event>

    <event include-in-release-notes="no">
      <notes>This is not a release note</notes>
    </event>
  </defect>

  <defect>
    <record-id>2</record-id>
    <custom-field-value field-name="Release Version" field-value="1.5"/>
    <custom-field-value field-name="Other info" field-value=""/>
    <custom-field-value field-name="More info" field-value="blah"/>

    <event include-in-release-notes="yes">
      <notes>This is a release note to include for 1.5</notes>
    </event>

    <event include-in-release-notes="no">
      <notes>This is not a release note</notes>
    </event>
  </defect>
</Data>

What I’m trying to do is create a release notes document that first sorts and finds all of the unique @field-value values of the elements that have the @field-name equal to “Release Version”. There may be other elements that do not pertain to release version. Here is the output I’m looking for:

Release Version: 1.0
  o This is a release note to include
Release Version: 1.5
  o This is a release note to include for 1.5
Release Verison: x.x
  o one release note
  o another release note

I’ve read up a bunch about the “Muenchian” method and sorting and grouping, but I’m struggling with the fact that I have attributes I need to compare to. Most of the examples I’ve read discuss sorting on elements which seems much more intuitive. And I need to find and sort on multiple attributes, well, my head just starts to explode.

I’ve come up with stylesheets that will give me ALL of the elements that have “Release Version” as the text using:

<xsl:key name="keyMajorReleases" match="custom-field-value" use="@field-name"/>
<xsl:for-each select=key('keyMajorReleases', 'Release Version')">
  <xsl:sort order="descending" data-type="text" select="@field-value"/>

But that gives them ALL to me, not just the unique ones. And then I haven’t figured out how to get the ‘event’ element that has the release note I need to print.

When I’ve tried to use ‘generate-id()’, I only get ONE result, as I guess there is only ONE unique entry with my value to find:

<xsl:for-each select="//custom-field-value[generate-id(.)=generate-id(key('keyMajorReleases', 'Release Version')[1])]">
  • 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-16T06:08:24+00:00Added an answer on June 16, 2026 at 6:08 am

    With your current key…

    <xsl:key name="keyMajorReleases" match="custom-field-value" use="@field-name"/>
    

    You would be grouping custom-field-value elements by field-name, which you would do if you wanted to find the distinct field-name values. However, you want to group by the field value attributes for ‘Release Versions’. This means you need to define your key like so:

    <xsl:key name="keyMajorReleases" match="custom-field-value[@field-name='Release Version']" use="@field-value"/>
    

    With this key, you are matching only on custom-field-value where the field name is ‘Release Version’. You can then use this to get the distinct field values attributes, like so:

    <xsl:apply-templates 
         select="defect/custom-field-value[@field-name='Release Version']
             [generate-id()=generate-id(key('keyMajorReleases', @field-value)[1])]" />
    

    Then to get your release notes for a given release version, you could then use the key again

    <xsl:apply-templates 
       select="key('keyMajorReleases', @field-value)
            /following-sibling::event[@include-in-release-notes='yes']" />
    

    Here is the full XSLT

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" indent="yes"/>
       <xsl:key name="keyMajorReleases" match="custom-field-value[@field-name='Release Version']" use="@field-value"/>
       <xsl:template match="/Data">
          <ul>
             <xsl:apply-templates select="defect/custom-field-value[@field-name='Release Version'][generate-id()=generate-id(key('keyMajorReleases', @field-value)[1])]"/>
          </ul>
       </xsl:template>
    
       <xsl:template match="custom-field-value">
          <li>Release Version: <xsl:value-of select="@field-value"/>
             <ul>
                <xsl:apply-templates select="key('keyMajorReleases', @field-value)/following-sibling::event[@include-in-release-notes='yes']"/>
             </ul></li>
       </xsl:template>
    
       <xsl:template match="event">
          <li>
             <xsl:value-of select="notes"/>
          </li>
       </xsl:template>
    </xsl:stylesheet>
    

    When applied to your sample XML, the following is output

    <ul>
       <li>Release Version: 1.0
           <ul>
              <li>This is a release note to include</li>
           </ul>
       </li>
       <li>Release Version: 1.5
          <ul>
             <li>This is a release note to include for 1.5</li>
          </ul>
       </li>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that looks like the example on this site: http://msdn.microsoft.com/en-us/library/ee223815(v=sql.105).aspx
If I have an XML file that looks like this: <properties> <property> <picture>http://example.com/image1.jpg</picture> <picture>http://example.com/image2.jpg</picture>
I have a XML file, that looks like this inside: <Data> <INFO> .. ...
I have an XML file that looks like this: <SiteMenuItems> <SiteMenuItem text=Home navigateurl=/Default.aspx tooltip=Return
I have a large xml file that looks like this: 20120124 07:30:15.301, saving to
--edited for clarity (hopefully) I have an XML file that looks something like this:
I have an eclipse's .classpath file that looks like this: <?xml version=1.0 encoding=UTF-8?> <classpath>
I have an XML file that looks like <?xml version=1.0> <playlist> <name>My Playlist</name> <song>
I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
I have an XML file that reads like this <abc> <ab>value</ab> <aa>time</aa> <ac>money</ac> </abc>

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.