![]() |
Enterprise Systems »
Microsoft BizTalk Server »
General
Intermediate
Design your Biztalk 2006 Schema - Part 1By SelvanA Beginers guide to Biztalk schema design |
Windows, Visual Studio, Architect, Dev, QA, Design
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
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.
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.
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

<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

<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.
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"
<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 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".

<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
- Select your mdb (Departments.mdb) file from Schema node's CodeList Database browse button.
- 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")

- Select Department element in the left pane and choose "Restriction" from the Derived by property, you would see CodeList property will be enabled automatically.
- 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
- Choose all the department by checking all the boxes in the new Window and select "OK"

- 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.
General
News
Question
Answer
Joke
Rant
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 |