Hi
Today, I had the pleasure of helping a fellow BizTalk guy on the microsoft.public.biztalk.general newsgroup. He has a schema which showed up with lots of root elements in the schema editor. He wanted to fix that, but how?
The "problem" is well known if you for instance use schemas created by InfoPath 2003. They will look something like this:
There are lots of elements that appear to be the root node. Now, I know that "myFields" is the actual root node that I want to use, but it sure isn't easy to see. What I want shown is this:
And if I create an instance of this schema, I will get this:
<ns0:CustomerName xmlns:ns0="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-09-07T18:24:45">CustomerName_0</ns0:CustomerName>
But that isn't what I wanted. I wanted this:
<ns0:myFields ns1:anyAttr="anyAttrContents" xmlns:ns1="http://www.w3.org/XML/1998/namespace" xmlns:ns0="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-09-07T18:24:45">
<ns0:CustomerName>CustomerName_0</ns0:CustomerName>
<ns0:OrderLines>
<ns0:OrderLine ns0:ID="ID">
<ns0:Description>Description_0</ns0:Description>
<ns0:Quantity>100</ns0:Quantity>
<ns0:ItemID>100</ns0:ItemID>
</ns0:OrderLine>
<ns0:OrderLine ns0:ID="ID">
<ns0:Description>Description_0</ns0:Description>
<ns0:Quantity>100</ns0:Quantity>
<ns0:ItemID>100</ns0:ItemID>
</ns0:OrderLine>
<ns0:OrderLine ns0:ID="ID">
<ns0:Description>Description_0</ns0:Description>
<ns0:Quantity>100</ns0:Quantity>
<ns0:ItemID>100</ns0:ItemID>
</ns0:OrderLine>
</ns0:OrderLines>
</ns0:myFields>
So, how do I achive this?
Well, the answer is quite simple, really... although it does involve manually editing the schema file (the .xsd file).
What you want to do is add a BizTalk specific annotation to the schema to let BizTalk Schema Editor know which node is to be treated as the root node.
So my schema looked like this:
<xsd:schema xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-09-07T18:24:45" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-09-07T18:24:45" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:attribute name="ID" type="my:requiredString" />
<xsd:element name="myFields">
... and a whole bunch more
and I edited it and now it looks like this:
<xsd:schema xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-09-07T18:24:45" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-09-07T18:24:45" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:appinfo>
<b:schemaInfo is_envelope="no" version="1.0" root_reference="myFields" displayroot_reference="myFields" xmlns:b="http://schemas.microsoft.com/BizTalk/2003">
</b:schemaInfo>
</xsd:appinfo>
</xsd:annotation>
<xsd:attribute name="ID" type="my:requiredString" />
<xsd:element name="myFields">
So under annotations under appinfo, I added a BizTalk specific schemaInfo element, which describes which node to treat as the root node.
Clever and simple. But remember that you need to do this editing every time a new version of the schema needs to be used.
You can find my schemas here:
myschema.zip (,78 KB)
and here:
correctedmyschema.zip (,88 KB)
I hope this helps someone.
--
eliasen