BizTalk平面文件嵌套xml

时间:2013-08-02 21:10:56

标签: xsd schema biztalk biztalk-2010

嵌套节点的BizTalk平面文件架构给我带来了一些麻烦。发生的事情是子记录分隔符显示为最后一个字段中的数据。我按照这篇老博客文章中的食谱。

Managing Flat Files in BizTalk 2004

以下是输入和架构。

https://bitbucket.org/kirk98445/stuff/src/90becbaa638b1bc42555cf84f2a1a4cb4f3cd3fc?at=master

结果是除了用户和ponumber字段中的crlf之外,xml看起来很好。

<Orders xmlns="http://KS.Biztalk.EDI.Common.Amtech.ASN.FlatFileSchema1"><Header><user>USER_1234
</user></Header><Order><OrderHeader><ponumber>PO_001
</ponumber></OrderHeader><LineItems><LineItem><item>Item32  33</item></LineItem><LineItem><item>Item63  45</item></LineItem></LineItems></Order><Order><OrderHeader><ponumber>PO_002
</ponumber></OrderHeader><LineItems><LineItem><item>Item454 12</item></LineItem></LineItems></Order></Orders>

1 个答案:

答案 0 :(得分:0)

您的架构存在问题。 记录“订单” - 未为分隔记录设置“子分隔符类型”属性。 记录“订单” - 未为分隔记录设置子分隔符类型属性。

通常使用这种平面文件,我会为标题创建一个模式,然后为Order&amp;订单行。然后在flat file dissembler中定义将Header架构和Document架构设置为上面两个。 通过这种方式,它将取消批处理,您将收到文件中每个采购订单的消息。

但是如果您想在单个架构中使用它,请尝试使用序列组节点的此架构。

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://KS.Biztalk.EDI.Common.Amtech.ASN.FlatFileSchema1" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" elementFormDefault="qualified" targetNamespace="http://KS.Biztalk.EDI.Common.Amtech.ASN.FlatFileSchema1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo standard="Flat File" root_reference="Orders" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="true" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" child_delimiter_type="hex" default_child_delimiter="0x0D 0x0A" default_child_order="postfix" />
      <schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Orders">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="postfix" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo>
            <b:groupInfo sequence_number="0" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element minOccurs="1" maxOccurs="1" name="Header">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo sequence_number="1" structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="HEADER" child_delimiter_type="hex" child_delimiter="0x09" child_order="prefix" />
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:annotation>
                <xs:appinfo>
                  <b:groupInfo sequence_number="0" />
                </xs:appinfo>
              </xs:annotation>
              <xs:element name="user" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo sequence_number="1" justification="left" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:sequence maxOccurs="unbounded">
          <xs:annotation>
            <xs:appinfo>
              <b:groupInfo sequence_number="2" />
            </xs:appinfo>
          </xs:annotation>
          <xs:element name="OrderHeader">
            <xs:annotation>
              <xs:appinfo>
                <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="PURCHASE" child_order="prefix" child_delimiter_type="hex" child_delimiter="0x09" sequence_number="1" />
              </xs:appinfo>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:annotation>
                  <xs:appinfo>
                    <b:groupInfo sequence_number="0" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:element name="ponumber" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo sequence_number="1" justification="left" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
          <xs:element maxOccurs="unbounded" name="LineItem">
            <xs:annotation>
              <xs:appinfo>
                <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="LINEITEM" child_delimiter_type="hex" child_delimiter="0x09" child_order="prefix" sequence_number="2" />
              </xs:appinfo>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:annotation>
                  <xs:appinfo>
                    <b:groupInfo sequence_number="0" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:element name="item" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo sequence_number="1" justification="left" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="Qty" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo sequence_number="2" justification="left" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>