[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Sorting XML with XSL, output as XML

Subject: RE: Sorting XML with XSL, output as XML
From: Ernst Wolthaus <ernst.wolthaus@xxxxxx>
Date: Mon, 6 May 2002 09:21:59 +0200
xsl sort xml
Dear Joerg (and everyone else),

Thanks very much for the information. It works perfectly. But...

I'm trying to use this algorithm to attach to every possible table with data
islands. That's why I don't want to use node names except in the xsl:sort
part, because I don't know the tagnames in advance.

I've tried it out and I can substitute select="chapter" with select="*".
That seems to work nicely.

Now all I got left is the match="book" statement. I've tried to change this
in match="/" which should select the root but that doesn't seem to work. How
can I select the root statement with the match statement without using the
nodename?

Thanks in advance,
Ernst Wolthaus

-----Original Message-----
From: Joerg Heinicke [mailto:joerg.heinicke@xxxxxx] 
Sent: zaterdag 4 mei 2002 20:35
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Sorting XML with XSL, output as XML


Hello Ernst,

again a identity transformation will help:

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

Then you need to add a special template for the book elements.

<xsl:template match="book">
   <xsl:copy>
     <xsl:apply-templates select="@*"/>
     <xsl:apply-templates select="chapter">
       <xsl:sort select="*[name()=$sortfield]" order="{$sortorder}" />
     </xsl:apply-templates>
   </xsl:copy>
</xsl:template>

Regards,

Joerg

Ernst Wolthaus schrieb:
> Hi all,
> 
> I'm new it this so I hope I'm posting this message the right way.
> Anyway...
> 
> I've got a HTML-pager with a table, with a data island, so the XML 
> data
> is bounded in the table by Datafld and Datasrc. Now I want to sort the 
> XML-data by an XSL-file and a XSL:SORT command. However, this needs to 
> be generic so I can use the same XSL for all kinds of XML, because else 
> I have to make a XSL for every XML.
> 
> Example:
> 	<?xml version="1.0"?>
> 	<book>
> 	<chapter>
> 	<number>2</number>
> 	<title>two</title>
> 	<paragraph>text 2</paragraph>
> 	</chapter>
> 	<chapter>
> 	<number>1</number>
> 	<title>one</title>
> 	<paragraph>text 1</paragraph>
> 	</chapter>
> 	</book>
> 
> How do I sort this data by e.g. Number or by Title in a generic way. 
> It's
> needs to output the "same" XML but sorted like:
> 
> 	<?xml version="1.0"?>
> 	<book>
> 	<chapter>
> 	<number>1</number>
> 	<title>one</title>
> 	<paragraph>text 1</paragraph>
> 	</chapter>
> 	<chapter>
> 	<number>2</number>
> 	<title>two</title>
> 	<paragraph>text 2</paragraph>
> 	</chapter>
> 	</book>
> 
> I know how to sort with xsl:param and <xsl:sort
> select="@*[name()=$sortfield]" order="{$sortorder}" /> but how do I get 
> the XML back like the XML described above...???
> 
> I've spend a lot of this on this so I would greatly appreciate any
> help!!
> 
> Thanks,
> Ernst Wolthaus


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.