473,408 Members | 1,875 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,408 software developers and data experts.

How can I use xsl 1.0 for sort by group and output to xml again?

Hi all,

I have xml like these below.

Expand|Select|Wrap|Line Numbers
  1. <Listing>
  2.     <Avail>
  3.         <Field1>aaa</Field1>
  4.         <Field2>800</Field2>
  5.         <Field3>900</Field3>
  6.         <SortValue>20.00</SortValue>
  7.     </Avail>
  8.     <Avail>
  9.         <Field1>aaa</Field1>
  10.         <Field2>800</Field2>
  11.         <Field3>900</Field3>
  12.         <SortValue>10.00</SortValue>
  13.     </Avail>
  14.     <Avail>
  15.         <Field1>bbb</Field1>
  16.         <Field2>1300</Field2>
  17.         <Field3>1500</Field3>
  18.         <SortValue>35.05</SortValue>
  19.     </Avail>
  20.     <Avail>
  21.         <Field1>bbb</Field1>
  22.         <Field2>1300</Field2>
  23.         <Field3>1500</Field3>
  24.         <SortValue>20.80</SortValue>
  25.     </Avail>
  26.     <Avail>
  27.         <Field1>ccc</Field1>
  28.         <Field2>1500</Field2>
  29.         <Field3>1900</Field3>
  30.         <SortValue>40.00</SortValue>
  31.     </Avail>
  32. </Listing>
Then I want to ascending sort "SortValue" within group by "Field1", "Field2" and "Field3" above XML to
new XML output like this below.

Expand|Select|Wrap|Line Numbers
  1. <Listing>
  2.     <Avail>
  3.         <Field1>aaa</Field1>
  4.         <Field2>800</Field2>
  5.         <Field3>900</Field3>
  6.         <SortValue>10.00</SortValue>
  7.     </Avail>
  8.     <Avail>
  9.         <Field1>aaa</Field1>
  10.         <Field2>800</Field2>
  11.         <Field3>900</Field3>
  12.         <SortValue>20.00</SortValue>
  13.     </Avail>
  14.     <Avail>
  15.         <Field1>bbb</Field1>
  16.         <Field2>1300</Field2>
  17.         <Field3>1500</Field3>
  18.         <SortValue>20.80</SortValue>
  19.     </Avail>
  20.     <Avail>
  21.         <Field1>bbb</Field1>
  22.         <Field2>1300</Field2>
  23.         <Field3>1500</Field3>
  24.         <SortValue>35.05</SortValue>
  25.     </Avail>
  26.     <Avail>
  27.         <Field1>ccc</Field1>
  28.         <Field2>1500</Field2>
  29.         <Field3>1900</Field3>
  30.         <SortValue>40.00</SortValue>
  31.     </Avail>
  32. </Listing>
I try to sort my using "SortValue" field but I don't know,
How can I use XSL 1.0 for sort by group?

Thank you very much.
Oct 9 '09 #1
0 1384

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

Similar topics

8
by: Darren Davison | last post by:
given the following DOM snippet; <root> <sub1 foo="4">testing</sub1> <sub1 foo="0">hello</sub1> <sub1 foo="0">world</sub1> <sub1>hello again</sub1> </root> I need to transform with XSL to...
3
by: Tjerk Wolterink | last post by:
I posted my problem earlier, but i simplified the examples, and i know what the cause of the problem is, but i dont know the solution, my xml file: <?xml version="1.0" encoding="ISO-8859-1"?>...
9
by: Raymond Lewallen | last post by:
I have a dataview in which the sort property will not sort the dataview. Here's is a simple scenario similar to what I am doing: Class Foo Private Function Retrieve() As DataView ' Returns a...
11
by: James P. | last post by:
Hello, I have a report with the Priority field is used as sort order and grouping. The problem is the data in this Priority field if sorted in ascending order is: High, Low, and Medium. How...
22
by: Nhmiller | last post by:
Is there a way to do this? Thanks. Neil Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
5
by: Irfan Mumtaz | last post by:
hi, I had posted a question in the group "how to arrange arrays in increasing order" Although i got an answer using IComparable Interface by Harfried ,which is given below. Dim InputArray()() As...
21
by: yeti349 | last post by:
Hi, I'm using the following code to retrieve data from an xml file and populate a javascript array. The data is then displayed in html table form. I would like to then be able to sort by each...
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
5
by: bbembi_de | last post by:
Hello everyone, I have just a little xslt problem: <xsl:for-each-group select="item" group-by="name"> <xsl:if test="contains(name, 'teststring11')"> <xsl:apply-templates...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.