saxon:order - ordered uniqueness constraints

Saxon allows the additional attribute xs:unique/xs:field/@saxon:order, with the permitted values ascending and descending. If the attribute is present on at least one field of a uniqueness constraint, then the constraint not only imposes uniqueness of values in the normal way, it also requires the values to be ordered. If the attribute is present on at least one field of a uniqueness constraint, then the value saxon:order="ascending" is assumed for any other fields of the constraint if not explicitly specified.

Not only does this provide an additional integrity constraint (one which is quite difficult to articulate using assertions), it also makes checking of the uniqueness constraint much more efficient, since it only requires the most recently-encountered value of the selected fields to be maintained.

For example, the following (rather contrived) example indicates that employees in a data file are to be sorted by ascending last name, then descending first name:

<xs:element name="employees"> <xs:unique> <xs:selector xpath="employee"/> <xs:field xpath="last" saxon:order="ascending"/> <xs:field xpath="first" saxon:order="descending"/> </xs:unique> </xs:element>