This walkthrough shows you how to create a flat file schema from a document instance using the BizTalk Flat File Schema Wizard based on the following sample purchase order. For an introduction to the BizTalk Flat File Schema Wizard, see How to Use BizTalk Flat File Schema Wizard.
Each line of the purchase order ends with a carriage return line feed (CRLF), marked in green. The purchase order starts with a PO tag shown in red and followed by a date. Two repeating fixed positional fields contain customer information and are shown in purple. After the comment field, there is a repeating field starting with an ITEMS tag that contains multiple records delimited by commas (,) and data values separated by pipes (|), which are shown in blue.
Before exercising this walkthrough, make sure the following software is installed and configured on your server:
-
Microsoft Visual Studio 2005
-
Microsoft BizTalk Server 2006 with the following components installed:
To prepare the document instance for the walkthrough, copy the following to Notepad and save it as a text file.
PO1999-10-20
US Alice Smith 123 Maple Street Mill Valley CA 90952
US Robert Smith 8 Oak Avenue Old Town PA 95819
ITEMS,ITEM872-AA|Lawnmower|1|148.95|Confirm this is electric,ITEM926-AA|Baby Monitor|1|39.98|Confirm this is electric
-
In Microsoft Visual Studio 2005, open the Solution Explorer.
-
To add the new flat file schema, right-click the project, and select Add. Click New Item.
-
In the Add New Item window, do the following:
-
In the Categories section, select Schema Files.
-
In the Templates section, select Flat File Schema Wizard.
-
In the Name field, enter PurchaseOrder.xsd for the new schema.
-
Click Add.
-
When the BizTalk Flat File Schema Wizard opens, the Welcome Page appears.
To skip this screen when running the wizard in the future, select the Do not show this introduction page again box. Click Next to continue.
Selecting Document Instance
To select purchase order instance
Selecting Document Instance Data
To select purchase order data
To delimit purchase order record
Specifying Record Data Property
To specify purchase order record property
Defining Element Property in Record Data
To define the element in the purchase order record
-
The wizard has identified four elements in the purchase order record; you must now define the element property. In the first row, do the following:
-
Type date for the Element Name.
-
Select Field element for Element Type.
-
Select date from the drop-down selection list for Data Type.
-
Repeat Steps a to c for the following elements. When you are done, click Next.
|
Element Name
|
Element Type
|
Data Type
|
|---|
|
customer
|
Repeating record
|
|
|
|
Ignore
|
|
|
items
|
Record
|
|
Note |
|---|
|
You can select multiple rows and then change their Element Type to a single type by using the mouse and the Shift or Ctrl button.
|
Note |
|---|
|
After you click Next on the Child Elements screen, you will not be able to click Back to redefine or make any changes to the child elements. You may need to close the wizard and launch the wizard again to define the flat file schema.
|
-
After you complete the steps in this procedure, the first level of the schema is generated as shown in the following screenshot. Three unique elements are defined, and you will continue to further define the child records for the elements in the purchase order record. Click Next.
Defining the Element Type of Record
To define customer record
-
Because we defined the customer element as the Repeating record type and the items element as the Record type, the BizTalk Flat File Schema Wizard now continues to further define these two elements. On the Schema View screen, select customer and click Next to continue.
-
To work with the customer record, you need to select the data that represents that element. Because it is a repeating record, either of the lines can be used to define the record. Select the first line of customer data and click Next to continue.
-
On the Select Record Format page, select By relative positions, and then click Next.
-
The wizard provides a visual tool for showing and calculating the distance between the fields. On the Positional Record page, use the left mouse button to click the position marker 10 to represent where the name field begins. Click the following position markers to represent the rest of the data fields:
|
Field Name
|
Position Marker
|
|---|
|
street
|
30
|
|
city
|
50
|
|
state
|
65
|
|
postalcode
|
68
|
Click Next to continue.
-
On the Child Elements page, you specify the properties of the child elements. Select the first row and type country as the Element Name. Leave the default values in the other columns. Type the following values for the other properties for the Element Name:
|
Element Name
|
Value
|
|---|
|
customer_Child2
|
fullName
|
|
customer_Child3
|
street
|
|
customer_Child4
|
city
|
|
customer_Child5
|
state
|
|
customer_Child6
|
postalcode
|
Click Next to continue.
-
The child elements of the customer record are created as shown in the following screenshot. Click Next to define the child elements for the items record.
To define the items record
-
On the Schema View page, select items and click Next.
-
On the Select Document Data page, select the entire line begins with ITEMS and click Next to define its child elements.
-
On the Select Record Format page, select By delimiter symbol and click Next.
-
In the Items record, commas are used to delimit the individual items. Therefore, on the Delimited Record page, enter the following to define the items record. When you are done, click Next.
-
Select , from Child delimiter drop down selection list.
-
Leave the Escape character text box blank.
-
Select Record has a tag identifier and type ITEMS in Tag.
In a multiple items record, ITEMS is used to identify each individual record.
-
Using the values from the Delimited Record page, the wizard identifies two child elements. Because one of them is a repeating record, select the first element and enter item for Element Name, and then select Repeating Record from the drop down selection list for Element Type. Leave the rest of the default values in the columns. Select the second row and select the Ignore from Element Type list. When you click Next, the next level for the items record is created in the schema. You continue to define the final part of the purchase order schema.
-
Select item and then click Next to continue on the Schema View page.
-
On the Select Document Data page, select ITEM872-AA|Lawnmower|1|148.95|Confirm this is electric. Click Next to continue.
-
On the Select Record Format page, select the By delimiter symbol option because the individual item is delimited by a pipe (|).
-
On the Delimited Record page, enter the following to define the item record. When you are done, click Next.
-
Select | from the Child delimiter drop down selection list.
-
Leave the Escape character text box blank.
-
On the Child Elements page, the wizard has identified five child elements. Select the first row and enter productCode for Element name. Leave the default values in the rest of the columns. For the rest of the Element Name properties, type the following:
|
Element Name
|
Value
|
|---|
|
item_Child2
|
description
|
|
item_Child3
|
quantity
|
|
item_Child4
|
unitPrice
|
|
item_Child5
|
notes
|
Click Next to continue.
-
You have defined all the nodes for the purchase order schema. On the Schema View page, click Finish.
-
You can now view the final purchase order schema. You can also refine the schema by using the BizTalk Schema Editor. See Flat file property name table and the Property tables in Schema Node Properties.
In this walkthrough you have learned how to use the BizTalk Flat File Schema Wizard to create a flat file schema from a document instance.
Validating PO Instance
To ensure that the PurchaseOrder.xsd schema can correctly parse the PO instance, do the following:
-
In Solution Explorer, right-click the PurchaseOrder.xsd and then select Properties.
-
In the Property Pages, make sure that the Input Instance Filename field is pointing to the location of the PO instance you created in the Prerequisites section of Walkthrough: Creating a Flat File Schema From a Document Instance. Click OK to close the dialog.
-
In Solution Explorer, right-click PurchaseOrder.xsd and then select Validate Instance. The validation component opens.
-
After validation is completed, a link is provided to you for viewing the XML output based on parsing result on PO instance using the PurchaseOrder.xsd schema. To view the XML output, press Ctrl and click the link.
Creating Pipelines for the Schema
Concepts
How to Use BizTalk Flat File Schema Wizard
Other Resources
Creating Schemas Using BizTalk Flat File Schema Wizard