473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to to group sort and combine XML data?

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <catalog>
  3.     <cd>
  4.         <title>Empire Burlesque</title>
  5.         <artist>Bob Dylan</artist>
  6.         <country>USA</country>
  7.         <company>Columbia</company>
  8.         <price>10.90</price>
  9.         <year>1985</year>
  10.     </cd>
  11.     <cd>
  12.         <title>Hide your heart</title>
  13.         <artist>Bonnie Tyler</artist>
  14.         <country>UK</country>
  15.         <company>CBS Records</company>
  16.         <price>9.90</price>
  17.         <year>1988</year>
  18.     </cd>
  19.     <cd>
  20.         <title>Greatest Hits</title>
  21.         <artist>Dolly Parton</artist>
  22.                 <country>USA</country>
  23.         <company>RCA</company>
  24.         <price>9.90</price>
  25.         <year>1982</year>
  26.     </cd>
  27.     <cd>
  28.         <title>Still got the blues</title>
  29.         <artist>Dolly Parton</artist>
  30.         <country>UK</country>
  31.         <company>Virgin records</company>
  32.         <price>10.20</price>
  33.         <year>1991</year>
  34.     </cd>
  35.     <cd>
  36.         <title>Eros</title>
  37.         <artist>Gary Moore</artist>
  38.         <country>EU</country>
  39.         <company>BMG</company>
  40.         <price>9.90</price>
  41.         <year>1997</year>
  42.     </cd>
  43.     <cd>
  44.         <title>One night only</title>
  45.         <artist>Bee Gees</artist>
  46.         <country>UK</country>
  47.         <company>Polydor</company>
  48.         <price>10.90</price>
  49.         <year>1998</year>
  50.     </cd>
  51. </catalog>
*********************
I need the output to look like:Group by Artist, sort by title
Dolly Parton
1. Greatest Hits, USA, RCA, 9.90, 1982
2. Still got the Blues, UK, Virgin Records, 10.20, 1991

BeeGees
1. One night only, UK, Polydor, 10.90, 1998

etc
Oct 27 '10 #1
1 1692
jkmyoung
2,057 Expert 2GB
http://www.jenitennison.com/xslt/gro...muenchian.html
Expand|Select|Wrap|Line Numbers
  1. <xsl:key name="cd-by-artist" match="cd" use="artist" />
  2.  
  3. <xsl:template match="catalog">
  4.     <xsl:for-each select="cd[count(. | key('cd-by-artist', artist)[1]) = 1]">
  5.         <xsl:sort select="artist" />
  6.         <xsl:value-of select="artist" />,<br />
  7.         <xsl:for-each select="key('cd-by-artist', artist)">
  8.             <xsl:sort select="title" />
  9.             <xsl:value-of select="title" /> (<xsl:value-of select="other information etc... " />)<br />
  10.         </xsl:for-each>
  11.     </xsl:for-each>
  12. </xsl:template>
  13.  
Oct 27 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: deko | last post by:
I need to import dates from a linked table then export them out as text to an Excel spreadsheet. The problem is the dates need to be in ascending order when I dump them out to Excel - and there's...
8
by: sudhir | last post by:
hi My application receives daily records, I need to show it sorted if needed...but I am not finding the right direction to do that...
1
by: Lars E. | last post by:
Hi all. I am trying to combine data from 2 tables in one datagridview. I have tables: "Customer" and "CustomerContact". I want to display Customer information (displaying all fields in...
2
by: John | last post by:
Hi, Is there a way to sort a datareader based on certain columns? TIA
1
by: sakurasyi | last post by:
hi there... i have some questions. Did anyone know how to sort a group of data in xml file? i means, i have retrieve the xml data, but it not arrange properly. For example: <number> ...
0
by: =?Utf-8?B?SmltSGVhdmV5?= | last post by:
I have written code to sort data retrieved from a database when using a Datagrid, but now I am wanting to sort a XML datasource and I'm not sure what I need to do this. I am guessing that I want...
0
by: srikantmatihali | last post by:
Hi all, I want to change the value of N in Group Sort Expert window (In Crystal Reports) explicitly from text box using some c# application. This will help us in devloping dynamic crystal...
2
by: lucoin | last post by:
Hi,everyboday. I'm designing a human management system. this system will be used by the branches separately. but the head office should combine the data from different branches. due to some...
2
by: shravanti88 | last post by:
How do I sort the data/records in the DataList using VB.NET? I am working on a .NET project and using a SQL database.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.