|
Subject: Re: [xsl] How to sort? From: Mike G <row.filter@xxxxxxxxx> Date: Thu, 14 Oct 2004 13:40:33 +0200 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] How to sort?, Jarno.Elovirta | Thread | RE: [xsl] How to sort?, Jarno.Elovirta |
| Re: [xsl] How to sort?, David Carlisle | Date | RE: [xsl] XSLT Help is needed, AYYALA, PAVITHRAN |
| Month |