1. Problem
You want to create an address data type that can be reused, rather than creating the same set of data for every address type.
2. Solution
You can use XSD complex
types within the BizTalk Editor. As an example, assume that you need to
create your own complex data type for storing shipping addresses for an Order schema:
<Order>
<CompanyName> </CompanyName>
<OrderID> </ OrderID>
<OrderDate> </OrderDate>
<OrderAmount></ OrderAmount >
<ShipTo>
<CompanyID> </CompanyID>
<AddressLine1> </AddressLine1>
<AddressLine2> </AddressLine2>
<AddressLine3> </AddressLine4>
<Zip> </Zip>
</ShipTo>
<ShipFrom>
<CompanyID> </CompanyID>
<AddressLine1> </AddressLine1>
<AddressLine2> </AddressLine2>
<AddressLine3> </AddressLine4>
<Zip> </Zip>
</ShipFrom>
</Order>
For this example, the Order schema has been built with Order Header nodes and the <ShipTo> record. The following steps outline how to create a complex type to be the data type for the <ShipTo> and <ShipFrom> addresses. You will model the data type of the existing <ShipTo> record.
Open the project that contains the schema.
Double-click the schema (the Order schema in this example) to open it, as shown in Figure 1.
Click the existing record on which you want to base the complex type (the <ShipTo> record in the Order schema in this example).
In the Properties window, click Data Structure Type, and type Address in the box. This step will now automatically recognize the record as a complex data type.
Now you can reuse the complex type. For example, here are the steps to create a record that uses the sample complex type:
Click the Order schema node.
Right-click and select Insert Schema Node => Child Record. Type the record name ShipFrom.
In the Properties window of the newly created ShipForm child record, click Data Structure Type, and select the complex type that is now available, Address.
This procedure creates the Address complex type element structure under the ShipFrom record. A sequence instruction is created under both the ShipFrom and ShipTo records to implement the complex type. Figure 2 shows the finished schema.
3. How It Works
The example demonstrated
creating a complex type data type based on an existing schema record
within the schema. By XSD definition, a complex type
is an element (record) that has child elements or attributes. Complex
types can be used to implement custom schema rules and XSD data
structure considerations for records, elements, and attributes. For
example, you might use complex data types for validation rules via XSD
regular expressions, schema cardinality, and order. In addition, you can
make data type references to your complex types, allowing you to reuse
record structures and XSD implementations.
A complex type is derived from the base data type anyType;
that is, in the purest form, a complex type is in essence a stand-alone
base type, in which you can define your own XSD structure
representation and schema rules.
NOTE
A simple type is an element that in itself is defined and does not have children. For example, you might have a simple type named Order ID, which has a length limit of six and must start with an A
character. In this instance, an XSD length restriction could be
defined, along with a regular expression to check that the order starts
with the letter A: <OrderID> Axxxxx </ OrderID>.