BizTalk Server: Deep Dive in Schema Design

BizTalk Server: Deep Dive in Schema Design

This article was started after reading this question on forum.

 

Introduction


Schema is a definition of a document which describes the structure of that particular document. In BizTalk there are two common types of structures which mainly deal with XML based and Flat Files.This article intends to explain bits and bytes of designing BizTalk Schema(XML).

Example used in article 



  <?xml version="1.0" encoding="utf-16" ?>
- <xs:simpleType name="eMailType">
- <xs:restriction base="xs:string">
  <xs:pattern value="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" />
  </xs:restriction>
  </xs:simpleType>
- <xs:element name="Order">
- <xs:annotation>
- <xs:appinfo>
- <b:properties>
  <b:property distinguished="true" xpath="/*[local-name()='Order' and namespace-uri()='http://TestingSchemas.IncomingOrder']/*[local-name()='Header' and namespace-uri()='']/*[local-name()='OrderId' and namespace-uri()='']" />
  <b:property distinguished="true" xpath="/*[local-name()='Order' and namespace-uri()='http://TestingSchemas.IncomingOrder']/*[local-name()='Header' and namespace-uri()='']/*[local-name()='OrderDate' and namespace-uri()='']" />
  </b:properties>
  </xs:appinfo>
  </xs:annotation>
- <xs:complexType>
- <xs:sequence>
- <xs:element name="Header">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="OrderId" type="xs:string" />
  <xs:element name="OrderDate" type="xs:string" />
  <xs:element name="Currency" type="xs:string" />
- <xs:element minOccurs="0" maxOccurs="1" name="ShipTo">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="ID" type="xs:string" />
  <xs:element name="Name" type="xs:string" />
  <xs:element name="AddressLine1" type="xs:string" />
  <xs:element name="AddressLine2" type="xs:string" />
  <xs:element name="City" type="xs:string" />
  <xs:element name="State" type="xs:string" />
  <xs:element name="PostalCode" type="xs:string" />
  <xs:element name="Country" type="xs:string" />
  <xs:element name="TelephoneNumber" type="xs:string" />
  <xs:element name="EmailAddress" type="eMailType" />
  </xs:sequence>
  </xs:complexType>
  </xs:element>
- <xs:element minOccurs="0" maxOccurs="1" name="BillTo">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="ID" type="xs:string" />
  <xs:element name="Name" type="xs:string" />
  <xs:element name="AddressLine1" type="xs:string" />
  <xs:element name="AddressLine2" type="xs:string" />
  <xs:element name="City" type="xs:string" />
  <xs:element name="State" type="xs:string" />
  <xs:element name="PostalCode" type="xs:string" />
  <xs:element name="Country" type="xs:string" />
  <xs:element name="TelephoneNumber" type="xs:string" />
  <xs:element name="EmailAddress" type="eMailType" />
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  <xs:element name="HeaderComment" type="xs:string" />
  </xs:sequence>
  </xs:complexType>
  </xs:element>
- <xs:element name="Details">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="1" maxOccurs="unbounded" name="Item">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="ItemId" type="xs:string" />
  <xs:element name="ItemDescription" type="xs:string" />
  <xs:element name="Quantity" type="xs:string" />
  <xs:element name="UnitPrice" type="xs:string" />
  <xs:element name="LineNumber" type="xs:string" />
  <xs:element name="UOM" type="xs:string" />
  <xs:element name="RequestedDeliveryDate" type="xs:string" />
  <xs:element name="LineComment" type="xs:string" />
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:schema>
Code Block 1. Sample schema 

Building blocks of schema

Schema is created with the help of following components:

  1. BizTalk Schema Editor.
  2. Encoding.
  3. Namespace.
  4. Properties.
  5. Root Node and properties associated with it.
  6. Record Node and properties associated with it.
  7. Element and properties associated with it.
  8. Attributes and properties associated with it.
  9. Properties associated with Schema.

BizTalk Schema Editor


The BizTalk Editor shows the schema in two sections, first section on left shows  the tree view and the second section shows the XSD code.
Properties window can be found at right bottom of the screen, which is used to set properties of the nodes. 

Note: XSD code can only be viewed and cannot be edited.

Figure 1. BizTalk Schema Editor.

Encoding

BizTalk always uses UTF-16 encoding for their schemas.

<?xml version="1.0" encoding="utf-16" ?>

Namespace


By default, the BizTalk Editor will set the namespace of a schema to http://ProjectName.SchemaName. 

Note: http://schemas.microsoft.com/BizTalk/2003 and http://www.w3.org/2001/XMLSchema are also added by BizTalk and are implicit. Basically both are references to definitions,annotations defined by BizTalk and W3.org, it is the reason why we are able to build schema.


Common Properties across Root Node,Record Node,Element Field,Attribute Field

