Geeks With Blogs
Edmund Zhao's BizTalk abc We share, We learn

I've been through a scenario where I had a very complicated multiple schemas map, the left(source) side of the map had two schemas and the right(destination) side had one, for some reason I decided to add one more schema to the left side.

BizTalk map editor in 2006/2006 R2/2009/2010 doesn't allow creating multiple schemas map directly, neither does it allow adding or removing schemas from either side of the map, therefore in order to add a schema, I would have to open an orchestration, create a transform shape then create a new multiple schemas map in transform configuration window. However, by doing this, I would end up with a new blank map and it would be a big headache for me to put all the mapping info back and retest it.

There is a reason I really like BizTalk, because most BizTalk artifacts are literally just XML. Therefore, as long as I have a XML editor, or any other text editor, I can always open the file and modify it by myself.

Here is what I did, it's not difficult at all and took less than five minutes for me to complete and test.

1. Open the existing map file "multisourcemap.btm" using any text editor tool.

2. Find the node <SrcTree>, it is usually close to the begining of the file, should be easy to locate.

3. Modify the child node <xs:schema>. In my case, I had two source schemas in existing map already, so it looks similar to

<xs:schema xmlns:tns="http://schemas.microsoft.com/BizTalk/2003/aggschema" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ns1="http://SourceSchema1NameSpace" xmlns:ns2="http://SourceSchema2NameSpace" targetNamespace="http://schemas.microsoft.com/BizTalk/2003/aggschema" xmlns:xs="http://www.w3.org/2001/XMLSchema">

     Now I just need to add "xmlns:ns3" attribute and make it look similar to

<xs:schema xmlns:tns="http://schemas.microsoft.com/BizTalk/2003/aggschema" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ns1="http://SourceSchema1NameSpace" xmlns:ns2="http://SourceSchema2NameSpace" xmlns:ns3="http://SourceSchema3NameSpace" targetNamespace="http://schemas.microsoft.com/BizTalk/2003/aggschema" xmlns:xs="http://www.w3.org/2001/XMLSchema">

4. The <xs:schema> node has two <xs:import> child nodes already, it looks similar to

<xs:import schemaLocation="Schema1Location" namespace="http://Schema1NameSpace" />
<xs:import schemaLocation="Schema2Location" namespace="http://Schema2NameSpace" />

     So just add another one

<xs:import schemaLocation="Schema3Location" namespace="http://Schema3NameSpace" />

5. After <xs:import> node, there is a <xs:element> node, looks similar to

      <xs:element name="Root">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="InputMessagePart_0">
              <xs:complexType>
                <xs:sequence>
                  <xs:element ref="ns1:Schema1RootNodeName" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="InputMessagePart_1">
              <xs:complexType>
                <xs:sequence>
                  <xs:element ref="ns2:Schema2RootNodeName" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>

    Add another section <xs:element name="InputMessagePart_2">, make it similar to

     <xs:element name="Root">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="InputMessagePart_0">
              <xs:complexType>
                <xs:sequence>
                  <xs:element ref="ns1:Schema1RootNodeName" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="InputMessagePart_1">
              <xs:complexType>
                <xs:sequence>
                  <xs:element ref="ns2:Schema2RootNodeName" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="InputMessagePart_2">
              <xs:complexType>
                <xs:sequence>
                  <xs:element ref="ns3:Schema3RootNodeName" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>

6. Save the btm file.

That's it, the modfied map file can be opened in BizTalk map editor, new schema is added, and all old mapping info are still there!

....Edmund Zhao

Posted on Thursday, April 7, 2011 8:14 PM | Back to top


Comments on this post: How to add schema to a multiple schemas map without losing existing mapping info

# re: How to add schema to a multiple schemas map without losing existing mapping info
Requesting Gravatar...
Nice. I never realized until I read this that the aggschema is defined inside the map. Very useful. :)
Left by Walter on Feb 04, 2016 12:52 PM

Your comment:
 (will show your gravatar)


Copyright © Edmund Zhao | Powered by: GeeksWithBlogs.net