Subject: RE: [xsl] How to sort? From: <Jarno.Elovirta@xxxxxxxxx> Date: Fri, 15 Oct 2004 11:22:54 +0300 |
Hi, Most probably the second predicate, i.e. > > > <xsl:for-each select="Article[@info = 'main']"> only processes the main ones. Cheers, Jarno - Velvet Acid Christ: Futile (Resisted mix by Funker Vogt) > -----Original Message----- > From: ext Mike G [mailto:row.filter@xxxxxxxxx] > Sent: 15 October, 2004 11:16 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] How to sort? > > > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to sort?, Mike G | Thread | [xsl] Re: XSL Grouping and Sorting, Mike G |
RE: [xsl] xsl:variable and node lis, Jarno.Elovirta | Date | Re: [xsl] xsl:variable and node lis, Jeni Tennison |
Month |