Properties

Description

Available For

Base Data Type

Determines the name of the type definition that the current node type is based upon.

Root Node, Record Node, Element Field,Attribute Field

Block

The Block property is used to prevent specific types of derivation to be used in place of this Node. Default value is ’None’.

Root Node, Record Node

Content Type

Content model of the complex type (either of ComplexContent, SimpleContent,None).Default is ‘None’.

Root Node, Record Node

Data Structure Type

Indicates the structure type of the record. Usually is a global complex type or named reference to a global element.

Root Node, Record Node

Group Max Occurs

Maximum Occurrences of the underlying group content of this Node. Its value should always be greater than or equal to Group Min Occurs. Default value is ‘1’.

Root Node, Record Node

Group Min Occurs

Minimum Occurrences of the underlying group content of this Node. Its value should always be less than or equal to Group Max Occurs. Default value is ‘1’.

Root Node, Record Node

Group Order Type

Determines the type of group ordering for children nodes under the current context. Available options are Sequence, Choice, All.

Root Node, Record Node

Mixed

Determines whether the sub elements in the current context can be intermingled with text content. Default is ‘False’.

Root Node, Record Node

Nillable

Determines whether this node can be null in the instance document. Default is ‘False’.

Root Node, Record Node, Element Field

Node Name

Name of the Node.

Root Node, Record Node, Element Field, Attribute Field

Notes

This property is used to access a dialog for entry of what are effectively business level comments about the node with focus.

Root Node, Record Node, Element Field, Attribute Field

Max Occurs

Maximum Occurrences of this node.Its value should always be greater than or equal to minOccurs of this node. Use ‘unbounded’ or ‘*’ to indicate unlimited occurrences. Default value is ‘1’.

Record Node, Element Field

Min Occurs

Minimum occurrences of this node. Its value should always be less than or equal to MaxOccurs for this node. Default value is ‘1’.

Record Node, Element Field

Data Type

Data Type of the Node

Element Field, Attribute Field

Default Value

Default value of this node

Element Field, Attribute Field

Derived By

Indicates how the underlying Simple Type of the Field is derived from its base data type. Options available are Restriction, List and Union.

Element Field, Attribute Field

Fixed

The fixed attribute is used to ensure that the field is set to particular fixed value.

Element Field, Attribute Field

Form

During instance validation, determine whether the items in the current context must be qualified with a namespace. Options are Qualified and Unqualified.

Element Field, Attribute Field

Table 1. Listing of common properties,description and available for.

Root Node and properties associated with it

Root node is a special type of Record Node which has at least one child and no parent. Whenever you create a schema in BizTalk schema editor a Root node will be added automatically with name as "Root".It can be renamed, and its best practice to name it after the purpose , say "Order" if it is for order.




Figure 2.Properties available for Root Node.

Record Node and properties associated with it



Figure 3.Properties available for Record Node.

Element and properties associated with it


Figure 4.Properties available for Element Field.

Attributes and properties associated with it


Figure 5.Properties available for Attributes.

Properties associated with Schema

 
Figure 6.Properties available for Schema.

[More Content will be added soon]



Author

Maheshkumar S. Tiwari
iVision Software Pvt Ltd|User Page
http://tech-findings.blogspot.com/


See Also


Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.

Another important place to find a huge amount of TechNet Wiki related articles is Wiki: List of Articles for TechNet Wiki

This article participates in the TechNet Guru for September competition 
Leave a Comment
  • Please add 6 and 8 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
Page 1 of 2 (15 items) 12
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Maheshkumar S Tiwari edited Original. Comment: Added tags

  • Maheshkumar S Tiwari edited Revision 1. Comment: Added TOC and tag

  • Maheshkumar S Tiwari edited Revision 3. Comment: Added text

  • Maheshkumar S Tiwari edited Revision 6. Comment: Added code block

  • Maheshkumar S Tiwari edited Revision 8. Comment: Added content in Namespace

  • Maheshkumar S Tiwari edited Revision 9. Comment: Added some content

  • Maheshkumar S Tiwari edited Revision 10. Comment: Added images and tag

  • Maheshkumar S Tiwari edited Revision 11. Comment: Added text

  • Maheshkumar S Tiwari edited Revision 12. Comment: Added some content

  • Maheshkumar S Tiwari edited Revision 15. Comment: Added some content

  • Maheshkumar S Tiwari edited Revision 16. Comment: Added content in Namespace

  • Maheshkumar S Tiwari edited Revision 17. Comment: Added text

  • Maheshkumar S Tiwari edited Revision 18. Comment: Added content in Root node section

  • Maheshkumar S Tiwari edited Revision 19. Comment: Added text

  • Maheshkumar S Tiwari edited Revision 20. Comment: Added Common properties section

Page 1 of 2 (17 items) 12