Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX - |
Contents
Index
![]() ![]() |
Appendix B Format of Search, Return and Sort Expressions | > B.4 Return Expressions |
Some example return expressions are shown below.
Document
<doc> <companyname>fujitsu</companyname> <employee position="manager"> <name>smith</name> <id>2000</id> <age>30</age> </employee> </doc> |
The examples of the return specification formats are shown below.
If a path expression is specified in the return item, the corresponding element nodes will be returned in XML format.
If multiple path expressions are specified in the return item, multiple elements are returned in the order specified. Results will be returned for each matching document, enclosed by the root tag.
If there are no matching elements, no elements will be returned.
Example 1
Return Expression
/Result: The Entire Record is Returned
<doc> <companyname>fujitsu</companyname> <employee position="manager"> <name>smith</name> <id>2000</id> <age>30</age> </employee> </doc>
Example 2
Return Expression
/doc/employee/nameResult
<doc><name>smith</name></doc>
Example 3
Return Expression
/doc/employeeResult
<doc><employee position="manager"><name>smith</name><id>2000</id><age>30</age></employee></doc>
Example 4
Return Expression
/doc/companyname,/doc/employee/idResult
<doc><companyname>fujitsu</companyname><id>2000</id></doc>
Example 1
If some elements do not exist, the application will not be able to determine which elements do not exist. In this example, there is no '/doc/president/name' element, and so only '/doc/employee/name' will be returned, but the application will not be able to determine whether the element returned is '/doc/president/name' or '/doc/employee/name'.Return expression
/doc/president/name,/doc/employee/name
Result
<doc><name>smith</name></doc>Example 2
The application will not be able to determine the path to the elements that have been extracted.In this example, the application cannot determine whether the path to the name element is '/doc/president/name' or '/doc/employee/name'.Document
The explanations that follow assume that the following XML document has been found.
<doc> <companyname>fujitsu</companyname> <president> <name>thompson</name> <id>1849</id> <age>61</age> </president> <employee> <name>smith</name> <id>2000</id> <age>30</age> </employee> </doc>Return expression
//nameResult
<doc><name>thompson</name><name>smith</name></doc>
If a text expression, attribute expression or a single-line function specification is specified in the return item, the results of the text expression, attribute expression or single-line function specification will be returned as a string.
If multiple path expressions are specified in the return item, multiple strings are returned in the order specified.
If there are no matching elements, an empty element will be indicated by consecutive delimiters.
In the following example, character codes '\001' and '\002' are expressed as '\1' and '\2' respectively.
Example 1: Example Return Item
Return Expression
/doc/employee/name/text()Result
For Java APIs
smithFor .NET APIs
smithFor C APIs
smith \1
Example 2: Example return item that attribute expression is specified
Return Expression
/doc/employee/@positionResult
For Java APIs
managerFor .NET APIs
managerFor C APIs
manager \1
Example 3: Example return item that contains a mixture of text expression, single-line function specification, and attribute expression
Return Expression
/doc/employee/name/text(),val(/doc/employee/age/text()),/doc/employee/@positionResult
For Java APIs
smith,30,managerFor .NET APIs
smith \1 30 \1 managerFor C APIs
smith \1 30 \1 manager \1
If a return parameter that will match multiple elements is specified (that is, if more than one path expression is specified, or if "//" or "*" is specified), the application will not be able to determine the relationship between the elements that have been extractedExample
Because there is no 'age element node' for 'jones' in the document below, it is impossible to tell whether the '30' in the third result relates to 'smith' or 'jones'.Document
<doc> <companyname>fujitsu</companyname> <employee> <name>smith</name> <id>2000</id> <age>30</age> </employee> <employee> <name>jones</name> <id>1000</id> </employee> </doc>Return expression
/doc/companyname/text(),/doc/employee/name/text(),val(/doc/employee/age/text())Result
For Java APIs
fujitsu,smith|jones,30For .NET APIs
fujitsu \1 smith \2 jones \1 30For C APIs
fujitsu \1 smith \2 jones \1 30 \1
Contents
Index
![]() ![]() |