Is it possible to do a sort in a XPath so that it would feed the
sequence in a sorted manner ?
XPath 1 does not have a sequence data type so you can not store a sorted
sequence, it has node sets, which are intrinsically unorderd.
If you need to store an ordered set of things in xpath 1 you need to
make copies of the nodes under under a parent node so that sibling order
records the ordering. You then to use the node set extension to access
the nodes.
XPath 2 has a (ordered) sequence type as its primitive datatype,
replacing node sets.
So where in xslt/xpath 2 you can go
<xsl:variable name="k1" as="xs:string+">
<xsl:perform-sort select="x/titles/key">
<xsl:sort select="."/>
</xsl:perform-sort>
</xsl:variable>
<xsl:for-each select="$k1,titles/value">
and so iterate over a sorted sequence of nodes, in XSLt 1 you'd go
<xsl:variable name="k1x">
<xsl:for-each select="x/titles/key">
<xsl:sort select="."/>
</xsl:for-each>
<xsl:copy-of select="x/titles/value"/>
</xsl:variable>
<xsl:variable name="k1" select="msxsl:node-set($k1x)/*"/>
<xsl:for-each select="$k1">
Which would work, but copying nodes is relatively expensive and if you
repeatedly copied at every iteration of the sorting it would get
exponentially so.
David
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________
--~------------------------------------------------------------------
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>
--~--