Click here to Skip to main content
15,882,209 members
Articles / Operating Systems / Windows

Design your Biztalk 2006 Schema - Part 1

Rate me:
Please Sign up or sign in to vote.
3.82/5 (7 votes)
5 Apr 2007CPOL4 min read 39.9K   29   1
A Beginner's guide to Biztalk schema design

Introduction

Creating a Schema is defining a structure of the data, similar to creating a table in database. Designing schema plays a vital role for the Integration project. In this series of articles, 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.

XML
<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> 

Image 1

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 a 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:

Image 2

XML Output
XML
<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 to be 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:

Image 3

XML Output
XML
<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 considers 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 the left pane and mark the "Form" property as "Qualified".

Image 4

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

XML Output
XML
<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 within 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".

Image 5

XML Output
XML
<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 whether 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".

Image 6

XML Output
XML
<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 all the other departments not falling 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 Microsoft Access table as shown below.

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

Image 7

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 queries the table by concatenating value in the "Standard" property and value of the " Standard Version" property. (Note the above Microsoft Access table named as "Xml_CCDepartments" , rename it to "Xml_Department")

    Image 8

  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 departments by checking all the boxes in the new Window and select "OK".

    Image 9

  6. All the selected values will be imported to your Schema, make sure everything is imported by selecting the Enumeration property of the "Department" field.

    Image 10

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

XML Output
XML
<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 occurrence property in the next article.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
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 <shift>+2 gmail.com.

Comments and Discussions

 
GeneralDefaultValue property not working Pin
Asish Kumar Das18-Mar-19 22:47
Asish Kumar Das18-Mar-19 22:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.