Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX -
Contents Index PreviousNext

Appendix B Format of Search, Return and Sort Expressions> B.5 Sort Expressions

B.5.1 Sort Expression Format

Sort expressions can be specified using either text expressions, attribute expressions or single-line function specifications. In each case, the sort order (ascending or descending) can be specified. Multiple specifications can be made, each separated by commas.

The definition format for sort expressions is shown below.

[Figure B-22 Sort Expression Definition]

Sort expressions can include up to eight key specifications.

The following section explains the item specified in sort expressions.

mark1Text Expressions

For text expressions, specify a text node to use as the key for sorting the data.

Refer to B.2.2 Text Expressions for more information on text expressions.

Example

/company/employee/dept/text()

mark1Single-line Function Specification

Single-line function specifications can be used to sort the results of single-line functions.

Refer to B.2.4 Single-line Function Specification for more information on single-line function specifications.

Example 1

rlen(/company/name/text(),16)

Example 2

rlen(/company/employee/@position,16)

mark1Attribute expressions

An attribute expression specifies an attribute node to use as the key for sorting the data.

Refer to B.2.3 Attribute Expressions for more information on attribute expressions.

Example

/company/employee/@position

mark1DESC

Specify DESC to return results in descending order. If omitted, results will be returned in ascending order.

Example

/company/employee/dept/text() DESC

mark1Sorting

mark2Sorting by text expressions

mark2Sorting by attribute expression

Example

If the two document items below are sorted as strings, '20' will be larger than '100'. By specifying 'val(/value/text())' in the sort expression, these values will be treated as the numbers 100 and 20, and so 100 will be larger than 20.
<value>100</value>

<value>20</value>

mark1Aggregation

mark2Aggregating by text expressions

mark2Aggregating by attribute expressions

Example

If the two documents below are aggregated using '/doc/key/text()' as the key, each will be placed in a separate group. If 'val(/doc/key/text())' is specified in the sort expression, both data items will be treated as the numeric value 1000, and so will be aggregated as the same group.
<doc>
  <key>net1000.00g</key>
  <ship>2000</ship>
</doc>

<doc>
  <key>1,000g</key>
  <ship>1000</ship>
</doc>

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006