BizTalk平面文件模式 - 文件标头和页脚,但没有记录

发布于 2025-02-10 01:33:44 字数 3074 浏览 1 评论 0原文

我正在处理一个平坦的文件,该文件具有标记和管道定界标题,位置主体记录和位置页脚,

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

我遇到了问题:摆脱此错误:

原因:寻找流的意外结束: 位置数据(长度为x) 当前正在解析的定义是记录。发生错误的流偏移量为xx。发生误差的线号为3。发生误差的列为0。

当我获得一个空文件时,例如:

H|20220601|XXXX
F00001234

这是我的平面文件架构

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

试图将记录设置为minoccurrs = 0和<代码> nillable ,但错误仍然存​​在。在这种情况下,如何获取管道来处理没有记录的文件?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽清梦 2025-02-17 01:33:44

如果您的行没有标签,并且您有其他记录,请更改模式属性,将解析器优化从速度到复杂性。
原因是因为该行没有标签,因此很难识别行何时结束。

将其设置为复杂性执行以下操作

在复杂性模式下,平面解析引擎同时使用自上而下和自下而上解析,并尝试更准确地拟合数据。在速度模式下,解析器试图在流中显示数据。

解析模式(learn..microsoft.com)。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文