xsl-list
[Top] [All Lists]

Re: How to sort?

2004-10-14 04:40:33
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(_dot_)elovirta(_at_)nokia(_dot_)com
<jarno(_dot_)elovirta(_at_)nokia(_dot_)com> 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[(_at_)info  = 'main' 
or @info = 'sub']]"/>

Cheers,

Jarno - Lisa Lashes: Hard Mix



--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--




-- 

[row.filter]


<Prev in Thread] Current Thread [Next in Thread>