具有标签名称的XSD可选元素

时间:2019-01-03 07:55:00

标签: xsd biztalk flat-file

在为平面文件构建XSD时,XSD具有两个由新行分隔的元素:

  • FirstElement_AAA:重复但标签名称为(AAA,)可选。
  • SecondElement_BBB:具有标签名称(BBB,)的单项和强制性。

因此XSD应该支持一个平面文件,例如:

AAA,
AAA,
BBB,

AAA,
BBB,

BBB,

我拥有的当前XSD:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://xxx.yyy.zzz.www.sss" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" targetNamespace="http://xxx.yyy.zzz.www.sss" 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" root_reference="xxx_yyy" 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="false" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="xxx_yyy">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="false" suppress_trailing_delimiters="true" sequence_number="1" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" notes="xxx_yyy" child_order="infix" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence minOccurs="0">
        <xs:annotation>
          <xs:appinfo>
            <b:groupInfo sequence_number="0" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="FirstElement_AAA">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo structure="delimited" child_delimiter_type="char" child_delimiter="," child_order="infix" preserve_delimiter_for_empty_data="false" suppress_trailing_delimiters="true" repeating_delimiter_type="hex" repeating_delimiter="0x0D 0x0A" tag_name="AAA," 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:complexType>
        </xs:element>
        <xs:element minOccurs="1" name="SecondElement_BBB">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo structure="delimited" child_delimiter_type="char" child_delimiter="," child_order="infix" sequence_number="2" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="true" tag_name="BBB," />
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:annotation>
                <xs:appinfo>
                  <groupInfo sequence_number="0" />
                  <b:groupInfo sequence_number="0" />
                </xs:appinfo>
              </xs:annotation>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

当前,除了AAA以外,一切都工作正常。

1 个答案:

答案 0 :(得分:1)

将节点属性“解析器优化”设置为“复杂性”