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

Part 1 The Basic for Developing Application> Chapter 3 Data Search Methods> 3.7 Extracting Aggregated Results> 3.7.1 Grouping Search Results

3.7.1.1 Grouping by Character String

Grouping can be performed using the value of an element node in an XML document or the value of the attribute nodes of that element node. To group by a character string, specify a text expression or attribute expression in the key specification of the sort expression.

The explanation that follows assumes that Documents A, B, C, and D, below exist:

Document A

<doc>
  <employee eno="19980120" position="general manager">
    :
    <name>Sara Jones</name>
    :
  </employee>
    :
  <detail>
    :
    <destination area="Griffith, Kingston, Deakin, Canberra"> Canberra branch</destination>
    :
  </detail>
    :
</doc>

Document B

<doc>
  <employee eno="19980120" position="general manager">
    :
    <name>Sara Jones</name>
    :
  </employee>
    :
  <detail>
    :
    <destination area="Clayton, Richmond, Melbourne"> Melbourne branch</destination>
    :
  </detail>
    :
</doc>

Document C

<doc>
  <employee eno="20012111" position="manager">
    :
    <name>Lisa Taylor</name>
    :
  </employee>
    :
  <detail>
    :
    <destination area="Clayton, Richmond, Melbourne">Melbourne branch</destination>
    :
  </detail>
    :
</doc>

Document D

<doc>
  <employee eno="20012111" position="manager">
    :
    <name>Lisa Taylor</name>
    :
  </employee>
    :
  <detail>
    :
    <destination area="Forrest, Kingston, Deakin, Canberra"> Canberra branch</destination>
    :
  </detail>
    :
</doc>

Example 1

The following examples show how to group according to the employee name (name):
/doc/employee/name/text() 

Result: Documents A and B are handled as one group, and documents C and D are handled as another group.

Example 2

The following examples show how to group according to the position (position):
/doc/employee/@position

Result: Documents A and B are handled as one group, and documents C and D are handled as another group.

The process of grouping by a character string takes place using the first 20 bytes of the string as a key. If the value in the XML document indicated by the key exceeds 20 bytes, differences in character strings from byte 21 onwards will be ignored, and dissimilar documents may end up being placed in the same group. In such cases, the rlen function can be included in the key specification to specify the number of characters from the start of the string that will be used as the key.
Refer to B.2.4 Single-line Function Specification for more information on the rlen function.

Example 3

The following example shows how to group according to the trip area (area):
rlen(/doc/detail/destination/@area,30) 

When the above is specified, grouping will occur using the first 30 characters of the trip area.


Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006