Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX - |
Contents
Index
![]() ![]() |
Part 2 Developing Applications by APIs | > Chapter 10 Developing .NET Applications | > 10.3 How to Use .NET APIs | > 10.3.2 Data Searches |
It is often desirable for a Web application to be able to divide up search results into a fixed number of items and to obtain these as consecutive groups.
XML documents can be obtained consecutively by specifying the last position information or the first position information obtained by the preceding search process as the Position property of the ShunSearchRequirement object
The following diagram shows the process for obtaining consecutive groups XML documents that match conditions.
ShunService service = new ShunService(); service.Connect(); ShunSearchRequirement req = new ShunSearchRequirement(); req.QueryExpression = "/document/base/prefecture == 'Sydney"; req.ReturnExpression = "/document/base/name, /document/base/price"; req.SortExpression = "val(/document/base/price/text()) DESC"; req.ReplyNumber = 5; // First position information ShunPosition firstPosition = null; // Last position information ShunPosition lastPosition = null; // Change the position settings according to the page to be displayed // To display the next page, set the direction to "NEXT". To display the previous page, set the direction to "PREV" switch ( direction ) { case NEXT: // Display the next page (2) req.Position = lastPosition; break; case PREV: // Display the previous page (3) req.Position = firstPosition; break; default: // Display the first page (1) req.Position = null; break; } ShunResultSet rs = service.Search( req ); (4) Console.WriteLine ( "[Number of hits] = {0}", rs.HitCount ); int i = 0; foreach ( ShunRecord record in rs.Records ) { (5) ++i; Console.WriteLine( "[Resuit] Item No.{0} = {1}", i, record.Data ); (5) } // Store the first position information and last position information firstPosition = rs.FirstPosition; (6) lastPosition = rs.LastPosition; (6) service.Disconnect(); |
Dim service As New ShunService() service.Connect() Dim req As New ShunSearchRequirement() req.QueryExpression = "/document/base/prefecture == 'Sydney'" req.ReturnExpression = "/document/base/name, /document/base/price" req.SortExpression = "val(/document/base/price/text()) DESC" req.ReplyNumber = 5 ' First position information Dim firstPosition As ShunPosition = Nothing ' Last position information Dim lastPosition As ShunPosition = Nothing ' Change the position settings according to the page to be displayed ' To display the next page, set the direction to "NEXT". To display the previous page, set the direction to "PREV" Select Case direction Case NEXT ' Display the next page (2) req.Position = lastPosition Case PREV ' Display the previous page (3) req.Position = firstPosition Case Else ' Display the first page (1) req.Position = Nothing End Select Dim rs As ShunResultSet = service.Search(req) (4) Console.WriteLine( "[Number of hits] = {0}", rs.HitCount ) Dim i As Integer = 0 For Each record As ShunRecord In rs.Records (5) i += 1 Console.WriteLine( "[Result] Item No.{0} = {1}", i, record.Data ) (5) Next ' Store the first position information and last position information firstPosition = rs.FirstPosition (6) lastPosition = rs.LastPosition (6) service.Disconnect() |
Specify the data acquisition position with the Position property. Search processing that displays the first page will start extracting data from the first item, so specify null for the data acquisition position (the position of the first or last data item to be acquired). If null is specified for the data acquisition position, data will be extracted from the first item.
Specify the data acquisition position with the Position property. For search processing that displays the next page, use the LastPosition property to obtain the last position information from the previous search, and then specify this position information as the data acquisition position (the acquisition start position). This specification makes it possible to obtain the data that follows the previously acquired data.
Specify the data acquisition position with the Position property. For search processing that displays the previous page, use the FirstPosition property to obtain the first position information from the previous search, and then specify this position information as the data acquisition position (the acquisition end position). This specification makes it possible to obtain the data that follows the previously acquired data.
For the search, specify and use the ShunSearchRequirement object that the search conditions have been set by the Search method. A ShunResultSet object will be created to hold the results of the search.
Extract 1 record of ShunRecord object from the ShunResultSet 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. The following table shows the properties or methods that can be used.
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 getStringArray method is an effective way to extract search results in text format.
Store the first position information using the FirstPosition property.
Store the last position information using the LastPosition property.
Contents
Index
![]() ![]() |