Hi,
I'm stuck with a sorting problem and hope to find some help here :-)
I have the following input:
<points>10 13,20 34,2 10,40 67</points>
This is a comma-separated list of 2d points. Each point consists of a
x-coordinate and a y-coordinate, parted by a white-space.
And I have a reference point, eg.
<refpoint>3 2</refpoint>
Now I want to sort the list of points. To do so I have to compare two
points and compute the following:
result =3D (P1.x - P0.x)*(P2.y - P0.y) - (P2.x - P0.x)*(P1.y - P0.y)
(P0 -> reference point,
P1 -> one point of the list,
P2 -> another point of the list)
According to the value of "result", P1 and P2 shall be sorted as follows:
result < 0: P1 goes before P2
result > 0: P2 goes before P1
result =3D 0: no sorting required
Assume the following template:
<xsl:template name=3D"sort">
<xsl:with-param name=3D"refpoint"/>
<xsl:with-param name=3D"$points"/>
<xsl:for-each select=3D"tokenize($points,',')">
<xsl:sort select=3D"."/>
......
</xsl:for-each>
</xsl:template>
I can't compare two points within <xsl:sort/> the way I have to, can
I? How can I solve my sorting problem using xslt?
Thanks for any ideas,
Claus
--~------------------------------------------------------------------
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>
--~--