Defining the Schema for a Complex File Structure

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 6-80 Oracle Fusion Middleware Users Guide for Technology Adapters Invoice-total = double The first line in the native data consists of buyer details, followed by seller details, followed by line items, and finally the total for the line items. Both buyer and seller elements have the same complex structure, as follows: ■ The first seven characters are the UID ■ This is followed by the buyerseller name surrounded by . ■ This is followed by the address until the end of the line.

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

created in the Schema Tree under Invoice, as shown in Figure 6–29 . Figure 6–29 Native Format Builder Wizard Design Schema Page

2. 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.

3. Enter partner-type in the Complex Type Name field, as shown in

Figure 6–30 . Native Format Builder Wizard 6-81 Figure 6–30 Native Format Builder Wizard Design Schema Page - Complex Type Details Dialog

4. Click the ruler at the desired position to mark fields on the sample text area, and

then click the Generate Fields button. The system tries to interpret the style of data for the defined fields.

5. Enter id, name, and address in the Name field, as shown in

Figure 6–31 . Note: For the Fixed Length or Mixed Delimiter type options, a ruler-based text area is displayed. You have to use the rulers to identify fields within the sample text. In case of delimited data, select or enter the appropriate delimiter in the Delimited By field. 6-82 Oracle Fusion Middleware Users Guide for Technology Adapters Figure 6–31 Complex Type Details Dialog

6. Click the pencil icon adjacent to each field to display the corresponding Edit Field

Details dialog that enables you to edit the field properties. For example, click the pencil icon adjacent to the Name field. The Edit Field Details dialog is displayed, as shown in Figure 6–32 . Figure 6–32 Edit Field Details Dialog 7. Edit the following field properties, as shown in Figure 6–32 . Native Format Builder Wizard 6-83 ■ Type : The data type of the sample text. Select String from the Type list. ■ Style : Represents the style of the complex type element. You can select any of the following four options: – fixed length – surrounded – terminated – leftright surrounded In this example, select surrounded. ■ Surrounded By : This option is displayed when you select surrounded in the Style option. In this example, enter caret in the Surrounded By field. The field properties displayed on this panel correspond to the NXSD attributes used in the schema.

8. Click OK. The Complex Type Details dialog is displayed with the field properties

that you selected. 9. Verify or edit the field properties for id and address Name fields.

10. Click OK in the Complex Type Details dialog. The Native Format Builder Design

Schema page is displayed, as shown in Figure 6–33 . Figure 6–33 Native Format Builder Wizard Design Schema Page - partner-type Complex Type Create an address-type Complex Type The address element can be further defined as another complex-type that contains a fixed-length street, city, and so on.

1. Create another new_complex_type node in the Schema Tree. See Step 1 in

Create the partner-type Complex Type .

2. Drag and drop the address part in the first row of the sample text to the Complex

Type, new_complex_type. The Complex Type Details dialog is displayed. 6-84 Oracle Fusion Middleware Users Guide for Technology Adapters

3. Enter address-type in the Complex Type Name field.

4. Click the ruler to mark fields on the sample text area, and then click the Generate

Fields button. Now, enter street1, street2, city, zip, country, state, and phone in the Name field, as shown in Figure 6–34 . Figure 6–34 Native Format Builder Wizard Design Schema Page - Complex Type Details Dialog

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

in Figure 6–35 . Native Format Builder Wizard 6-85 Figure 6–35 Native Format Builder Wizard Design Schema Page Assign the address-type Complex Type to address field of partner-type Complex Type You must assign the address-type complex type to the address field of the partner-type complex type. You can assign a complex type to an element by using one of the following methods: ■ Drag and drop the address-type node on the address field node of the partner-type complex type. This instantly assigns address-type to the address field element. ■ Select the address field node of the partner-type complex type and then click the pencil icon. The Edit Field Details dialog is displayed, as shown in Figure 6–36 . Figure 6–36 Edit Field Details Dialog

6. Select the address-type option in the Type list, and click OK. The address-type

option is assigned to the address field element in the Native Format Builder Design Schema page, as shown in Figure 6–37 . 6-86 Oracle Fusion Middleware Users Guide for Technology Adapters Figure 6–37 Native Format Builder Wizard Design Schema Page Create buyer and seller Global Elements 1. Select Invoice, and click the Add Element icon. An element, new_element, is created in the Schema Tree under the root element, Invoice.

