I've also sorted out a document order issue, so that string(ns) returns the right thing. Most functions which operate on a node-set want the node that comes first in document order. However, until now the node-set returned by reverse axes where, unsurprisingly, in reverse order so they gave the wrong result. Node-sets now keep track of whether they are forward or reverse, so they do the right thing at the right time. Several other XPath implementations get this wrong, btw. For instance XPath Explorer have a play with.
Here's what I mean
<document> <chapter>one</chapter> <chapter>two</chapter> <chapter>three</chapter> <chapter>four</chapter> <chapter>five</chapter> </document>
string(/document/*) = "one" string(/document/*[last()]) = "five" string(/document/chapter/preceding-sibling::* = "four" string(/document/chapter/preceding-sibling::*[last()]) = "one" string(/document/chapter/preceding-sibling::*) = "one"That last expression is the most interesting. It selects all the chapter elements before the last one in reverse document order (as we can see from the previous two expressions), but the string() function returns the value of the node which comes first in document order.
One remaining issue here - my implementation of the union operator may not (depending on what you're joining together) return the node-set in any kind of order, in which case this all breaks down.