Following on from this question about navigating collections using pos
:
In eXist 4.7 I have a collection in myapp/data/
which contains thousands of TEI XML documents. I use the following solution from Martin Honnen to get the document before and after a certain document
let $data := myapp/data
let $examples := $data/tei:TEI[@type="example"]
for $example at $pos in $examples
where $example/@xml:id = 'TC0005'
return (
$examples[$pos - 1],
$example
$examples[$pos + 1]
)
With this I would have expected $examples[$pos - 1]
to produce document 'TC0004' and $examples[$pos + 1]
to produce 'TC0006' (based on the sort order seen in eXide collection navigation view for example). They do not, producing the inverse instead.
Honnen and Michael Kay responded that
ordering of documents within a collection is very much processor-dependent
Applying an order by $example/@xml:id ascending
clause did not change the result for the better.
So, the question is how can I impose an alpha-numeric order on $data
?
Many thanks.