2. Rename it to buyer.

3. Again, select Invoice, and click the Add Element icon. An element, new_

element, is created in the Schema Tree under Invoice. 4. Rename it to seller. Now, drag and drop the partner-type node on each of the buyer and seller nodes, to assign the partner-type complex type to these nodes. The Schema Tree appears, as shown in Figure 6–38 . Native Format Builder Wizard 6-87 Figure 6–38 Native Format Builder Wizard Design Schema Page Create item-type Complex Type, and items and invoice-total Element Nodes The items element can be considered an array of item-types. The last line item in the native file ends with the number sign , followed by the line-item total.

1. Select Invoice, and click the Add Element icon. An element, new_element, is

created in the Schema Tree under Invoice. 2. Rename it to items. 3. Create the item-type complex type and define the field properties, as shown in Figure 6–39 . Figure 6–39 Native Format Builder Wizard Design Schema Page 6-88 Oracle Fusion Middleware Users Guide for Technology Adapters

4. Drag and drop item-type complex type to the items element to assign item-type to

this element.

5. Select items - item-type and click the pencil icon. The Element Details dialog is

displayed. Figure 6–40 Element Details Dialog

6. Set the following properties in the Element Details dialog, as shown in

Figure 6–40 :

1. Set Max. Occurence - UNBOUNDED

2. Select Array. The Cell Separator and Array Separator are enabled.

3. Set Cell Separator - {eol}

4. Set Array Separator -

7. Click OK.

8. Create the invoice-total element, and drag and drop the sample text 110000 on the new_element node. The Element Details dialog is displayed.

9. Enter invoice-total in the Element Name field, and click Generate Fields. The

Alert message is displayed, as shown in Figure 6–41 . Note: The element items is defined as an array of item-type. Native Format Builder Wizard 6-89 Figure 6–41 Element Details Dialog - Alert Message If a single field is identified in the sampled data for a global element, then the properties of this data are applied to the global element itself.

10. Click OK in the Alert message. The Element Details dialog is displayed.

11. Select double in the Data Type list, and click OK. The Native Format Builder

Design Schema page is displayed, as shown in Figure 6–42 . Figure 6–42 Native Format Builder Wizard Design Schema Page - Complete Schema Tree 6-90 Oracle Fusion Middleware Users Guide for Technology Adapters

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

in Figure 6–43 , which displays the native format file. Figure 6–43 Native Format Builder Wizard Generated Native Format File Page The native schema definition corresponding to the preceding native data can be defined as follows: schema attributeFormDefault=qualified elementFormDefault=qualified targetNamespace=http:xmlns.oracle.comiaspcbpelfatransschemademo xmlns:tns=http:xmlns.oracle.comiaspcbpelfatransschemademo xmlns=http:www.w3.org2001XMLSchema xmlns:nxsd=http:xmlns.oracle.compcbpelnxsd nxsd:version=NXSD nxsd:stream=chars element name=invoice type=tns:invoiceType complexType name=invoiceType sequence element name=purchaser type=tns:partnerType element name=seller type=tns:partnerType element name=line-item type=tns:line-itemType maxOccurs=unbounded nxsd:style=array nxsd:cellSeparatedBy={eol} nxsd:arrayTerminatedBy= element name=total type=double nxsd:style=terminated nxsd:terminatedBy={eol} sequence complexType complexType name=partnerType sequence element name=uid type=string nxsd:style=fixedLength nxsd:length=7 nxsd:padStyle=tail nxsd:paddedBy= element name=name type=string nxsd:style=surrounded nxsd:surroundedBy= element name=address type=tns:addressType sequence Native Format Builder Wizard 6-91 complexType complexType name=addressType sequence element name=street1 type=string nxsd:style=fixedLength nxsd:length=15 nxsd:padStyle=tail nxsd:paddedBy= element name=street2 type=string nxsd:style=fixedLength nxsd:length=10 nxsd:padStyle=tail nxsd:paddedBy= element name=city type=string nxsd:style=fixedLength nxsd:length=15 nxsd:padStyle=tail nxsd:paddedBy= element name=postal-code type=string nxsd:style=fixedLength nxsd:length=5 nxsd:padStyle=none element name=country type=string nxsd:style=fixedLength nxsd:length=2 nxsd:padStyle=none element name=state type=string nxsd:style=fixedLength nxsd:length=2 nxsd:padStyle=none element name=phone type=string nxsd:style=terminated nxsd:terminatedBy={eol} sequence complexType complexType name=line-itemType sequence element name=uid type=string nxsd:style=fixedLength nxsd:length=3 nxsd:padStyle=none element name=description type=string nxsd:style=surrounded nxsd:surroundedBy=| element name=price type=double nxsd:style=terminated nxsd:terminatedBy=, element name=quantity type=integer nxsd:style=terminated nxsd:terminatedBy=, element name=line-total type=double nxsd:style=surrounded nxsd:surroundedBy=+ sequence complexType schema

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

