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

Part 2 Developing Applications by APIs> Chapter 10 Developing .NET Applications> 10.3 How to Use .NET APIs> 10.3.2 Data Searches

10.3.2.5 Using Record IDs to Obtain Entire XML Documents

When searching for a particular XML document, do not obtain the entire document immediately. Instead, start by obtaining the partial information that can effectively identify the document.

To extract the entire XML document, set the ShunRecord object that has extracted information partially in the ShunRecordCollection object, and then use the SearchByRecordID to extract the entire target XML document.

The following diagram shows the process for using record IDs to obtain an entire XML document.

[Figure 10-9 Flow of the Process for Using Record IDs to Obtain an Entire XML Document]

mark1Sample Code for C# .NET

ShunService service = new ShunService();
service.Connect();

ShunSearchRequirement req = new ShunSearchRequirement();                          
req.QueryExpression = "/document/base/prefecture == 'Sydney'";                      
req.ReturnExpression = "/document/base/name/text()";              

ShunResultSet rs = service.Search( req );                                         
Console.WriteLine("[Number of hits] = " + rs.HitCount);                            
ShunRecordCollection recCol = new ShunRecordCollection();                       (1)
foreach ( ShunRecord record in rs.Records ) {                                   (2)
  if ( record.Data == "Hotel 1" ) {                                             (2)
    recCol.Add( record );                                                       (2)
  }
}

rs = service.SearchByRecordID( recCol );                                        (3)
foreach ( ShunRecord record in rs.Records ) {                                   (4)
  Console.WriteLine( "[Detail] = " + record.Data );                             (4)
}

service.Disconnect();

mark1Sample Code for VB .NET

Dim service As New ShunService()
service.Connect()

Dim req As New ShunSearchRequirement()
req.QueryExpression = "/document/base/prefecture == 'Sydney'"
req.ReturnExpression = "/document/base/name/text()"

Dim rs As ShunResultSet = service.Search( req )
Console.WriteLine( "[Number of hits] = {0}", rs.HitCount )
Dim recCol As New ShunRecordCollection()                                      (1)
For Each record As ShunRecord In rs.Records                                   (2)
  If record.Data = "Hotel 1" Then                                             (2)
    recCol.Add( record )                                                      (2)
  End If
Next

rs = service.SearchByRecordID( recCol )                                       (3)
For Each record As ShunRecord In rs.Records                                   (4)
  Console.WriteLine( "[Detail] = {0}", record.Data)                           (4)
Next

service.Disconnect()

mark2(1) Create a ShunRecordCollection Object

Create a ShunRecordCollection object.

mark2(2) Set the ShunRecord Object that Holds Record ID

Set the ShunRecord object in the ShunRecordCollection object.

The following methods are used to set the ShunRecord object. Refer to the table below for the methods that can be used to set the ShunRecord object.

[Table 10-4 List of Methods for Setting ShunRecord Object]

Method or property

Function

Add(ShunRecord record)

Adds the ShunRecord to the end of ShunRecordCollection.

AddRange(ShunRecord[] records)

Copies the element of ShunRecord array to the end of ShunRecordCollection.

Insert(int index, ShunRecord record)

Inserts the ShunRecord at the index position specified in the ShunRecordCollection.

Item[int index]

Replaces the ShunRecord that the index position is specified.
This property will be the indexer of ShunRecordCollection class for C# .NET.

mark2(3) Execute the Search (Create a ShunRecordCollection Object)

Execute the search using the SearchByRecordID method. A ShunRecordCollection object will be created to hold the results of the search.

mark2(4) Extract the Results of the Search

Extract one record of ShunRecord object from the ShunRecordCollection object. Then extract the XML documents from the ShunRecord object.

The following properties or methods are used to extract XML documents according to the purpose of the extraction. Refer to the table below for the properties and methods that can be used to extract XML documents.

[Table 10-5 Properties and Methods that Can be Used to Extract XML Documents]

Property or method

Function

Data property

Extracts XML documents as String objects.

GetDividedData method

Extracts XML documents as a two-dimensional array of String objects.

GetStream method

Extracts XML documents as Stream objects.

Note: The GetDividedData method is an effective way to extract search results in text format.


Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006