P
p0wer
Let's suppose I have this sample document:
<root>
<entry id="1"
<date>2003-08-03</date>
<param_1>5</param_1>
<param_2>10</param_2>
</entry>
<entry id="2">
...
</entry>
</root>
Given some template to apply to this data, firstly I want to sort these
entries according to content of "date" element. Secondly, I would like to
split the result tree into two parts - the documents which are newer than 30
days and the rest, and following that I need to sort these groups according
to value of param_2 and param_1 (in the given order). The code I have tried
looks like this:
<xsl:apply-templates select="entry[number( concat(
substring(Date,1,4),substring(Date,6,2),substring(Date,9,2) ) ) <
($date - $new_days)]">
<xsl:sort select="param_2" order="descending"/>
<xsl:sort select="param_1" order="descending"/>
<xsl:sort select="date" order="descending"/>
</xsl:apply-templates>
But there's some caveat: the data gets sorted by param_2 and if there are
two entries with equal value, they are not sorted further by param_1. The
same applies the level below - if there are two entries with equal values of
param_1, they don't get sorted by date. What's wrong here? How can I make
this work the way I want it to?
I use PHP 4.3.2 with DOM XML.
--
__ .: Radoslaw Loboda :. | Cool stuff !!!
(oo) (e-mail address removed) | --------------------
/ \/ \ | www.tigerhomes.org
`V__V' | www.suncam.tv
<root>
<entry id="1"
<date>2003-08-03</date>
<param_1>5</param_1>
<param_2>10</param_2>
</entry>
<entry id="2">
...
</entry>
</root>
Given some template to apply to this data, firstly I want to sort these
entries according to content of "date" element. Secondly, I would like to
split the result tree into two parts - the documents which are newer than 30
days and the rest, and following that I need to sort these groups according
to value of param_2 and param_1 (in the given order). The code I have tried
looks like this:
<xsl:apply-templates select="entry[number( concat(
substring(Date,1,4),substring(Date,6,2),substring(Date,9,2) ) ) <
($date - $new_days)]">
<xsl:sort select="param_2" order="descending"/>
<xsl:sort select="param_1" order="descending"/>
<xsl:sort select="date" order="descending"/>
</xsl:apply-templates>
But there's some caveat: the data gets sorted by param_2 and if there are
two entries with equal value, they are not sorted further by param_1. The
same applies the level below - if there are two entries with equal values of
param_1, they don't get sorted by date. What's wrong here? How can I make
this work the way I want it to?
I use PHP 4.3.2 with DOM XML.
--
__ .: Radoslaw Loboda :. | Cool stuff !!!
(oo) (e-mail address removed) | --------------------
/ \/ \ | www.tigerhomes.org
`V__V' | www.suncam.tv