简体   繁体   中英

Issue migrating custom positional flat file schema from Seeburger to BizTalk

I am trying to migrate some positional flat file schemas from Seeburger to BizTalk and it seems I am stuck with a problem I do not know how to handle with BizTalk.

I'll try to reduce the complexity to the basic issue I am having.

Let's say that in Seeburger the following message is processed.

Field1----Field2-------Field3----Field4--[CR][LF]

I added padding character "-" here to be visible, and CR LF segment terminator

The seeburger schema has defined the following structure for the above message

Field1 = Min/Max length = 10 characters

Field2 = Min/Max length = 13 characters

Field3 = Min/Max length = 10 characters

Field4 = Min/Max length = 8 characters

All fields are optional so it may be possible to get a message like this only

Field1----Field2-------Field3----[CR][LF]

Until here everything works fine. The problem is that the actual messages received by Seeburger are looking like this for example:

Field1----Field2-------Field3----Field4[CR][LF]

or

Field1----Field2-------Field3[CR][LF]

Please notice that the padding characters are missing from the last element from the record. Seeburger knows to handle this but in BizTalk I am not able to validate a message like this. ( without last element length < length defined in schema )

Biztalk expects that the length of last field from the record to be the defined length in the schema which makes sense. I did tried a lot of things but I was not able to find a solution for this.

Was somebody else stuck on this or do you have any suggestions?

  1. You need to set the Early Termination flag to True on the schema root 提前终止标志图像

  2. Set the Early Terminate Optional Fields to Yes提前终止可选字段

  3. Make sure all the fields that are optional have the Min Occurs set to 0

For an input file

Field1----Field2-------Field3----Field4--[CR][LF]
Field1----Field2-------Field3----Field4[CR][LF]
Field1----Field2-------Field3[CR][LF]
Field1----Field2-------[CR][LF]
Field1----Field2[CR][LF]
Field1----[CR][LF]
Field1[CR][LF]

The schema

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch2.Schema.SO73820633" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch2.Schema.SO73820633" 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="true" early_terminate_optional_fields="true" 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>
        <b:recordInfo structure="delimited" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" child_order="postfix" />
      </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 maxOccurs="unbounded" name="Record">
          <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 minOccurs="0" name="Root_Child1" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="10" sequence_number="1" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element minOccurs="0" name="Root_Child2" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="13" sequence_number="2" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element minOccurs="0" name="Root_Child3" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="10" sequence_number="3" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element minOccurs="0" name="Root_Child4" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="8" sequence_number="4" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Will parse it to below (XML tidied with Notepad++ for readability)

<Root xmlns="http://Scratch2.Schema.SO73820633">
    <Record xmlns="">
        <Root_Child1>Field1----</Root_Child1>
        <Root_Child2>Field2-------</Root_Child2>
        <Root_Child3>Field3----</Root_Child3>
        <Root_Child4>Field4--</Root_Child4>
    </Record>
    <Record xmlns="">
        <Root_Child1>Field1----</Root_Child1>
        <Root_Child2>Field2-------</Root_Child2>
        <Root_Child3>Field3----</Root_Child3>
        <Root_Child4>Field4</Root_Child4>
    </Record>
    <Record xmlns="">
        <Root_Child1>Field1----</Root_Child1>
        <Root_Child2>Field2-------</Root_Child2>
        <Root_Child3>Field3</Root_Child3>
    </Record>
    <Record xmlns="">
        <Root_Child1>Field1----</Root_Child1>
        <Root_Child2>Field2-------</Root_Child2>
    </Record>
    <Record xmlns="">
        <Root_Child1>Field1----</Root_Child1>
        <Root_Child2>Field2</Root_Child2>
    </Record>
    <Record xmlns="">
        <Root_Child1>Field1----</Root_Child1>
    </Record>
    <Record xmlns="">
        <Root_Child1>Field1</Root_Child1>
    </Record>
</Root>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM