Sufyan Jabr
Sufyan Jabr

Reputation: 809

XSD optional element with tag name

Am building an XSD for a flat file, the XSD have two elements delimited by new line:

So the XSD should support a flat file like:

AAA,
AAA,
BBB,

or

AAA,
BBB,

or

BBB,

The current XSD that i have:

<?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>

Currently everything is working fine, except for when AAA, does not exist.

Upvotes: 1

Views: 221

Answers (1)

Set the node property "Parser Optimization" to "Complexity"

Upvotes: 1

Related Questions