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

Re: How to sort?

Subject: Re: How to sort?
From: Mike G <row.filter@xxxxxxxxx>
Date: Thu, 14 Oct 2004 13:40:33 +0200
sort filter elements xslt
Thanx.

I have one more question regarding sorting.
It's a bit more advanced then this sorting algorithm tough.

What I do now, is choose all Article elements that contain info="main"
and info="sub" attributes and then sort everything by state="n"
attribute.

Now, after altering XML so the it looks like this:

Note! 
filter="" attribute is removed from Document-elements.
state="" attribute is removed from Article-elements that contain filter="food".

<?xml version="1.0"?>

<Documents>
       <Document title="1" chapter="i" href="file1.xml">
               <Article title="1.1" info="sub" filter="drink" state="1"/>
               <Article title="1.2" info="main" filter="food"/>
        <Article title="1.3" info="main" filter="drink" state="2"/>
       </Document>
       <Document title="2" chapter="ii" href="file2.xml">
               <Article title="2.1" info="main" filter="drink" state="1"/>
               <Article title="2.1" info="sub" filter="drink" state="3"/>
               <Article title="2.2" info="main" filter="food"/>
       </Document>
       <Document title="3" chapter="1" href="file2.xml">
               <Article title="3.1" info="sub" filter="drink" state=""/>
               <Article title="3.2" info="child" filter="" state="8"/>
       </Document>
       <Document title="4" chapter="2" href="file2.xml">
               <Article title="3.1" info="sub" filter="drink" state=""/>
               <Article title="3.2" info="main" filter="food"/>
       </Document>
</Documents>

Is it possible to implement an sorting option that enables Article
elements where filter="food" to be placed on the top of the Article
list, that is giving them higher priority in sort than the previous
value of state="n".

so the XML output will look like:

<?xml version="1.0"?>
<Documents>
	<Document title="1" chapter="i" href="file1.xml" filter="food">
		<Article title="1.2" info="main" filter="food"/>
		<Article title="1.3" info="main" filter="drink" state="2"/>
	</Document>

	<Document title="2" chapter="ii" href="file2.xml" filter="drink">
    	               <Article title="2.2" info="main" filter="food"/>
    	               <Article title="2.1" info="main" filter="drink" state="1"/>
	</Document>

	<Document title="4" chapter="2" href="file2.xml" filter="">
		<Article title="3.2" info="main" filter="food"/>
	</Document>
</Documents>

regards,

.M

On Thu, 14 Oct 2004 14:18:16 +0300, jarno.elovirta@xxxxxxxxx
<jarno.elovirta@xxxxxxxxx> wrote:
> Hi,
> 
> > what i also wanted to add is an option to filter by two parameters
> > instead of one:
> >
> > now:
> > <xsl:apply-templates select="Documents/Document[Article/@info
> > = 'main']"/>
> >
> > Would like to choose all article-elements where info="main"
> > or info="sub".
> 
> E.g.
> 
> <xsl:apply-templates select="Documents/Document[Article[@info  = 'main' or @info = 'sub']]"/>
> 
> Cheers,
> 
> Jarno - Lisa Lashes: Hard Mix
> 
> 


-- 

[row.filter]

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.