insert and delete

Insert and delete are symmetrical:

If you try to insert with a value of @at below 1, it inserts at the start;  
with a value larger than the size of the sequence, or with something that  
isn't a number, it inserts at the end.

<instance>
   <data xmlns="">
     <list>
        <item/>
        <item/>
        <item/>
     </list>
     <node/>
   </data>
</instance>
...
<insert context="list" ref="item" at="-100" origin="node"/> - inserts at  
start
<insert context="list" ref="item" at="100" origin="node"/> - inserts at end
<insert context="list" ref="item" at="cat" origin="node"/> - inserts at end

Delete works the same.

<delete context="list" ref="item" at="-100"/> - deletes first item
<delete context="list" ref="item" at="100"/> - deletes last item
<delete context="list" ref="item" at="cat"/> - deletes last item

Now, I'm OK with how insert works. It does a best effort.

However, I'm less happy with deleting when @at is out-of-range, since you  
are losing information.

Personally I'd prefer delete only to delete items if @at is in range.

Steven

Received on Tuesday, 22 November 2016 20:24:17 UTC