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

时间:2018-09-04 07:45:37

标签: nested biztalk flat-file

有什么好心的人请给我建议或帮我解决这个平面文件吗?我不知道如何实现我想要的。

正如您在下面看到的,有一些字段可用作标记标识符。

我们在开始标记中使用“ 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

2 个答案:

答案 0 :(得分:0)

技巧是,在向导的一个步骤中,选择整个重复组(I ... N),然后设置一个重复元素。

然后,向导将向下钻取I ... N,让您定义子记录,这些子记录也可以是重复的“组”或“带有字段的记录”。

多次运行向导以使结构正确无误。我们已经完成了很多次。

答案 1 :(得分: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>
相关问题