具有嵌套记录的位置平面文件

问题描述 投票:0回答:2

有些灵魂请建议我或帮我解决这个平面文件?我不知道如何实现我想要的。

如下所示,有一些字段可用作标记标识符。

我们有'S'代表开始标记,'I'代表客户信息,'F'代表发票明细,'N'代表备注部分,最后是'E'代表结束部分。正如你所看到的,还有重复的记录,这种嵌套和位置记录的使用给我带来了麻烦。因此,每个F部分(客户)都有自己的重复发票和备注。

我确实尝试了这个奇妙的post的提示,但在这个问题上不幸的是没有嵌套。

奇怪的是,如果我不考虑位置记录,我可以设法得到我想要的东西。如果我只是将整个数据放入一个字段(即整个F没有定位),我可以得到正确的结构,包括重复。但它们是位置的,我,F和N而且我所有的挣扎总是会产生错误,要么说它正在寻找标签标识符字母,要么就是在寻找回车和行尾。任何帮助都会受到高度赞赏,因为我已经在这方面挣扎了很长一段时间。

样本文件:

S                                                                                                                                                                                                       
I02710242Company name 01               Postboks 123 Sum                                            010223 14 15 50 54                            9597598396200468                             NO                                                                                                                                                                                      N                                                          
F141220178065428         00000102700-13012018000000080654288                                                                                                                  
NINK       !!!!!!!!!!!                                                                                                                                                                                                               
F141220178065429         00000197200-13012018000000080654296                                                                                                                  
NINK       !!!!!!!!!!!                                                                                                                                                                                                               
I02710242Company name 02               Postboks 234 Seum                                           010223 14 16 50 54                            9597598396200468                             NO                                                                                                                                                                                      N                                                          
F050120185794526         00003686250+04022018000000057945263                                                                                                                  
NINK       !!!!!!!!!!!                                                                                                                                                                                                               
F141220178065428         00000102700-13012018000000080654288                                                                                                                  
NINK       !!!!!!!!!!!                                                                                                                                                                                                               
F141220178065429         00000197200-13012018000000080654296                                                                                                                  
NINK       !!!!!!!!!!!                                                                                                                                                                                                               
E000000420000005000030679668+

所以我认为我想要实现(除非你们中的任何人有更好的设置)是一个如下所示的模式:

S
---I
     -F
     -N
     -F
     -N

  -I 
     -F
     -N
     -F
     -N
E
nested biztalk flat-file
2个回答
0
投票

我为你做了一个例子,这将验证您的示例消息。我没有巫师就这样做了。虽然向导是了解一些事情的一个很好的起点,但复杂的嵌套应该只是手工尝试。

有几点需要注意:

  • 您的孩子订单是每个重复record的中缀。
  • 您没有非重复订单的子订单,而是将这些订单指定为positional
  • 如果重复,则分隔符是换行符。这意味着在每个重复的record上你都有指定的分隔符,或者你在<Schema>级别指定了一个默认的分隔符。

我认为你的问题部分是关于识别模式,正如你在我的样本中看到的那样,模式是不同的;在I行之后,有一个FN行的重复模式,我将其封装在一个名为Repeatingchild的记录中。

你仍然可以使你的模式工作;

  • 通过删除Repeatingchild记录并将所有元素放在Repeating记录中来编辑下面的示例。
  • Parser Optimization级别将Complexity设置为<Schema>,如果你不这样做,它将在I记录中遇到麻烦。

仍然缺少的是你对每个领域的确切位置映射,但我已经证明了我放置的Irecord_part1Irecord_part2的位置。我接下来要做的是仍然分别使用每一行的向导来制作所有的行元素。因此,拆分每一行并在每个行类型上运行向导。

