[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: Fri, 15 Oct 2004 10:16:19 +0200
xsl sort then by
How do I get Only one chapter e.g. chapter="2" instead of getting all chapters
in kombination with implementation above?

-Mike


On Fri, 15 Oct 2004 10:07:34 +0200, Mike G <row.filter@xxxxxxxxx> wrote:
> Yeah, this works with some modification.
> 
> <xsl:apply-templates select="Document[Article/@info = 'main' or
> Article/@filter = 'food']"/>
> 
> thanx!
> 
> -Mike
> 
> On Thu, 14 Oct 2004 15:06:16 +0300, jarno.elovirta@xxxxxxxxx
> 
> 
> <jarno.elovirta@xxxxxxxxx> wrote:
> > Hi,
> >
> > > 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.
> >
> > An Article cannot have two info attributes, thus the above condition can never be true in XML.
> >
> > > 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>
> >
> >  <xsl:template match="Documents">
> >    <xsl:copy>
> >      <xsl:apply-templates select="Document[Article/@info = 'main' and Article/@info = 'sub']"/>
> >    </xsl:copy>
> >  </xsl:template>
> >  <xsl:template match="Document">
> >    <xsl:copy>
> >      <xsl:copy-of select="@*"/>
> >      <xsl:for-each select="Article[@info = 'main']">
> >        <xsl:sort select="@filter ='food'" data-type="number" order="descending"/>
> >        <xsl:sort select="@state" data-type="number"/>
> >        <xsl:copy-of select="."/>
> >      </xsl:for-each>
> >    </xsl:copy>
> >  </xsl:template>
> >
> > I'm not sure exactly how you wanted the info attribute handled, because you desired output doesn't use Articles with "sub" info. Anyhow, this produces the desired output. The
> >
> >  <xsl:sort select="@filter ='food'" data-type="number" order="descending"/>
> >
> > sort condition basically works so that the "@filter = 'food'" expression will either return boolean true or false, which will be cast to number 1 or 0, respectively, and that gives you the sort key value.
> >
> >
> >
> > Cheers,
> >
> > Jarno - Lisa Lashes: Hard Mix
> >
> >
> 
> 
> --
> 
> [row.filter]
> 


-- 

[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.