This example shows how to build a Flat File Schema to parse a mix of positional and delimited data. To create a Flat File Schema, you must first analyze your Flat File data to determine what fields and nodes to added to the Flat File Schema. In this example, you create a Flat File Schema for the following two lines of data:
BuyRight Pharmacy;USACAMVI334;!389!22;34980;
Taylor Drugs;USANJWLB128;!778!23!523;5667;
Use a top-down approach for defining the records and fields of the Flat File Schema as shown in the following steps:
Using these criteria, specify the following values for the Basic Properties and Delimiters pane of the Order node as shown in Figure 2:
Using these criteria, specify the following values for the Basic Properties and Delimiters pane of the purchaseOrder node as shown in Figure 4:
The Field Offset is calibrated from the current character location as the originCode string is being processed and not from the beginning of the originCode string for each field. In this example, the countryCode is processed and the first three characters of the originString are assigned to the countryCode. When the stateCode is processed, the current character location is already at the 3 character location, so the Field Offset of 1 of stateCode is added to the current character location to get the starting point for processing the stateCode string as shown in Figure 6:
Using these criteria, specify the following values for the Basic Properties and Delimiters pane of the items node as shown in Figure 8:
BuyRight Pharmacy;USACAMVI334;!389!22;34980;
Taylor Drugs;USANJWLB128;!778!23!523;5667;
<?xml version="1.0" encoding="UTF-8"?> <Order> <purchaseOrder> <storeName>BuyRight Pharmacy</storeName> <originCode> <countryCode>USA</countryCode> <stateCode>CA</stateCode <cityCode>MVI</cityCode> <storeCode>334</storeCode> </originCode> <items> <item>389</item> <item>22</item> </items> <orderId>34980</orderId> </purchaseOrder> <purchaseOrder> <storeName>Taylor Drugs</storeName> <originCode> <countryCode>USA</countryCode> <stateCode>NJ</stateCode> <cityCode>WLB</cityCode> <storeCode>128</storeCode> </originCode> <items> <item>778</item> <item>23</item> <item>523</item> </items> <orderId>5667</orderId> </purchaseOrder> </Order>