Defining Choice Condition With LookAhead for a Complex File Structure

6-100 Oracle Fusion Middleware Users Guide for Technology Adapters ending with text YES and the RecTwo record takes data for records ending with text NO . Also, using this use case you can generate the NXSD and test it. Perform the following steps to run this use case: 1. The data in a sample text file, address.txt, appears as below: Name1,2 Old Street, Old Town,Manchester,20-08-1954,0161-499-1718, YES Name2,2 Old Street, Old Town,Manchester,20-08-1954,0161-499-1718, NO Name3,2 Old Street, Old Town,Manchester,20-08-1954,0161-499-1718, NO Name4,2 Old Street, Old Town,Manchester,20-08-1954,0161-499-1718, YES 2. Launch the Adapter Configuration Wizard and navigate to the Messages page, and click Define Schema For Native Format. The Native Format Builder Welcome page is displayed.

3. Click Next. The Choose Type page is displayed.

4. Select Complex Type and click Next. The Native Format Builder File Description

page is displayed.

5. Click Browse and select the address.txt file, and enter Address in the Root

Element field.

6. Click Next. The Native Format Builder Design Schema page is displayed.

7. Click the Add Complex Type icon. A Complex Type, new_complex_type is

created in the Schema Tree under Address. 8. Select the first row of the sample text from the right-hand pane of the Sample File section, and drag and drop it on the new_complex_type node. The Complex Type Details dialog is displayed.

9. Enter RECORD1 in the Complex Type Name field and select Comma , in the

Delimited By list.

10. Click OK. The Native Format Builder Design Schema page is displayed, as shown

in Figure 6–52 . Figure 6–52 Native Format Builder Design Schema Page Native Format Builder Wizard 6-101 11. Similarly, create another complex type node called RECORD2. The Native Format Builder Design Schema page is displayed, as shown in Figure 6–53 . Figure 6–53 Native Format Builder Design Schema Page

12. Click Add Choice Node. The Choice Option Type dialog is displayed.

13. Set the options in the Choice Option Type dialog, as shown in

Figure 6–54 , and then click OK. Figure 6–54 The Choice Option Type Dialog

14. Select choice and click the Add Element icon. A new_element is added to the

choice node.

15. Click the Edit Node icon. The Element Details dialog is displayed.

16. Enter RECONE in the Element Name field and select RECORD1 as the Data Type

set choice condition as YES, and then click OK. 6-102 Oracle Fusion Middleware Users Guide for Technology Adapters 17. Follow Step 14 to 16 to create the RECTWO choice element for the choice node and set choice condition as NO . The Native Format Builder Design Schema dialog is displayed, as shown in Figure 6–55 . Figure 6–55 Native Format Builder Design Schema Page 18. Drag and drop the RECORD1 complex type to the RECONE element under choice and the RECORD2 complex type to the RECTWO element under choice. The Native Format Builder Design Schema dialog is displayed.

19. Click Next. The Generated Native Format Schema File page is displayed, as shown

