了解BizTalk平面文件架构

时间:2016-11-09 21:56:05

标签: xsd schema biztalk biztalk-2013

我正在尝试修改BizTalk平面文件向导生成的架构。 这非常复杂,我宁愿花几天时间让巫师再做一些可行的事情。

输入是一个复杂的文件,由回车符/换行符分隔记录组成。目前有一条线在前面有一个标签来识别它。他们想要添加接受当前行或其他类似行的能力。

我需要任意顺序的两行中的任意一行。

我在第一行之后为第二行创建了一个定义。 然后我用Choice节点包围了两个行定义。 选择节点设置为minOccurs =“0”maxOccurs =“unbounded”。 我以为这会给我任意数量的任何一个块:

<xs:choice minOccurs="0" maxOccurs="unbounded">
  <xs:annotation>
    <xs:appinfo>
      <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="2" />
    </xs:appinfo>
  </xs:annotation>

  <xs:element name="GROS">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="positional" tag_name="GROS" tag_offset="0" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
      </xs:appinfo>
    </xs:annotation>
    ...
  </xs:element>

  <xs:element name="GRSD">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="positional" tag_name="GRSD" tag_offset="0" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
      </xs:appinfo>
    </xs:annotation>
    ...
  </xs:element>

</xs:choice>

第三行失败了:

GROS ...
GRSD ...
GRSD ...

有什么建议吗?我的大脑疼。

2 个答案:

答案 0 :(得分:1)

给定有效载荷

GROS1234567890 CR LF
GRSD1234567890 CR LF
GRSD1234567890 CR LF

以下架构将很乐意通过标签解析,然后通过位置

解析
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.FlatFileSchema40516683" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.FlatFileSchema40516683" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
      <b:schemaInfo standard="Flat File" codepage="65001" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" root_reference="Root" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Root">
    <xs:annotation>
      <xs:appinfo>
        <recordInfo sequence_number="1" structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo>
            <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
          </xs:appinfo>
        </xs:annotation>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:annotation>
            <xs:appinfo>
              <groupInfo sequence_number="1" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
            </xs:appinfo>
          </xs:annotation>
          <xs:element name="GROS">
            <xs:annotation>
              <xs:appinfo>
                <recordInfo sequence_number="1" structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="GROS" child_order="postfix" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
              </xs:appinfo>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:annotation>
                  <xs:appinfo>
                    <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:element name="Fields">
                  <xs:annotation>
                    <xs:appinfo>
                      <recordInfo sequence_number="1" structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                    </xs:appinfo>
                  </xs:annotation>
                  <xs:complexType>
                    <xs:sequence>
                      <xs:annotation>
                        <xs:appinfo>
                          <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                        </xs:appinfo>
                      </xs:annotation>
                      <xs:element name="Field" type="xs:string">
                        <xs:annotation>
                          <xs:appinfo>
                            <fieldInfo sequence_number="1" justification="left" pos_length="5" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                          </xs:appinfo>
                        </xs:annotation>
                      </xs:element>
                      <xs:element name="Field2" type="xs:string">
                        <xs:annotation>
                          <xs:appinfo>
                            <fieldInfo sequence_number="2" justification="left" pos_length="5" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                          </xs:appinfo>
                        </xs:annotation>
                      </xs:element>
                    </xs:sequence>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
          <xs:element name="GRSD">
            <xs:annotation>
              <xs:appinfo>
                <recordInfo sequence_number="2" structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" child_order="postfix" tag_name="GRSD" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
              </xs:appinfo>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:annotation>
                  <xs:appinfo>
                    <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:element name="Fields">
                  <xs:annotation>
                    <xs:appinfo>
                      <recordInfo structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                    </xs:appinfo>
                  </xs:annotation>
                  <xs:complexType>
                    <xs:sequence>
                      <xs:annotation>
                        <xs:appinfo>
                          <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                        </xs:appinfo>
                      </xs:annotation>
                      <xs:element name="Field" type="xs:string">
                        <xs:annotation>
                          <xs:appinfo>
                            <fieldInfo sequence_number="1" justification="left" pos_length="5" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                          </xs:appinfo>
                        </xs:annotation>
                      </xs:element>
                      <xs:element name="Field2" type="xs:string">
                        <xs:annotation>
                          <xs:appinfo>
                            <fieldInfo sequence_number="2" justification="left" pos_length="5" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                          </xs:appinfo>
                        </xs:annotation>
                      </xs:element>
                    </xs:sequence>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

输出

<Root xmlns="http://Scratch.FlatFileSchema40516683">
    <GROS xmlns="">
        <Fields>
            <Field>12345</Field>
            <Field2>67890</Field2>
        </Fields>
    </GROS>
    <GRSD xmlns="">
        <Fields>
            <Field>12345</Field>
            <Field2>67890</Field2>
        </Fields>
    </GRSD>
    <GRSD xmlns="">
        <Fields>
            <Field>12345</Field>
            <Field2>67890</Field2>
        </Fields>
    </GRSD>
</Root>

主要区别在于我在字段记录(位置)下面放置了标记记录(由CR LF分隔)。

注意,这只有在所有记录都以CR LF结束时才有效,因为分隔符定义为Postfix(期望它后面的分隔符)。

答案 1 :(得分:0)

我终于能够通过侧身进行工作来实现它。我修改了现有节点,并用'TagIdentifier'字符串字段替换了记录标识标记。这解决了不同组合中多种类型节点的需求。我修改了地图以测试字符串字段的内容,以确定收到的记录类型。

这只会起作用,因为两条记录在其他方面完全相同。