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.4 Searching by Joining Multiple Conditions with Logical Operators

A search expression is used to retrieve XML documents that satisfy specified conditions from the XML documents stored in Shunsaku.

Searches can be conducted using multiple conditions joined by logical operators. Logical operators make it possible to search for XML documents that satisfy two conditions, or that satisfy only one of two conditions.

Logical operators include "AND" and "OR". When both "AND" and "OR" are specified in a search expression, "AND" is evaluated before "OR".

Refer to B.3 Search Expressions for more information on search expressions and logical operators.

The explanation that follows assumes that the following documents exist:

Document A

<doc>
    :
  <basic date="2006/01/30" expense="$157.00">
    :
  </basic>
  <detail>
    <destination area="Richmond, Melbourne">Melbourne Office</destination>
    <purpose>Attendance at Shunsaku Sales Meeting</purpose>
    :
  </detail>
    :
</doc>

Document B

<doc>
    :
  <basic date="2006/02/16" expense="$160.20">
    :
  </basic>
  <detail>
    <destination area="Balmain, Darlinghurst, Sydney">Sydney branch</destination>
    <purpose>V7.0L10 installation report</purpose>
    :
  </detail>
    :
</doc>

Document C

<doc>
    :
  <basic date="2006/03/02" expense="$24.00">
    :
  </basic>
  <detail>
    <destination area="Clearview, Belair, Adelaide">Head office</destination>
    <purpose>Regular Interstage meeting</purpose>
    :
  </detail>
    :
</doc>

Example 1

The following example shows how to search for documents that contain the keyword 'Interstage' or 'Shunsaku' in the trip purpose (purpose):
/doc/detail/purpose = 'Interstage' OR 
/doc/detail/purpose = 'Shunsaku'

Result: Documents A and C are returned.

Example 2

The following example shows how to search for documents that contain the keyword 'Richmond' or 'Clearview' in the trip area (area):
/doc/detail/destination/@area = 'Richmond' OR 
/doc/detail/destination/@area = 'Clearview'

Result: Documents A and C are returned.

Example 3

The following example shows how to search for documents in which the trip expenses (expense) are more than $100.00and the trip area (area) includes 'Sydney':
/doc/basic/@expense >= 100.00 AND
/doc/detail/destination/@area = 'Sydney'

Result: Documents B is returned.

Enclose the conditional expression in parentheses if it is necessary to evaluate "OR" preferentially.

Example 4

The following example shows how to search for documents in which the trip destination (destination) is 'Head Office' or 'Sydney Branch' and the trip date (date) includes '2006/02':
(/doc/detail/destination == 'Head Office' OR
/doc/detail/destination == 'Sydney Branch') AND
/doc/basic/@date = '2006/02'

Result: Documents B is returned.

Specify the filter expressions when specifying the conditions within the closed range of element nodes specified by the path expressions.

Refer to B.3.8 Filter Expressions for more information on filter expressions.


Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006