Multiple data type for BizTalk Schema elements

 

Exception:

The XML Validator failed to validate. Details: The xsi:type attribute value ‘http://www.w3.org/2001/XMLSchema:double’ is not valid for the element ‘http://schemas.microsoft.com/2003/10/Serialization/Arrays:Value’, either because it is not a type validly derived from the type in the schema, or because it has xsi:type derivation blocked.

SampleSchema.jpg

Explanation:

This issue is occurred when we validate the schema. Main reason is that for a element field the data type is defined more than one format e.g. in below xml file value field has data type double and string both. so when we validate this xml with schema then it throws exception.

Resolution:

When any element has more than one datatype then we need also define this in schema property as below:

Select element and open properties window of that element as below:

Expend Advanced in Properties-> Derived By->  Select Union

SampleSchemaProperties1.jpg

Now select multiple datatypes which is required in Member Types.

Note: You can not select all data types in Member Types

SampleSchemaProperties2.jpg

 

Now save the change and validate the xml with validate instance, it will working fine.

Advertisements

BizTalk Schemas Properties

Base Data Type:

this is important properties of schema, but most of the cases we have set as blank.

This properties is applied on Record, Field Element, Field Attribute;

Its by default value is set as Blank, indicating that the data type of this Record, Field Element, or Field Attribute node is not derived from another data type.

Data Structure Type:

It specifies a name for the data type of the selected node so that it can be used elsewhere.

Data Structure type only applied on Record in Schema. It is used for below three kind of activity:

  • Select an existing global complex type to be associated with the selected Record node, thereby converting the inbuilt complex type for this Record node to a global complex type.
  • Specify a name for the complex type associated with the selected Record node, thereby converting its unnamed complex type to a global complex type
  • Reference an existing global Record node.

Difference between Base Data Type and Data Structure Type:

Base Data Type as inheriting from a base class which you can then modify further.  It will retain the name you define and can then be used as the Data Structure Type of other Elements.

Data Structure Type is similar to creating an instance of a Type.  So, if you have your ‘Type’ Elements defined at the root, you can then set child Elements elsewhere to these types, complex or simple, using Data Structure Type.

Derived By:

It specifies how the complex type associated with the selected node is derived from the data type specified by the Base Data Type property.

Derived By.jpg

More info available at: https://msdn.microsoft.com/en-us/library/aa560465.aspx

Simple and complex types in XML Schema:

In XML Schema, there is a basic difference between complex types which allow elements in their content and may carry attributes, and simple types which cannot have element content and cannot carry attributes.

Regulation Expression in BizTalk Schema

Some times we need to set element or record attribute with particular restricted values e.g. mail id, positive integer, without any special characters. We can achieve this  with following steps:

mail.jpg

We need to set Schema property for this MailID as below

 

mailidproperties.jpg

Now click on Pattern eclipse and set the Regular expression for mail id:

PatternEditor.jpg

Through this way we can achieve regulation expression in BizTalk Schemas.