gpt4 book ai didi

BizTalk 平面文件复杂性解析问题

转载 作者:行者123 更新时间:2023-12-02 14:35:58 24 4
gpt4 key购买 nike

我目前正在创建一个平面文件模式来实现一种名为 Tradacoms 的旧英国 EDI 格式。我已经复制了我正在处理的模式部分所需的内容,并且通常运行良好。但是,由于架构中有很多可选项目,我需要将解析器优化更改为复杂性。

为了轻松解释问题,我将问题重现为一个更小的模式(实际上与 Tradacom 完全无关)。

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Bidvest.Integration.Supplier.Schemas.TestSchema" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Bidvest.Integration.Supplier.Schemas.TestSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo standard="Flat File" root_reference="Root" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="complexity" lookahead_depth="0" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" />
<schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
</xs:appinfo>
</xs:annotation>
<xs:element name="Root">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="infix" child_delimiter_type="char" child_delimiter="+" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="0" />
</xs:appinfo>
</xs:annotation>
<xs:element name="Name" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Address">
<xs:annotation>
<xs:appinfo>
<b:recordInfo sequence_number="2" structure="delimited" preserve_delimiter_for_empty_data="false" suppress_trailing_delimiters="false" child_order="infix" child_delimiter_type="char" child_delimiter=":" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="0" />
</xs:appinfo>
</xs:annotation>
<xs:element minOccurs="0" name="Line1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Line2" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Line3" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Line4" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Line5" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="5" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="PostCode" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="6" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Country" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo sequence_number="7" justification="left" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

该架构包含一个名称元素和一个地址记录,该记录本身具有许多可选元素。

如果我使用下面的测试文件验证实例(右键单击架构等)

DAve+Line1:Line2:Line3:Line4:Line5:PostCode:Country

然后我按预期得到下面的输出

<Root xmlns="http://Bidvest.Integration.Supplier.Schemas.TestSchema">
<Name xmlns="">DAve</Name>
<Address xmlns="">
<Line1>Line1</Line1>
<Line2>Line2</Line2>
<Line3>Line3</Line3>
<Line4>Line4</Line4>
<Line5>Line5</Line5>
<PostCode>PostCode</PostCode>
<Country>Country</Country>
</Address>
</Root>

如果我使用如下非常简单的消息验证实例

DAve+Line1

然后我得到以下输出

<Root xmlns="http://Bidvest.Integration.Supplier.Schemas.TestSchema">
<Name xmlns="">DAve</Name>
<Address xmlns="">
<Line4>Line1</Line4>
</Address>
</Root>

您可以看到 Line1 已放置在 Line4 元素中。由于上面的示例消息将文本“Line1”作为分隔符之前的第一个值,因此我预计上面的 XML 是 Line1。

这里发生了一些非常奇怪的事情。有人可以帮忙吗?我在 BizTalk 2013 (CU3) 和 BizTalk 2013 R2 中遇到此问题。

最佳答案

是的,如果记录开头没有必填字段,平面文件反汇编程序可能会变得非常困惑。您已将所有地址元素设置为可选,然后可能会得到非常奇怪的结果。我发现您应该始终至少有一个必填字段作为第一个字段,并且永远不应该在可选字段之后有一个必填字段。

如果您删除 line1 上的 minOccurs = 0,它会正常工作,并且您会得到以下结果。

<Root xmlns="http://Bidvest.Integration.Supplier.Schemas.TestSchema">
<Name xmlns="">DAve</Name>
<Address xmlns="">
<Line1>Line1</Line1>
</Address>
</Root>

它甚至可以处理以下输入

DAve+

得到以下输出

<Root xmlns="http://Bidvest.Integration.Supplier.Schemas.TestSchema">
<Name xmlns="">DAve</Name>
<Address xmlns="">
<Line1/>
</Address>
</Root>

或者

DAve

输出

<Root xmlns="http://Bidvest.Integration.Supplier.Schemas.TestSchema">
<Name xmlns="">DAve</Name>
</Root>

关于BizTalk 平面文件复杂性解析问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34153403/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com