Defining the Schema for a Fixed Length File Structure

6-72 Oracle Fusion Middleware Users Guide for Technology Adapters Figure 6–17 Native Format Builder Wizard Choose Type Page

5. Click Next. The Native Format Builder File Description page is displayed.

6. Click Browse and select the address.txt file, as displayed in

Figure 6–18 . Figure 6–18 Native Format Builder Wizard File Description Page

7. Click Next. The Record Organization page is displayed, as shown in

Figure 6–19 . Native Format Builder Wizard 6-73 Figure 6–19 Native Format Builder Wizard Record Organization Page

8. Select Multiple records are of single type, and click Next. The Specify Elements

page is displayed.

9. Enter AddressBook in the Enter name of element containing multiple records

field, and enter Address in the Enter a name for element that will represent record field, as shown in Figure 6–20 . Figure 6–20 Native Format Builder Wizard Specify Elements Page

10. Click Next. The Field Lengths for Multiple Record Files page is displayed.

11. Click the ruler at the desired position to mark fields on the sample text area, as shown in Figure 6–21 and click Next. The Field Properties page is displayed. 6-74 Oracle Fusion Middleware Users Guide for Technology Adapters Figure 6–21 Native Format Builder Wizard Field Lengths for Multiple Record Files Page

12. Check Use the first record as the field names, as shown in

Figure 6–22 . Figure 6–22 Native Format Builder Wizard Field Properties Page

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

in Figure 6–23 . Native Format Builder Wizard 6-75 Figure 6–23 Native Format Builder Wizard Native Format Schema File Page The corresponding native schema definition is similar to the definition of the CSV, file but style changes from nxsd:style=terminated to nxsd:style=fixedLength along with the relevant attributes for the fixed-length style. For the fixed-length style, the one mandatory attribute is the length: nxsd:length. The value of nxsd:length is the actual length of the data to be read. ?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.comFileIn_1 targetNamespace=http:TargetNamespace.comFileIn_1 elementFormDefault=qualified attributeFormDefault=unqualified nxsd:version=NXSD nxsd:stream=chars nxsd:encoding=ASCII nxsd:hasHeader=true nxsd:headerLines=1 nxsd:headerLinesTerminatedBy={eol} xsd:element name=AddressBook xsd:complexType xsd:sequence xsd:element name=Address minOccurs=1 maxOccurs=unbounded nxsd:style=array nxsd:cellSeparatedBy={eol} xsd:complexType xsd:sequence xsd:element name=Name type=xsd:string nxsd:style=fixedLength nxsd:length=22 xsd:element name=Street type=xsd:string nxsd:style=fixedLength nxsd:length=8 xsd:element name=City type=xsd:string nxsd:style=fixedLength nxsd:length=12 xsd:element name=State type=xsd:string 6-76 Oracle Fusion Middleware Users Guide for Technology Adapters nxsd:style=fixedLength nxsd:length=10 xsd:element name=Country type=xsd:string nxsd:style=fixedLength nxsd:length=7 xsd:sequence xsd:complexType xsd:element xsd:sequence xsd:complexType xsd:element xsd:schema

14. Click Test. The Test NXSD Schema dialog is displayed, as shown in

Figure 6–24 . Figure 6–24 Test NXSD Schema Dialog

15. Click the Generate XML icon. The resultant XML is displayed on the Result XML

pane of the Test NXSD Schema dialog, as shown in Figure 6–25 . Native Format Builder Wizard 6-77 Figure 6–25 Test NXSD Schema Dialog The native data using the corresponding native schema format is translated into the following XML: ?xml version = 1.0 encoding = UTF-8? AddressBook xmlns=http:TargetNamespace.comRead Address NameABC Private Limited Name StreetStreet1 Street City Bangalore City StateKarnataka State CountryIndiaCountry Address Address NameXYZ Private Limited Name StreetStreet1 Street City Bangalore City StateKarnataka State CountryIndia Country Address AddressBook

16. Click OK. The Generated Native Format File page is displayed, as shown in

Figure 6–23 .

17. Click Next. The Native Format Builder Finish page is displayed, as shown in

Figure 6–15 .

18. Click Finish. The Adapter Configuration Wizard Messages page is displayed, as

shown in Figure 6–16 , that contains the generated NXSD. 6-78 Oracle Fusion Middleware Users Guide for Technology Adapters

6.4.3 Defining the Schema for a Complex File Structure

The file structure of an invoice is more complex than the structure of CSV, SV, and fixed-length files discussed in the preceding use cases. An invoice usually contains buyer information, seller information, and line items. Each of these elements, in turn, can be of complex type. For example, the buyer element can be defined as a partner-type, where partner-type consists of three elements - id, name, and address. Use the Complex Type option in the Native Format Builder wizard when creating the XML schema for this native file. In this use case, the Native Format Builder uses invoice.txt, a complex file type called invoice, which contains multiple records such as buyer, seller, and items. 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, invoice.txt, appears as below:

6335722Company OneFirst Street 999 San Jose 95129USCA650-801-6250 OracleBridge Parkway 1600 Redwood Shores 94065USCA650-506-7000 001|BPEL Process Manager Enterprise Edition|20000,2,+40000+ 002|BPEL Process Manager Standard Edition|10000,5,+50000+ 003|BPEL Process Manager Developer Edition|1000,20,+20000+110000 2. Launch the Adapter Configuration Wizard and navigate to the Messages page, as displayed in Figure 6–4 , and click Define Schema For Native Format. The Native Format Builder Welcome page is displayed, as shown in Figure 6–5 .

3. Click Next. The Choose Type page is displayed, as shown in

Figure 6–26 . Figure 6–26 Native Format Builder Wizard Choose Type Page

4. Select Complex Type Contains records whose fields may themselves be records

having multiple delimiter types .

5. Click Next. The Native Format Builder File Description page is displayed.

6. Click Browse and select the invoice.txt file, and enter Invoice in the Root

Element field, as displayed in Figure 6–27 . Native Format Builder Wizard 6-79 Figure 6–27 Native Format Builder Wizard File Description Page

7. Click Next. The Native Format Builder Design Schema is displayed, as shown in

Figure 6–28 . Figure 6–28 Native Format Builder Wizard Design Schema Page Create the partner-type Complex Type The schema structure that you can build using the invoice.txt sample is as follows: Invoice Buyer = partner-type Seller = partner-type Items = item-type