views:

40

answers:

1

In Bitzalk 2010 I should map from an input to an XML with the following structure:

<REQUEST>
  <PROGRAM name="PROGRAM123">
    <INPUT>
      <INSTRUCT name="INSTR1">
         <FIELD name="FIELD11">VALUE1</FIELD>
         <FIELD name="FIELD12">VALUE2</FIELD>
         <FIELD name="FIELD13">VALUE3</FIELD>
       </INSTRUCT>
       <INSTRUCT name="INSTR2">
         <FIELD name="FIELD21">VALUE4</FIELD>
         <FIELD name="FIELD22">VALUE5</FIELD>
         <FIELD name="FIELD23">VALUE6</FIELD>
         <FIELD name="FIELD24">VALUE7</FIELD>
       </INSTRUCT>
       <INSTRUCT name="INSTR2">
         <FIELD name="FIELD21">VALUE8</FIELD>
         <FIELD name="FIELD22">VALUE9</FIELD>
         <FIELD name="FIELD23">VALUE10</FIELD>
         <FIELD name="FIELD24">VALUE11</FIELD>
       </INSTRUCT>
     </INPUT>
   </PROGRAM>
</REQUEST>

The generated XSD was like this:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="REQUEST" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="REQUEST" msdata:IsDataSet="true" msdata:Locale="en-US">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="PROGRAM">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="INPUT" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="INSTRUCT" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="FIELD" nillable="true" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:simpleContent msdata:ColumnName="FIELD_Text" msdata:Ordinal="1">
                                <xs:extension base="xs:string">
                                  <xs:attribute name="name" type="xs:string" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="name" type="xs:string" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>    
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" />
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

The generated structure was just "general" and I would have to use the table looping functoid to map it in Biztalk. I have got the information from this solution: http://hestia.typepad.com/flatlander/2007/01/mapping_fixed_e.html But this seems very cumbersome for me (I have got 40 fields with some constant values).

Another possibility would be to use XSLT. But I don't have got any experience with it and I would prefer to map it directly in Biztalk (without XSLT)

Is there the possibility of creating an XSD scheme, so I would have all the fields in the map editor and create the mapping in there (without using the table looping functoid).

Any ideas / comments would be appreciated (even if the answer is: "use XSLT")

+1  A: 

FWIW we generally wind up using XSLT for any non-trivial maps anyway.

And BizTalk creates the XSLT for you anyway :)

So would recommend:

  • Do as best as you can with the BizTalk mapper (it seems REQUEST, PROGRAM, INPUT and INSTRUCT are mappable)
  • Compile your project
  • Click on your .btm file in the Solution Explorer in Visual Studio, and then select "Show all Files" at the top. You should now see a hidden file SameFileName.btm.cs. In this file is the XSLT that BizTalk generates. Copy this XSLT, and paste it into a new file - save this as .xslt. You'll need to replace the double quotes with single quotes.
  • Open the original .btm (map) again. Click on the map grey area between the schemas (Grid Properties). In the 'Custom XSLT Path' Property, select your newly created .XSLT file.

BizTalk's mapper has given you a headstart on your XSLT, and you should be able to pick up basic XSLT pretty easily. One gotcha - make sure that you remember the namespace alias prefix (usually s1)

Edit : Note that the above is for BizTalk 2009

HTH!

nonnb