Below is a XSLT 2.0 solution for this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:variable name="x" select="source" />
<target>
<elements>
<xsl:for-each select="tokenize($x/sortorder,',')">
<xsl:copy-of select="$x/elements/element[(_at_)ID =
normalize-space(current())]" />
</xsl:for-each>
</elements>
</target>
</xsl:template>
</xsl:stylesheet>
On 5/20/08, marentxml <mailing(_dot_)lists(_at_)marentxml(_dot_)ch> wrote:
hi
is there any way to sort elements by a predefined order? i'd like to come
from
<source>
<sortorder>46, 21, 39, 27, 17</sortorder>
<elements>
<element ID="17"/>
<element ID="21"/>
<element ID="27"/>
<element ID="39"/>
<element ID="46"/>
</elements>
</source>
the most elegant way to
<target>
<elements>
<element ID="46"/>
<element ID="21"/>
<element ID="39"/>
<element ID="27"/>
<element ID="17"/>
</elements>
</target>
thanks in advance for any help.
frank
--
Regards,
Mukul Gandhi
--~------------------------------------------------------------------
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>
--~--