Figure 6–44 . 6-92 Oracle Fusion Middleware Users Guide for Technology Adapters Figure 6–44 Test NXSD Schema Dialog

14. 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–45 . Figure 6–45 Test NXSD Schema Dialog - Result XML The translated XML looks as follows: Native Format Builder Wizard 6-93 invoice xmlns=http:xmlns.oracle.compcbpeldemoSchemainvoice-nxsd purchaser uid6335722uid nameCompany Onename address street1First Streetstreet1 street2999street2 citySan Josecity postal-code95129postal-code countryUScountry stateCAstate phone650-801-6250phone address purchaser seller uid nameOraclename address street1Bridge Parkwaystreet1 street21600street2 cityRedwood Shorescity postal-code94065postal-code countryUScountry stateCAstate phone650-506-7000phone address seller line-item uid001uid descriptionBPEL Process Manager Enterprise Editiondescription price20000price quantity2quantity line-total40000line-total line-item line-item uid002uid descriptionBPEL Process Manager Standard Editiondescription price10000price quantity5quantity line-total50000line-total line-item line-item uid003uid descriptionBPEL Process Manager Developer Editiondescription price1000price quantity20quantity line-total20000line-total line-item total110000total invoice

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

Figure 6–43 .

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

Figure 6–15 .

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

containing the generated NXSD, as shown in Figure 6–16 . 6-94 Oracle Fusion Middleware Users Guide for Technology Adapters

6.4.4 Removing or Adding Namespaces to XML with No Namespace

When the native data is XML and that XML has no namespace, the Native Format Translator can be used to add a namespace to an inbound XML document and remove the namespace from an outbound XML document. The XML has no namespace when either of the following is true: ■ The XML has a corresponding XML schema, and there is no target namespace specified in that XML schema. ■ The XML has a corresponding DTD, which was converted to the XML schema. In both cases, you must create a wrapper schema with targetNamespace specified, and the wrapper schema must include the actual schema. In addition, the wrapper schema must also have the nxsd:version attribute set to DTD. For example: --wrapper.xsd ?xml version=1.0 encoding=UTF-8? schema xmlns=http:www.w3.org2001XMLSchema targetNamespace=myNamespace xmlns:nxsd=http:xmlns.oracle.compcbpelnxsd nxsd:version=DTD include schemaLocation=actual.xsd schema Using this wrapper.xsd file in place of the original .xsd file would add the myNamespace namespace to the inbound XML and would remove the myNamespace namespace from the outbound XML.

6.4.5 Defining the Choice Condition Schema for a Complex File Structure

In this use case, the Native Format Builder uses order.txt, a complex type file, which contains multiple record types such as order, customer, 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, order.txt, appears as below: Order, ID41678, 20May2000 Item1, GigaWidget, 60, 75 Item2, MegaBucket, 48, 125 Cust1, Hopkins Associates, ID26490 Order, ID41680, 20May2000 Item3, Rt.Clopper, 40, 100 Item4, Lt.Clopper, 50, 100 Cust2, Jersey WebInovaters, ID46786 2. Create the following complex types by dragging one row each of order, customer, and item native data: ■ OrderType ■ ItemType ■ CustomerType Note: Ensure that elementFormDefault=qualified is specified in the actual schema. Native Format Builder Wizard 6-95 For more information about creating a complex type, see Section 6.4.3, Defining the Schema for a Complex File Structure . The Native Format Builder Design Schema page is displayed, as shown in Figure 6–46 . Figure 6–46 Native Format Builder Design Schema Page

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

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

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

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

choice node. 6. Rename the newly added element to OrderChoice, and then drag and drop the OrderType complex type element to OrderChoice.