Re: Proposed spec text for sort properties

Revised version.

Steven

===


The sort Property

Associates a sorting property with a nodeset, ensuring that the nodeset is 
kept sorted.

Computed expression: Yes
Legal values: Any expression
Default value: none
Inheritance Rules: Does not inherit
Data binding restriction: none

If a bound-to node already has one or more sort properties, the new one is 
added at a lower-priority, so that the highest priority is the primary sort 
property, the second, the secondary sort property, and so on.

When applied to instance data, during initialisation and recalculation the 
processor assures that the nodeset is sorted according to this and the 
other sorting properties (direction, and collation) reordering as 
necessary. As a result, if direction = 'up', evaluating the expression of 
the sort property with context of any node is less than or equal to the 
evaluation of the expression in the context of the previous node, if any, 
in the nodeset, and greater than or equal to the evaluation of the 
expression in the context of the following node, if any, in the nodeset, 
and the other way round if direction = 'down'. 

A lower-priority sort property only applies to the preceding and following 
siblings of a node whose one-level higher priority sort property are equal, 
if any.  

If the evaluation of the property, or comparison of the properties at any 
time cause an xforms-expression-error to be dispatched, the sorting is 
terminated, and this may leave the nodeset in an unsorted state.

When applied to a control, during refresh the displayed data is reordered 
as necessary in the same way.

Example

In both these cases

 <bind ref="data" sort="date">
  <bind sort="time"/>
 </bind>
and
 <bind ref="data" sort="date"/>
 <bind ref="data" sort="time"/>

the data will primarily be sorted on the date field, and with equal dates, 
sorted on the time field. 


The direction Property

Associates a sorting direction with a nodeset.

Computed expression: No
Legal values: up | down
Default value: up
Inheritance Rules: Does not inherit
Data binding restriction: none

For nodes with a sort property, this property specifies whether the sorting 
of nodes should be ascending ('up'), or descending ('down').

The collation Property

Associates a collation order with a nodeset.

Computed expression: No
Legal values: URI
Default value: none
Inheritance Rules: Does not inherit
Data binding restriction: none

For nodes with a sort property, when values are compared for sorting at a 
character level, the Unicode collating algorithm will be applied. For 
details, see [ref].



The insert Element

This action inserts items into a sequence. In brief:

ref or bind gives a target sequence;
origin gives one or more items to be inserted in the sequence (default: a 
copy of the last item of the target sequence);
at gives an index into the target sequence for the insertions (default: the 
end of the sequence);
position says whether to insert before or after the given position 
(default: after).

If the target sequence is empty (and origin is present and non-empty) the 
origin items are inserted into the context node, ignoring at and position.

If the target sequence has one or more sort properties, the origin items 
are inserted at the correct sorted position in the target sequence, 
ignoring at and position.

Received on Thursday, 18 December 2025 21:10:02 UTC