为了使它更漂亮,你可以制作代表header and the trailer的单独模式。所以我想S记录将是标题,而E记录将是预告片。

 <?xml version="1.0" encoding="utf-16"?>
    <xs:schema xmlns="StackOverflow.FlatFileSchema1" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="StackOverflow.FlatFileSchema1" 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="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="true" 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_delimiter_type="hex" child_order="infix" child_delimiter="0x0A" />
          </xs:appinfo>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:annotation>
              <xs:appinfo>
                <b:groupInfo sequence_number="0" />
              </xs:appinfo>
            </xs:annotation>
            <xs:element minOccurs="1" maxOccurs="1" name="SRecord">
              <xs:annotation>
                <xs:appinfo>
                  <b:recordInfo structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" tag_name="S" />
                </xs:appinfo>
              </xs:annotation>
              <xs:complexType>
                <xs:sequence>
                  <xs:annotation>
                    <xs:appinfo>
                      <b:groupInfo sequence_number="0" />
                    </xs:appinfo>
                  </xs:annotation>
                  <xs:element name="Srecord" type="xs:string">
                    <xs:annotation>
                      <xs:appinfo>
                        <b:fieldInfo justification="left" sequence_number="1" pos_length="200" />
                      </xs:appinfo>
                    </xs:annotation>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="Repeating">
              <xs:annotation>
                <xs:appinfo>
                  <b:recordInfo sequence_number="2" structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="hex" child_delimiter="0x0A" child_order="infix" repeating_delimiter_type="hex" repeating_delimiter="0x0A" />
                </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" maxOccurs="unbounded" name="IRecord">
                    <xs:annotation>
                      <xs:appinfo>
                        <b:recordInfo structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" tag_name="I" />
                      </xs:appinfo>
                    </xs:annotation>
                    <xs:complexType>
                      <xs:sequence>
                        <xs:annotation>
                          <xs:appinfo>
                            <b:groupInfo sequence_number="0" />
                          </xs:appinfo>
                        </xs:annotation>
                        <xs:element name="Irecord_part1" type="xs:string">
                          <xs:annotation>
                            <xs:appinfo>
                              <b:fieldInfo justification="left" sequence_number="1" pos_length="133" />
                            </xs:appinfo>
                          </xs:annotation>
                        </xs:element>
                        <xs:element name="Irecord_part2" type="xs:string">
                          <xs:annotation>
                            <xs:appinfo>
                              <b:fieldInfo sequence_number="2" justification="left" pos_length="200" />
                            </xs:appinfo>
                          </xs:annotation>
                        </xs:element>
                      </xs:sequence>
                    </xs:complexType>
                  </xs:element>
                  <xs:element minOccurs="0" maxOccurs="unbounded" name="Repeatingchild">
                    <xs:annotation>
                      <xs:appinfo>
                        <b:recordInfo sequence_number="2" structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="hex" child_delimiter="0x0A" child_order="infix" />
                      </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" maxOccurs="unbounded" name="FRecord">
                          <xs:annotation>
                            <xs:appinfo>
                              <b:recordInfo structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" tag_name="F" />
                            </xs:appinfo>
                          </xs:annotation>
                          <xs:complexType>
                            <xs:sequence>
                              <xs:annotation>
                                <xs:appinfo>
                                  <b:groupInfo sequence_number="0" />
                                </xs:appinfo>
                              </xs:annotation>
                              <xs:element name="Frecord" type="xs:string">
                                <xs:annotation>
                                  <xs:appinfo>
                                    <b:fieldInfo justification="left" sequence_number="1" pos_length="174" />
                                  </xs:appinfo>
                                </xs:annotation>
                              </xs:element>
                            </xs:sequence>
                          </xs:complexType>
                        </xs:element>
                        <xs:element minOccurs="0" maxOccurs="unbounded" name="NRecord">
                          <xs:annotation>
                            <xs:appinfo>
                              <b:recordInfo sequence_number="2" structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="N" />
                            </xs:appinfo>
                          </xs:annotation>
                          <xs:complexType>
                            <xs:sequence>
                              <xs:annotation>
                                <xs:appinfo>
                                  <b:groupInfo sequence_number="0" />
                                </xs:appinfo>
                              </xs:annotation>
                              <xs:element name="Nrecord" type="xs:string">
                                <xs:annotation>
                                  <xs:appinfo>
                                    <b:fieldInfo justification="left" sequence_number="1" pos_length="229" />
                                  </xs:appinfo>
                                </xs:annotation>
                              </xs:element>
                            </xs:sequence>
                          </xs:complexType>
                        </xs:element>
                      </xs:sequence>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="ERecord">
              <xs:annotation>
                <xs:appinfo>
                  <b:recordInfo structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="E" sequence_number="3" />
                </xs:appinfo>
              </xs:annotation>
              <xs:complexType>
                <xs:sequence>
                  <xs:annotation>
                    <xs:appinfo>
                      <b:groupInfo sequence_number="0" />
                    </xs:appinfo>
                  </xs:annotation>
                  <xs:element name="Erecord" type="xs:string">
                    <xs:annotation>
                      <xs:appinfo>
                        <b:fieldInfo justification="left" sequence_number="1" pos_length="29" />
                      </xs:appinfo>
                    </xs:annotation>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>

0
投票

诀窍是,在向导的一个步骤中,您选择一个完整的重复组(I ... N)并设置一个重复元素的重复组。

然后,向导将向下钻取到I ... N并定义子记录,这些子记录也可以使用字段重复组或记录。

多次运行向导以使结构正确,没有任何问题。我们都做过很多次了。

© www.soinside.com 2019 - 2024. All rights reserved.