Hi there,
I also used sorting to get the maximum values - the top three, to be specific.
But I have two issues:
1. I have to change the commands to also consider negative values - sorting should be done using absolute values.
Is this possible with the sort function? Or do I have to take a different approach?
2. I currently have a sub-optimal approach, as I use the code below six times in a row to create variables holding the top three and the resp. values.
(The important part of) the XML file looks like this:
Code:
<arrayLine Name="abc">
<arrayField Name="F1">13.491</arrayField>
<arrayField Name="F2">12.023</arrayField>
<arrayField Name="F3">1.676</arrayField>
<arrayField Name="F4">-33.884</arrayField>
<arrayField Name="F5">11.592</arrayField>
<arrayField Name="F6">9.291</arrayField>
<arrayField Name="F7">1.743</arrayField>
</arrayLine>
<arrayLine Name="xyz">
<arrayField Name="F1">21.433</arrayField>
<arrayField Name="F2">4.326</arrayField>
<arrayField Name="F3">12.891</arrayField>
<arrayField Name="F4">0.150</arrayField>
<arrayField Name="F5">10.471</arrayField>
<arrayField Name="F6">23.803</arrayField>
<arrayField Name="F7">14.555</arrayField>
</arrayLine>
...
I have to get the top three values for a given "Fn" from all arrayLine's and the names of the resp. arrayLine's.
In the example code above, it would be
for F1:
topOne = xyz
topOneValue = 21.433
topTwo = abc
topTwoValue = 13.491
for F4:
topOne = abc
topOneValue = -33.884
topTwo = xyz
topTwoValue = 0.150
The corresponding code snippet for getting topOne:
Code:
<xsl:variable name="topOne">
<xsl:for-each select="arrayLine/arrayField[@Name=$currentFactor]">
<xsl:sort data-type="number" order="descending"/>
<xsl:if test="position()=1">
<xsl:value-of select="../@Name"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
($currentFactor gets iterated from F1 to F7)
Could you please give me advise how to do this?
Thanks in advance! :)
Cheers,
Dennis
P.S.: Is it possible to only take a fixed number of digits after the decimal point?