Biztalk 2010: la cartografía de un XSD con una gran cantidad de elementos con el mismo nombre

StackOverflow https://stackoverflow.com/questions/3716608

Pregunta

En 2010 Bitzalk que debería trazar desde una entrada a un archivo XML con la siguiente estructura:

<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>

El XSD generado era así:

<?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>

La estructura generada era simplemente "general" y que tendría que utilizar la tabla de bucle functoid de hacer un mapa de BizTalk. Tengo la información de esta solución: http://hestia.typepad.com /flatlander/2007/01/mapping_fixed_e.html Pero esto parece muy complicado para mí (tengo 40 campos con algunos valores constantes).

Otra posibilidad sería utilizar XSLT. Pero yo no tengo ninguna experiencia con ella y yo preferiría para mapear directamente en Biztalk (sin XSLT)

¿Existe la posibilidad de crear un esquema XSD, por lo que tendría todos los campos en el editor de mapas y crear la correlación de allí (sin utilizar la tabla de bucle functoid).

Todas las ideas / comentarios serán bienvenidos (incluso si la respuesta es: "El uso de XSLT")

¿Fue útil?

Solución

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

Edit

As a sanity precaution, in the visual map of the btm, I suggest that you manually delete all the mapping lines and functoids from the grey mapping area, in case you forget that you are now using custom xslt. If you test a map with custom xslt, the mapper does issue a reminder that the xslt file is used and the visual map is ignored.

Otros consejos

A simpler way to get the generated xlst (and generally the recommended way that has worked since at least bts2006) is to right-click the btm file in your solution explorer and choose "validate map". The output of this gives you both the xslt and the extension objects in standalone files (certain functoids and external class references use an extension objects file).

From here you can save off and modify the xslt output - don't need to parse the .btm.cs file or worry about string encoding issues like missing an escaped double quote around an attribute or a namespace...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top