Topic: Xml sorting with Xsl Pages that link to <a href="https://ozoneasylum.com/backlink?for=21558" title="Pages that link to Topic: Xml sorting with Xsl" rel="nofollow" >Topic: Xml sorting with Xsl\

 
Author Thread
bertcox
Obsessive-Compulsive (I) Inmate

From:
Insane since: Apr 2004

IP logged posted posted 04-27-2004 09:08 Edit Quote

hello,


I'm using C# to display Xml-data in a datagrid. Now i want the datagrid to be sorted. I heard the best way to sort the xml-file is to use XSLT. I'm new to c#,xml and xslt so i don't really know what to do.
Can someone plz help me?

Thx a lot in advance,

Bert Cox

Cameron
Bipolar (III) Inmate

From: Brisbane
Insane since: Jan 2003

IP logged posted posted 04-27-2004 11:16 Edit Quote

I know nothing about C# yet sorting with XSLT is simple, however it is quite slow.

XSL(T) is almost a programming language in itself. You use an XSL style sheet to "process" an XML file. The XSL file can match data in an XML file using X-Path, which is an XML related expression language (X-Path is used within the XSL file).

Sorting in XSLT is done using the <xsl:for-each> element to match all the children/attributes/whatever and you can specify a sort element inside this to order the results of the for-each. www.w3schools.com has some good tutorials on this.

Although, if you're wanting to do this often throughout the execution of a program, invoking an XSLT processor is going to be rather slow. If *all* you want to do is sort some data, then using XSLT is probably going to be overkill.

You might be better off writing some sort of custom sorting method. I'm not sure what a data grid is (googled it and got a hodge podge of different ASP & .NET crap), but it sounds like some kind of abstract data type like a hash map or a tree, if that's the case then you should be able to implement a simple quick sort algorithm which will be much faster then using XSLT. Chances are someone has already written one for t already, but again, I know nothing about C#, this data-grid thing or the avaliable community support for the language, so I'm just stabing in the dark here.

But again, using XSLT just for sorting a bit fo XML data sounds like overkill, but you're likely to find many other uses for XSLT so I'd encourage you to have a look into it anyhow.

rickindy
Nervous Wreck (II) Inmate

From: Indianapolis, In USA
Insane since: Jan 2002

IP logged posted posted 04-27-2004 14:53 Edit Quote

W3Schools has an example of using the <xsl:sort> tag. It's part of their excellent reference/tutorial

http://www.w3schools.com/xsl/el_sort.asp

HTH

Few problems in life can't be solved by chocolate



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu