473,666 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 1393

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

Similar topics

8
3393
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 something like;
3
2454
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"?> <?xml-stylesheet type="text/xsl" href="datastyle.xsl"?> <data xmlns="http://tjerk.com"> <item>a1</item> <item>b2</item>
9
2088
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 DataView with 2 columns and 3 rows Dim ADOHelper As New DAL.ADOHelper Return ADOHelper.GetMyDataview() End
11
3884
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 could I sort it as: Low, Medium, High? Any suggestion is greatly appreciated, James
22
17889
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
1429
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 Integer = _ New Integer()() { _ New Integer() {2, 0, 0}, _ New Integer() {1, 0, 0}, _ New Integer() {6, 0, 0}, _ New Integer() {3, 0, 0} _
21
3198
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 column. Once the array elements are split, what is the best way to sort them? Thank you. //populate data object with data from xml file. //Data is a comma delimited list of values var jsData = new Array(); jsData = {lib: "#field...
48
4456
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 lot faster with both methods using .NET 1.1, that's why I am pretty sure its a (rather serious) bug. Below you can find C# test case that should allow you to reproduce this error, to run it you will need to put 2 data files into current directory...
5
6563
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 select="current-group()"/> </xsl:if> <xsl:if test="contains(name, 'teststring22')"> <xsl:apply-templates select="current-group()"/>
0
8449
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8360
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8784
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8556
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4371
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1777
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.