in Figure 6–56 , which displays the native format file. Note: There is one space after chars NO, since you need to match the total no. of characters to three. Native Format Builder Wizard 6-103 Figure 6–56 Generated Native Format Schema File Page Native Schema The native schema definition corresponding to the preceding native data can be defined as follows: ?xml version=1.0 encoding=UTF-8 ? xsd:schema xmlns:xsd=http:www.w3.org2001XMLSchema xmlns:nxsd=http:xmlns.oracle.compcbpelnxsd xmlns:tns=http:TargetNamespace.comtesNew targetNamespace=http:TargetNamespace.comtesNew elementFormDefault=qualified attributeFormDefault=unqualified nxsd:version=NXSD nxsd:stream=chars nxsd:encoding=ASCII xsd:element name=Root-Element xsd:complexType xsd:choice minOccurs=1 maxOccurs=unbounded nxsd:choiceCondition={X} nxsd:lookAhead=70 nxsd:scanLength=3 nxsd:assignTo={X} xsd:element name=RECTWO type=tns:RECORD2 nxsd:conditionValue=NO xsd:element name=RECONE type=tns:RECORD1 nxsd:conditionValue=YES xsd:choice xsd:complexType xsd:element xsd:complexType name=RECORD2 xsd:sequence xsd:element name=C1 type=xsd:string nxsd:style=terminated nxsd:terminatedBy=, xsd:element name=C2 type=xsd:string nxsd:style=terminated nxsd:terminatedBy=, xsd:element name=C3 type=xsd:string nxsd:style=terminated nxsd:terminatedBy=, xsd:element name=C4 type=xsd:string nxsd:style=terminated 6-104 Oracle Fusion Middleware Users Guide for Technology Adapters nxsd:terminatedBy=, xsd:element name=C5 type=xsd:string nxsd:style=terminated nxsd:terminatedBy={eol} xsd:sequence xsd:complexType xsd:complexType name=RECORD1 xsd:sequence xsd:element name=C1 type=xsd:string nxsd:style=terminated nxsd:terminatedBy=, xsd:element name=C2 type=xsd:string nxsd:style=terminated nxsd:terminatedBy=, xsd:element name=C3 type=xsd:string nxsd:style=terminated nxsd:terminatedBy=, xsd:element name=C4 type=xsd:string nxsd:style=terminated nxsd:terminatedBy=, xsd:element name=C5 type=xsd:string nxsd:style=terminated nxsd:terminatedBy={eol} xsd:sequence xsd:complexType xsd:schema

20. Click Test. The Test NXSD Schema dialog is displayed.

21. Click the Generate XML icon. The Result XML is displayed on the right pane of

the Test NXSD Schema dialog, as shown in Figure 6–57 . Figure 6–57 Test NXSD Schema Dialog Translated XML Using the Native Schema The translated XML looks as follows: ?xml version = 1.0 encoding = UTF-8? Root-Element xmlns=http:TargetNamespace.comtesNew RECONE Native Format Builder Wizard 6-105 C1Name1C1 C22 Old Street, Old Town,ManchesterC2 C320-08-1954C3 C40161-499-1718C4 C5 YESC5 RECONE RECTWO C1Name2C1 C22 Old Street, Old Town,ManchesterC2 C320-08-1954C3 C40161-499-1718C4 C5 NO C5 RECTWO RECTWO C1Name3C1 C22 Old Street, Old Town,ManchesterC2 C320-08-1954C3 C40161-499-1718C4 C5 NO C5 RECTWO RECONE C1Name4C1 C22 Old Street, Old Town,ManchesterC2 C320-08-1954C3 C40161-499-1718C4 C5 YESC5 RECONE Root-Element

22. Click OK. The Generated Native Format File page is displayed.

23. Click Next. The Native Format Builder Finish page is displayed.

6.4.7 Defining Array Type Schema for a Complex File Structure

In this use case, the Native Format Builder uses array.txt, a complex type file, which contains an array of items. The sample data has four names which are separated by a semicolon and ending with a period. In this use case, you would create a schema with array type which has member names separated by a semicolon and array terminated by a period. Also, using this use case you can generate the NXSD and test it. Perform the following steps to run this use case:

1. The data in a sample text file, array.txt, appears as below:

John;Steve;Paul;Todd.

2. Launch the Adapter Configuration Wizard and navigate to the Messages page and

click Define Schema For Native Format. The Native Format Builder Welcome page is displayed.

3. Click Next. The Choose Type page is displayed.

4. Select Complex Type and click Next. The Native Format Builder File Description

page is displayed. Note: There are 2 recordtypes: RECONE and RECTWO. RECONE takes records that end with character YES and RECTWO takes records that end with character NO. 6-106 Oracle Fusion Middleware Users Guide for Technology Adapters

5. Click Browse and select the array.txt file, as shown in

Figure 6–58 . The Native Format Builder File Description page is displayed. Figure 6–58 Native Format Builder File Description Page

6. Click Next. The Native Format Builder Design Schema Page is displayed.

7. Create a global element called NewArray and drag and drop the native data to the

newly created global element.

8. Select NewArray, as shown in

Figure 6–59 , and click the Edit Node icon. The Element Details dialog is displayed. Figure 6–59 Native Format Builder Design Schema Page 9. Set the options in the Element Details dialog, as shown in Figure 6–60 , and then click OK.