BizTalk - 构建 XSD 用于在记录的开头和结尾处使用单词定界符的平面文件

BizTalk - Build XSD for flat file with words delimiter at start and end of records

我正在尝试基于以下文本文件(平面文件)构建一个 XSD 文件。我正在使用平面文件架构向导,但无法实现我想要的。

:BEGIN
Key1 Value1
Key2 Value2
:END
:BEGIN
Key1 Value1
Key2 Value2
Key3 Value3
:END
:BEGIN
:END

XSD 类似于:

Record (Delimited by :BEGIN and :END)
|_Association (Delimited by \n)
  |_Key (Delimited by space, first occurence)
  |_Value (second occurence)

我希望将我的 txt 文件转换为 xml 中 xsd 文件的一个实例。结果将类似于:

<Record>
  <Association>
    <Key>Key1</Key>
    <Value>Value1</Value>
  </Association>
  <Association>
    <Key>Key2</Key>
    <Value>Value2</Value>
  </Association>
</Record>
<Record>
  <Association>
    <Key>Key1</Key>
    <Value>Value1</Value>
  </Association>
  <Association>
    <Key>Key2</Key>
    <Value>Value2</Value>
  </Association>
  <Association>
    <Key>Key3</Key>
    <Value>Value3</Value>
  </Association>
</Record>

只有 2 条记录,因为最后一个 :BEGIN:END 块是空的。

我的主要问题是我无法找到如何通过 :START 和 :END 标记分隔我的记录。这可能吗?

是的,可以,但不能使用向导。这是一个手动构建它并在添加定义时测试结构的问题。

这是使用标签标识符作为 :BEGIN 和 :END 以及使用序列组表示这些 re-occur.

的问题

此外,在 <Schema> 级别将解析器优化设置为复杂性。

根据定义行尾的内容,您可能需要将 0x0A 0x0D(回车 Return 和换行)调整为文件实际包含的内容。此外,如果最后一行没有以 CR/LF 结束,则将其从后缀(之后)更改为中缀(之间)。

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO63600733" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.SO63600733" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo standard="Flat File" root_reference="Root" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="complexity" 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" />
      <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="Root">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" 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 maxOccurs="unbounded" name="Record">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_order="postfix" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" 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:sequence>
                <xs:annotation>
                  <xs:appinfo>
                    <b:groupInfo sequence_number="1" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:element name="BEGIN">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" tag_name=":BEGIN" />
                    </xs:appinfo>
                  </xs:annotation>
                  <xs:complexType />
                </xs:element>
                <xs:element minOccurs="0" maxOccurs="unbounded" name="Accociation">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="char" child_order="infix" child_delimiter=" " 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="Key" type="xs:string">
                        <xs:annotation>
                          <xs:appinfo>
                            <b:fieldInfo sequence_number="1" justification="left" />
                          </xs:appinfo>
                        </xs:annotation>
                      </xs:element>
                      <xs:element name="value" 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:element name="END">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name=":END" child_order="postfix" child_delimiter_type="hex" child_delimiter="0x0A 0x0D" sequence_number="3" />
                    </xs:appinfo>
                  </xs:annotation>
                  <xs:complexType />
                </xs:element>
              </xs:sequence>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

根据您的示例输入给出

<Root xmlns="http://Scratch.SO63600733">
    <Record xmlns="">
        <BEGIN/>
        <Accociation>
            <Key>Key1</Key>
            <value>Value1</value>
        </Accociation>
        <Accociation>
            <Key>Key2</Key>
            <value>Value2</value>
        </Accociation>
        <END/>
    </Record>
    <Record xmlns="">
        <BEGIN/>
        <Accociation>
            <Key>Key1</Key>
            <value>Value1</value>
        </Accociation>
        <Accociation>
            <Key>Key2</Key>
            <value>Value2</value>
        </Accociation>
        <Accociation>
            <Key>Key3</Key>
            <value>Value3</value>
        </Accociation>
        <END/>
    </Record>
    <Record xmlns="">
        <BEGIN/>
        <END/>
    </Record>
</Root>