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

Sort xml and write to xml

Hi , I have an xml file with below data,and would like to sort this
based on the classname. I did try some xsl but not much use.

<?xml version="1.0" encoding="UTF-8"?>
<document>
<ObjectDataForm classname="AC" displayname="ACL">
<ObjectMenu name="ACb" menuFileName="AC.xml"/>
<property name="dName" display="NE" swingType="JLabel"/>
<property name="name" display="Name" swingType="JLabel"/>
<property name="aclCfgTblACLID" swingType="JLabel"/>
</ObjectDataForm>
<ObjectDataForm classname="A13" displayname="A13">
<ObjectMenu name="A13" menuFileName="A13.xml"/>
<property name="AName" display="NE" swingType="JLabel"/>
<property name="name" display="Name"swingType="JLabel"/>
</ObjectDataForm>
</document>

Thanks a lot for reading and ...
Devah

Jul 20 '05 #1
2 1216


gd****@gmail.com wrote:
Hi , I have an xml file with below data,and would like to sort this
based on the classname. I did try some xsl but not much use.

<?xml version="1.0" encoding="UTF-8"?>
<document>
<ObjectDataForm classname="AC" displayname="ACL">
<ObjectMenu name="ACb" menuFileName="AC.xml"/>
<property name="dName" display="NE" swingType="JLabel"/>
<property name="name" display="Name" swingType="JLabel"/>
<property name="aclCfgTblACLID" swingType="JLabel"/>
</ObjectDataForm>
<ObjectDataForm classname="A13" displayname="A13">
<ObjectMenu name="A13" menuFileName="A13.xml"/>
<property name="AName" display="NE" swingType="JLabel"/>
<property name="name" display="Name"swingType="JLabel"/>
</ObjectDataForm>
</document>


You can use XSLT alike the following

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="xml" encoding="UTF-8" indent="yes" />

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>

<xsl:template match="document">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="ObjectDataForm">
<xsl:sort select="@classname" data-type="text" order="ascending" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Thanks... it works like charm :)

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: googleboy | last post by:
I didn't think this would be as difficult as it now seems to me. I am reading in a csv file that documents a bunch of different info on about 200 books, such as title, author, publisher, isbn,...
13
by: Gram | last post by:
Hello, Can anyone help out with a bubble sort for strings using ASP? I have a text file of words id like to sort and count. Thanks in advance for any help. Gram.
4
by: Johan | last post by:
Hi, Why does my vector not sort. What I understand is you have to overload the < operator, but that does not work. see code below Thanks Johan
34
by: Mark Kamoski | last post by:
Hi-- Please help. I need a code sample for bubble sort. Thank you. --Mark
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
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...
25
by: Rainmaker | last post by:
Hi, Can anyone tell me an efficient algorithm to sort an array of strings? Keep in mind that this array is HUGE and so the algorithm should me efficient enough to deal with it. Thanks
6
by: Les Juby | last post by:
I need to extract records from a database subject to conditions and only thereafter give the users the choice of which fields to sort the results on. In this situation I can't write back to a...
5
by: jason735 | last post by:
Hi, I've got the following problem. I have to sort x*y elements which are in one file. I can use only an array for x elements and floor tmp files which can be read only forward. Thanks for...
3
by: raylopez99 | last post by:
This is an example of using multiple comparison criteria for IComparer/ Compare/CompareTo for List<and Array. Adapted from David Hayden's tutorial found on the net, but he used ArrayList so the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
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...

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.