Hussein Shafie escribi?:
> Manuel Collado wrote:
> 
>>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.
>>
> 
> 
> You are right. I propose the following changes:
> 
> [1] In a macro, $selected will always denote the first (in document
> order) selected node if any (i.e. otherwise, empty node set).
> 
> [2] In a macro, $selected2 will always denote the last (in document
> order) selected node if any (i.e. otherwise, empty node set).
> 
> Is that OK for you?

Of course it is. I didn't suggested it myself as I don't know if this 
could break some existing customization code.

Please find attached my general macro code for moving the selection up 
and down among its siblings. It can be used to reorder paragraphs, list 
items, table rows, etc. It still needs some rework, in order to swap 
only elements and not elements and text nodes.

If you find the code useful, please feel free to use it in any way (even 
to include it in the sample 'customize.xxe' :-)

Thank you for your support, and for allowing free usage of your 
excellent tool for personal work.

Regards.
-- 
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20070425/3167a88f/attachment.htm
 

Reply via email to