XML – Limit the number of sorting results of the for-Each cycle XSL

I am trying to see if it is possible to have a for-each loop setup in an XSL file that passes through many nodes, but I want it to return only the first three results, for example



80


77


96


69

Then use for similar to the following -each loop:




But the problem is, If I do something like:
< xsl: for-each select = "/course/ unit [position()& lt; = 3]">
It will grab the first 3 nodes and then It sorts, which is not what I need, I want it to get the 3 highest marks and return these nodes to display information instead of sorting the results after they have gone through all the loops. I am sure there is an easy way to do This is achieved using templates, so any tips will be very welcome.

use< p>






I am trying to see if it is possible to have a for-each loop setup in an XSL file that goes through many nodes, but I want to make It only returns the first three results, such as



80


77


96


69

< p>Then use a for-each loop similar to the following:




But the problem is, if I do something like this:
< xsl: for-each select = "/course / unit [position()& lt; = 3]">
It will Grab the first 3 nodes and then sort it, which is not what I need, I want it to get the 3 highest marks and return these nodes to display the information, instead of sorting the results after they have gone through all the cycles. I'm sure there is an easy way to achieve this without using templates, so any hints will be very welcome.

Use

< /p>






Leave a Comment

Your email address will not be published.