Biztalk 2010:使用大量具有相同名称的元素映射xsd [英] Biztalk 2010: mapping an xsd with a lot of elements with the same name

查看:107
本文介绍了Biztalk 2010:使用大量具有相同名称的元素映射xsd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Bitzalk 2010中,我应该从输入映射到具有以下结构的XML:

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>

生成的XSD是这样的:

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>

生成的结构只是常规"的,我将不得不使用表循环functoid将其映射到Biztalk中.我从此解决方案中获得了信息: http://hestia.typepad.com /flatlander/2007/01/mapping_fixed_e.html 但这对我来说似乎很麻烦(我有40个具有恒定值的字段).

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

另一种可能性是使用XSLT.但是我没有任何经验,我希望直接在Biztalk中(无需XSLT)将其映射

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)

是否可以创建XSD方案,所以我将在地图编辑器中拥有所有字段,并在其中创建映射(无需使用表循环functoid).

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

任何想法/评论都会受到赞赏(即使答案是:使用XSLT")

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

推荐答案

FWIW我们通常都会对任何非平凡的地图使用XSLT.

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

然后BizTalk会为您创建XSLT:)

And BizTalk creates the XSLT for you anyway :)

所以建议:

  • 使用BizTalk映射器尽力而为(似乎可以映射REQUEST,PROGRAM,INPUT和INSTRUCT)
  • 编译项​​目
  • 在Visual Studio的解决方案资源管理器"中单击您的.btm文件,然后在顶部选择显示所有文件". 现在,您应该看到一个隐藏文件SameFileName.btm.cs.在此文件中是BizTalk生成的XSLT.复制此XSLT,并将其粘贴到新文件中-将其另存为.xslt.您需要将双引号替换为单引号.
  • 再次打开原始的.btm(地图).单击架构之间的地图灰色区域(网格属性).在自定义XSLT路径"属性中,选择新创建的.XSLT文件.
  • 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的映射器为您提供了XSLT的领先优势,您应该能够轻松掌握基本的XSLT.一个陷阱-确保记住名称空间别名前缀(通常是s1)

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)

请注意,以上内容适用于BizTalk 2009

Edit : Note that the above is for BizTalk 2009

修改

为防万一,在btm的可视化图中,建议您手动删除灰色映射区域中的所有映射线和函子,以防万一您忘记了现在正在使用自定义xslt.如果您使用自定义xslt测试地图,则映射器会提醒您使用了xslt文件,而可视化地图将被忽略.

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.

这篇关于Biztalk 2010:使用大量具有相同名称的元素映射xsd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