Re: Sorting

Second strawman, though it comes in two parts.

Part One: binding

There are two new bind properties: @sorted[XPath expression] default is 
empty, and @direction["up"|"down"]: default is up

If a bind has such a property:

 <bind ref="item" sorted="date"/>

then the nodeset referenced is kept sorted by the system, using the XPath 
expression as key.

 <bind ref="item" sorted="lowercase(name)"/>

 <bind ref="instance('data')" sorted="substring(date, 6, 2)" />

 <bind ref="instance('books')" sorted="."/>

@direction determines whether to sort increasing or decreasing.

If @sorted is empty, then the items are not sorted, but keep their document 
order.

Part Two: Use on controls

It was pointed out that it would be useful to use sorting on a repeat (for 
instance), independent of binds. This meshes also with an earlier request 
by Alain that bind properties be usable on controls.

So proposal part two is to allow all bind attributes to be used on 
controls, where the properties then only apply to the value(s) selected by 
the control at that point, and not to the instance data in general. For 
instance:

<trigger ref="index" label="previous" relevant=". > 1">
 <setvalue ev:event="DOMActivate" ref="." value=". - 1"/>
</trigger>

In this way we can apply the sorted attributes to a repeat, or itemset. For 
instance:

 <repeat ref="item" sorted="received-date">
     ...

Diffference with XPath 3.

XPath 3 has a "collation" attribute, which is not used here.
https://www.w3.org/TR/xpath-functions-31/#func-sort

Steven 

Received on Thursday, 4 April 2024 17:48:34 UTC