Xingzhou Liu
Xingzhou Liu

Reputation: 1559

BizTalk Flat File Schema - file header and footer but no records

I'm dealing with a flat file that has a tagged and pipe delimited header, positional body records, and a positional footer

H|20220601|XXXX
CONTENT FIELD 1              CONTENT FIELD 2                CONTENT FIELD 3
CONTENT FIELD 1              CONTENT FIELD 2                CONTENT FIELD 3
F00001234

I'm having an issue getting rid of this error:

Reason: Unexpected end of stream while looking for: Positional data (length is X) The current definition being parsed is Records. The stream offset where the error occured is XX. The line number where the error occured is 3. The column where the error occured is 0.

when I get an empty file like:

H|20220601|XXXX
F00001234

This is my flat file schema

<xs:element name="Root">
    <xs:annotation>
        <xs:appinfo>
            <b:recordInfo suppress_trailing_delimiters="false" preserve_delimiter_for_empty_data="true" sequence_number="1" child_order="postfix" child_delimiter="0xD 0xA" child_delimiter_type="hex" structure="delimited"/>
        </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:annotation>
                <xs:appinfo>
                    <groupInfo xmlns="http://schemas.microsoft.com/BizTalk/2003" sequence_number="0"/>
                </xs:appinfo>
            </xs:annotation>
            <xs:element name="Header" maxOccurs="1" minOccurs="1">
                <xs:annotation>
                    <xs:appinfo>
                        <b:recordInfo suppress_trailing_delimiters="false" preserve_delimiter_for_empty_data="true" sequence_number="1" child_order="infix" child_delimiter="/" child_delimiter_type="char" structure="delimited" tag_name="H"/>
                    </xs:appinfo>
                </xs:annotation>
                <xs:complexType>
                    [...]
                </xs:complexType>
            </xs:element>
            <xs:element name="Records" maxOccurs="unbounded" minOccurs="0" nillable="true">
                <xs:annotation>
                    <xs:appinfo>
                        <b:recordInfo suppress_trailing_delimiters="false" preserve_delimiter_for_empty_data="true" sequence_number="2" structure="positional"/>
                    </xs:appinfo>
                </xs:annotation>
                <xs:complexType>
                    [...]
                </xs:complexType>
            </xs:element>
            <xs:element name="Footers" maxOccurs="1" minOccurs="1">
                <xs:annotation>
                    <xs:appinfo>
                        <b:recordInfo suppress_trailing_delimiters="false" preserve_delimiter_for_empty_data="true" sequence_number="3" structure="positional" tag_name="F" tag_offset="0"/>
                    </xs:appinfo>
                </xs:annotation>
                <xs:complexType>
                    [...]
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>

Tried setting the records to minoccurrs = 0 and nillable, but error persists. How can I get the pipeline to handle a file with no records in this case?

Upvotes: 1

Views: 172

Answers (1)

Dijkgraaf
Dijkgraaf

Reputation: 11527

If your lines do not have a tag, and you have other records following, then change the Schema properties, Parser Optimisation from Speed to Complexity. The reason for this is because the line doesn't have a tag, it has trouble recognising when the lines end.

Setting it to Complexity does the following

In complexity mode, the flat file parsing engine uses both top-down and bottom-up parsing, and tries to fit data more accurately. In speed mode, the parser tries to fit data as they appear in the stream.

Parsing Modes (learn.microsoft.com).

Schema properties, Parser Optimisation, Complexity

Upvotes: 1

Related Questions