You can use the XSD Import method within the BizTalk Editor to reuse an existing common XML object structure within another, as opposed to manually creating an entire schema. As an example, assume you have two simple XML structures, Customer and Address:
<Customer>
<FirstName> </FirstName>
<LastName> </LastName>
<MiddleInit> </MiddleInit>
<Age></Age>
</Customer>
<Address>
<AddrLine1> </AddrLine1>
<AddrLine2> </AddrLine2>
<AddrLine3> </AddrLine3>
<Zip> </Zip>
<State> </State>
<Country> </Country>
</Address>
To use the XSD Import method to allow this scenario within BizTalk, follow these steps:
- Open the project that contains the existing schema (in this case, the Customer schema).
- Double-click the Customer schema to open it.
- Right-click the root node of the Customer schema, and select Properties.
- In the Properties window, click the ellipsis next to Imports to open the Imports dialog box, which is shown in Figure 1.
- Select XSD Import as the import type, and click the Add button.
- In the BizTalk Type Picker dialog box, select the Schemas tree node, and select the Address schema.
Figure 1. Imports dialog box
NOTE
In this example, the Address schema is within the current BizTalk project. If the schema existed outside the BizTalk project, the schema could be imported by selecting the Reference tree node.
The preceding procedure imports the Address schema into the Customer schema. To use the Address schema, follow these steps:
- Click the Customer node in the Customer schema.
- Right-click and select Insert Child Record.
- Click the newly created child record.
The Customer schema is now referencing and using the Address schema via the Imports schema method within the BizTalk tool set.
3. How It Works
Within the BizTalk tool set, there are a variety of ways in which you can construct XML schemas. The choices revolve around common architecture principles such as reuse, development best practices for schema organization, and fundamental development preferences.
This example illustrated using the Imports method for referencing schema. The Imports dialog box offers three choices for achieving the schema reference activity (step 5 of the recipe):
Include: This method physically includes a schema definition within another. The common usage would be to create a static reference of a schema during the schema build process. This choice could be used to leverage previously defined XSD schema (for example, publicly available schema). The include schema must be the same target namespace of the schema you are including. Alternatively, the target namespace of the include schema can be blank.
Import: The most commonly used import method within BizTalk, the Import option includes XSD Imports statements within the source schema definition. By using this option, namespaces and XSD object structures within the target schema are available for use within the source schema in read-only fashion. The practical application for this choice revolves around common reuse, such as reuse of an existing schema artifact or use of a publicly available XML schema.
Redefine: The least-common import method within BizTalk, the Redefine option, like the Import option, allows namespaces and XSD object references to be used within the source definition. However, the Redefine option allows objects and data structures to be overridden within the source definition. Common uses could be to create an inheritance model or to reuse and customize an existing XSD structure.
This example demonstrated referencing other schemas within the BizTalk tool set. However, while BizTalk provides and implements standard XSD instructions to achieve this functionality, common architecture usage and choices should not be ignored to ensure the correct schema reference method is selected.
No comments:
Post a Comment