It would be nice to have uniform macro code that works for both simple
and multiple selections. It seems that predefined variables like
'selected' and 'selected2' would be enough, but in fact they aren't:
a.- 'selected2' is only meaningful for multiple selections.
b.- 'selected' and 'selected2' may not be in document order.
The following code fragment is an attempt (after several ones) to locate
the first and last nodes, in document order, for any explicit selection:
[1] <set variable="selectedNodes" expression="$selectedNodes" />
[2] <set variable="firstSelected" expression="$selected" />
[3] <choice>
<sequence>
<test context="$selected2" expression="." />
<set variable="lastSelected" expression="$selected2" />
</sequence>
<set variable="lastSelected" expression="$selected" />
</choice>
This code seems to work OK, but has some drawbacks:
a.- It relies on an undocumented feature of [1]. Reselecting the current
selection as a whole lets 'selected' and 'selected2' to be in document
order.
b.- There is a clear assimetry for locating the first node [2] and the
last node [3] in the selection.
Am I missing somethig obvious?
Thanks in advance.
--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado