Reusable Schema In Biztalk

The reusability of schema can be achieved through schema import and definition of simple and complex types, here is a very simple guide line as how to and what to do in terms of reusable schema design in Biztalk

1.Schema Import, Include, and Redefine

The schema that is to be imported must have targeted name space

The schema that is to be included or redfined must have targeted name space and the targeted name space must be same as the host

2. How to create simple type

Add a child element

At the data type of this element, enter a new name, this new name will be name for new simple type, and base data type for this new type will be one of those simple types already defined

If an existing type is selected for this child element, it will define this new child element with an existing simple type, rather than creating a new simple type

3. How to create complex type

Add a child record

At the data type of this record, enter a new name, this new name will be name for new complex type, and any further elements added to this record will be added to the new complex type too

If an existing type is selected for this child record, it will define this new child record with an existing complex type, rather than creating a new complex type

4. Base data type and Data type

If data type of new element is set , then the new element is of the set data type

If Base data type of new element is set, then the new element is of a new anonymous type that is derived from base data type with variations allowed

5. How to Reference an imported root

Only root level element of imported schema can be referenced, the referenced element has no data type defined, which makes it visible for reference

6. How to use namespace in xpath

You can either reference the namespace
/*[local-name()=’Root’ and namespace-uri()=’http://NameSpace’]/Head/BatchID
Or just use local-name in a namespace agnostic way
/*[local-name()=’Root’]/Head/BatchID

7. A final example

<?xml version="1.0" encoding="utf-16" ?> 
- <xs:schema xmlns="http://Test.SchemaTest" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ns0="http://Test.SchemaTest2" targetNamespace="http://Test.SchemaTest" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation=".\SchemaTest3.xsd" /> 
<xs:redefine schemaLocation=".\SchemaTest4.xsd" /> 
<xs:import schemaLocation=".\SchemaTest2.xsd" namespace="http://Test.SchemaTest2" /> 
- <xs:annotation>
- <xs:appinfo>
- <b:references>
<b:reference targetNamespace="http://Test.SchemaTest2" /> 
</b:references>
</xs:appinfo>
</xs:annotation>
- <xs:element name="Root">
- <xs:complexType>
- <xs:sequence>
<xs:element ref="ns0:Root2" /> 
<xs:element ref="Root3" /> 
<xs:element ref="Root4" /> 
<xs:element name="Record" type="ns0:Type2" /> 
<xs:element name="Field" type="ns0:Type3Simple" /> 
<xs:element ref="ns0:Root2" /> 
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Have fun

Tags:

This entry was posted on Tuesday, April 10th, 2012 at 1:15 am and is filed under ASP.NET, General. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

*