Click here to Skip to main content
6,634,665 members and growing! (15,373 online)
Email Password   helpLost your password?
Enterprise Systems » Microsoft BizTalk Server » General     Intermediate

Design your Biztalk 2006 Schema - Part 1

By Selvan

A Beginers guide to Biztalk schema design
Windows, Visual Studio, Architect, Dev, QA, Design
Posted:5 Apr 2007
Views:14,363
Bookmarked:21 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
6 votes for this article.
Popularity: 2.92 Rating: 3.75 out of 5
1 vote, 16.7%
1

2
1 vote, 16.7%
3

4
4 votes, 66.7%
5

Introduction

Creating a Schema is defining a structure of the data, as similar to creating a table in database. Designing schema plays a vital role for the Integration project. This series of article I am planning to walk through Xml Schema design by giving more samples and pictures in Biztalk 2006.

Base Example

To give you a more common scenario I would take the below shown XML as the base example, from here we explore the changes in each sample.

<ns0:Employees xmlns:ns0="http://CyclicSubs.XmlSchemaEmployee">

<Employee ID="ID_0">

<Name>Name_0</Name>

<Age>Age_0</Age>

<Department>Finance</Department>

</Employee>

</ns0:Employees>

The above sample is the Employees record of a company, contains ID, Name, Age and Department.

Qualified XML

To generate the qualified xml instance out of schema would require few property changes in schema and field level.

Schema level qualified Attribute

Your system receives or the destination system expects the xml message with all attributes are marked with namespaces, design your schema as shown below

Choose Schema Node on the left pane and mark Attribute FormDefault property as "Qualified" (by default its "Unqualified") and your Schema Instance output will be as follows

XML Output

<ns0:Employees xmlns:ns0="http://CyclicSubs.XmlSchemaEmployee">

<Employee ns0:ID="ID_0">

<Name>Name_0</Name>

<Age>Age_0</Age>

<Department>Finance</Department>

</Employee>

</ns0:Employees>

Note: The entire schema attribute fields will be appended with "ns0" namespace (marked as Bold), in our case "ID" is the only attribute in the whole schema.

Schema level qualified Record / Element

Your system receives or the destination system expects the xml message with all elements are marked with namespaces, design your schema as shown below

Choose Schema Node on the left pane and mark Element FormDefault property as "Qualified" (by default its "Unqualified"), reset the Attribute FormDefault property back to "Default" and your Schema Instance output will be as follows

XML Output

<ns0:Employees xmlns:ns0="http://CyclicSubs.XmlSchemaEmployee">

<ns0:Employee ID="ID_0">

<ns0:Name>Name_0</ns0:Name>

<ns0:Age>Age_0</ns0:Age>

<ns0:Department>Finance</ns0:Department>

</ns0:Employee>

</ns0:Employees>

Note: The entire schema element field will be appended with "ns0" namespace (marked as Bold), in our case Name, Age and Employee are the field elements in the whole schema. How the Record "Employee" did append with ns0? In Biztalk term "Employee" is the Record but W3C standard consider it as a Complex element.

Single Qualified Attribute / Element

Can we make only the specific element/attribute as Qualified? Yes it's possible. Choose the specific Element/ Attribute on left pane and mark the "Form" property as "Qualified".

"designbiztalkschema1/4.jpg" />

Note: In the above example Name element under Employee record as marked as "Qualified"

XML Output

<ns0:Employees xmlns:ns0="http://CyclicSubs.XmlSchemaEmployee">

<Employee ID="ID_0">

<ns0:Name>Name_0</ns0:Name>

<Age>Age_0</Age>

</Employee>

</ns0:Employees>

Default and Fixed Value for the Attributes / Elements

Default value

Assume that you receive an Employees message from HR department which has Department element, can be empty for any one. But with in Biztalk you may want to process those employees under department called "UnknownDepartment". This can be easily done by setting the Default Value property of the "Department" element as "UnknownDepartment".

XML Output

<ns0:Employees xmlns:ns0="http://CyclicSubs.XmlSchemaEmployee">

<Employee ID="ID_0">

<Name>Name_0</Name>

<Age>Age_0</Age>

<Department>UnknownDepartment</Department>

</Employee>

</ns0:Employees>

Fixed value

Take the above scenario, here you only process IT departments employee's message, so no matter you receive Department value as "Finance" or "Help Desk" your scenario has to process them under "IT Department". This can be done by setting "Fixed" value of the Department element as "IT Department"

XML Output

<ns0:Employees xmlns:ns0="http://CyclicSubs.XmlSchemaEmployee">

<Employee ID="ID_0">

<Name>Name_0</Name>

<Age>Age_0</Age>

<Department>IT Department</Department>

</Employee>

</ns0:Employees>

Dynamic value assignment for the empty elements can be done in mapping using functoids.

Document Type Property

Document Type property is used in adapters like EDI, in general it is not considered in Xml or Flat file schema. BRE use Document Type property to identify the fully qualified name.

Document Version

This can be used to store the version number of your schema.

CodeList Database

You are developing a schema for processing Employee Reimbursement of all the departments under a cost center "CC001"; you would need to restrict the all other departments not fall under "CC001". Assume that CC001 has around 100 departments you can enter manually all the departments name in Department element's enumeration collection.

Otherwise you can import the department collection from MS Access table as like below

Column names should be Code, Value and Desc, Data type of all the column is expected to be "Text" in MS Access.

Import Data List from Database

  1. Select your mdb (Departments.mdb) file from Schema node's CodeList Database browse button.
  2. Choose XML in Standard property of schema node and enter "Department" in Standard Version property. Biztalk query the table by concatenating value in the "Standard" property and value of the " Standard Version" property. ( Note the above MS Access table named as "Xml_CCDepartments" , rename it to "Xml_Department")
  3. Select Department element in the left pane and choose "Restriction" from the Derived by property, you would see CodeList property will be enabled automatically.
  4. In CodeList property enter the CostCenter Code "CC001" and click on the browse button of the property, A new window with list of matching values will appear as shown below
  5. Choose all the department by checking all the boxes in the new Window and select "OK"
  6. All the selected values will be imported to your Schema, make sure everything imported by selecting the Enumeration property of the "Department" field.

Here is the sample instance showing the Department name from the Enumeration.

XML Output

<ns0:Employees xmlns:ns0="http://CyclicSubs.XmlSchemaEmployee">

<Employee ID="ID_0">

<Name>Name_0</Name>

<Age>Age_0</Age>

<Department>Finance</Department>

</Employee>

</ns0:Employees>

History

This is the first of Schema design article , let us see Group Max, Min occurance property in the next article.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Selvan


Member
Tamilselvan Subramanian is a Lead consultant working on Microsoft Technologies for the past 6 years, Currently living in Newyork, US. Technical experience most specifically Biztalk 2004/2006, Webservices, C# and .NET framework,VB.NET, XML, XSLT, Flat file,Java.

He was awarded 'Community Star' by Microsoft for resolving .NET community people questions.
http://www.microsoft.com/india/communitystar/CurrentSelections.aspx

He blogs @ http://biztek.blogspot.com here.
You can reach him at tamilselvan +2 gmail.com.
Occupation: Software Developer (Senior)
Location: United States United States

Other popular Microsoft BizTalk Server articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
  (Refresh) 
-- There are no messages in this forum --

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 5 Apr 2007
Editor:
Copyright 2007 by Selvan
Everything else Copyright © CodeProject, 1999-2009
Web18 | Advertise on the Code Project