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

|
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.
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.
- The '//' path operator cannot be specified in the text expression.
- The '*' path element cannot be specified in the text expression.
Example
/company/employee/dept/text() |
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) |
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.
- The '//' path operator cannot be specified in the attribute expression.
- The '*' path element cannot be specified in the attribute expression.
- The '*' cannot be specified at the attribute name specified by the attribute expression.
Example
/company/employee/@position |
Specify DESC to return results in descending order. If omitted, results will be returned in ascending order.
Example
/company/employee/dept/text() DESC |
Sorting by text expressions
- If a text expression is specified, results will be sorted using the string held by the text node specified by the text expression.
- By default, only the leftmost 20 bytes of the string held by the text node specified with the text expression are valid. The number of valid characters can be changed using the 'rlen' function. The range of values that can be specified is 1 to 128.
- Any spaces, tabs, or linefeed characters in the string held by the text node specified with the text expression will be distinguished as valid values.
- If the text node specified with the text expression occurs more than once in the document, only the value of the first text node will be used.
- If the text node specified with the text expression is not in the document, the document will be placed last in the sorted results, regardless of the sort order.
- Specify the val function to sort numeric values. If the val function is specified, the data will be treated as numeric, and there is no need to line up digits.
Sorting by attribute expression
- If an attribute expression is specified, results will be sorted using the string held by the attribute node specified by the attribute expression.
- By default, only the leftmost 20 bytes of the string held by the attribute node specified with the attribute expression are valid. The number of valid characters can be changed using the 'rlen' function. The range of values that can be specified is 1 to 128.
- Any spaces, tabs, or linefeed characters in the string held by the attribute node specified with the attribute expression will be distinguished as valid values.
- If the attribute node specified with the attribute expression occurs more than once in the document, only the value of the first attribute node will be used.
- If the attribute node specified with the attribute expression is not in the document, the document will be placed last in the sorted results, regardless of the sort order.
- Specify the val function to sort numeric values. If the val function is specified, the data will be treated as numeric, and there is no need to line up digits.
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.
Aggregating by text expressions
- If a text expression is specified, all documents where the text node specified by the text expression hold the same string are treated as a single group.
- By default, only the leftmost 20 bytes of the string held by the text node specified with the text expression are valid. The number of valid characters can be changed using the 'rlen' function. The range of values that can be specified is 1 to 128.
- Any spaces, tabs or linefeed characters in the string held by the text node specified with the text expression will be distinguished as valid values.
- If the text node specified with the text expression occurs more than once in the document, only the value of the first text node will be used.
- Documents where the text node specified with the text expression does not exist are treated as a single group where the group key has no value.
- Specify the val function to aggregate search results using a numeric key. If the val function is specified, the data will be treated as numeric, and so elements with the same numeric value will be treated as the same group even if some strings contain non-numeric values, or if the positioning of the decimal places below the decimal point is different.
Aggregating by attribute expressions
- If an attribute expression is specified, all documents where the attribute node specified by the attribute expression hold the same string are treated as a single group.
- By default, only the leftmost 20 bytes of the string held by the attribute node specified with the attribute expression are valid. The number of valid characters can be changed using the 'rlen' function. The range of values that can be specified is 1 to 128.
- Any spaces, tabs or linefeed characters in the string held by the attribute node specified with the attribute expression will be distinguished as valid values.
- If the attribute node specified with the attribute expression occurs more than once in the document, only the value of the first attribute node will be used.
- Documents where the attribute node specified with the attribute expression does not exist are treated as a single group where the group key has no value.
- Specify the val function to aggregate search results using a numeric key. If the val function is specified, the data will be treated as numeric, and so elements with the same numeric value will be treated as the same group even if some strings contain non-numeric values, or if the positioning of the decimal places below the decimal point is different.
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> |
All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006