Hey Michael, I completely understanding your confusion. I actually reread my post and it looks like I mistakenly copied in the wrong name for the nodes in the "desired result"; it should have said "rank" node, not "top-player" node. I've updated all of my posts with code to reflect the proper names.
Regardless, let me break down the components of the object that you're confused about. So, for the rank node that I'm trying to create at the bottom of the file, here are the components:
Snippet of XML where the data is coming from for the first rank node:
Code:
<pass y="500" t="1">
<name value="mike"/>
<name-id id="1115"/>
</pass>
Desired result:
Code:
<rank position="1" player-id="1115" name="mike" run-y="" run-t="" pass-y="500" pass-t="1" receive-y="" receive-t=""/>
position => position()
id => name-id/@id
name =>name/@value
pass-y => pass/@y
pass-t => pass/@t
Now, the reason the desired result above is output as rank 1 is because based off of my sort logic algorithm:
Code:
<xsl:sort select="(run/@y * 1 + run/@t * 10 + pass/@y * .5 + pass/@t * 5 + receive/@y * .5 + receive/@t * 5)" data-type="number" order="descending"/>
The rank node gets evaluated to the first position because of the following:
pass/@y = (500*.5) + (pass/@t = 1 * 5) =
255
Now, for the rank node at position 2 it would be: receive/@y = (322*.5) + (receive/@t = 1 * 5) =
166
Data in the original XML for position 2
Code:
<receive y="322" t="1">
<name value="greg"/>
<name-id id="1205"/>
</receive >
Desired results for position2:
Code:
<rank position="2" player-id="1205" name="greg" run-y="" run-t="" pass-y="" pass-t="" receive-y="322" receive-t="1"/>
I'm basically just trying to parse the entire XML and return the top three nodes/child-nodes that have the highest value based of on the sort logic specified above.