BizTalk Schema to use <any> element

Overview

The XSD <any> element is very useful while designing generic schema or a schema to contain something unexpected/undefined or set of defined XML or elements.

The <any> element provides a way to keep/contain XML element which is not defined in the schema. For more details and example, Please read here :

Problem

There is a requirement to design a schema which should be generic in nature to contain any undefined type of XML. For example the following XML should be able to contain any XML in the <Details> element. As in the below example it contains <feedtext> element

schema input-1

The XM: should be able to contain any other XML in the <Details> as below a different input:

schema input-2

As in the above input XML , it contains <feedtextfromsite1>

Solution

To cater the above requirement we have to use <any> element in our schema . As defined in the page here, If a element is defined as <any> It can contain any other XML which is not defined in the schema.

Code

We will start by creating a schema using BizTalk Schema editor , Below are few steps:

  1. Create the Root Element and name it “MyBlogRssFeeds”
  2. Insert a  record and rename it to “Header”
  3. Insert a record below “Header”
  4. Insert a record below root element and name it “Details”
  5. Insert <any> element by Right Click on <Details>, then select “Insert Schema Node” then select “Any Element” .
  6. After this the schema should look like below:

Schema

And with this I was able to create a generic schema and was able to validate my XML.

And One More Thing!!

Please pay attention of the properties of <Any> element: It should look like below:

Schema Final

The property “Process Contents” should be set to “Skip” . Because of course we do not want the XML engine to validate the structure of this element.

the definition of this property is below from this page :

“Indicates how XML from other namespaces (introduced by the any element in a content model) should be validated. The value for this attribute may be one of ‘strict’ (the processor must retrieve the schema declaration associated with the namespace and validate the XML); ‘lax’ (the processor should attempt to validate the XML against its schema); and ‘skip’ (the processor should not attempt to validate the XML) “

Thanks for reading!

Advertisements

About Naushad Alam
I am a BizTalk developer/administrator/designer/architect with over 9 years of experience. Currently I am living in UK and working with one of the largest bank as a Senior BizTalk Consultant. I believe in sharing my experience with others and learn more while helping or solving others problem.

2 Responses to BizTalk Schema to use <any> element

  1. “BizTalk Schema to use element Naushad Alam’s We[b]log”
    ended up being a incredibly pleasant posting, . Continue posting
    and I’ll try to keep on reading! Thanks a lot ,Grace

  2. shajahan says:

    how to retrieve particular record from a schema?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: