title: BizTalk FlatFile Schema multiple repeating records
body: <p>I have a flat file and I need to create a schema so I can convert that flat file into XML and bring it to BizTalk.</p>
  
  <p>I have used flat file schema wizard to create a schema but it is not working. I've modified it manually still not working. I will explain what is not working.</p>
  
  <pre><code>Flat File structure:
  File header
  Batch header
  Detail (repeating records)
  Address (repeating records)
  Trailer
  END
  </code></pre>
  
  <p>After creating the schema I'm trying to validate it and I'm getting error at this point.
  Detail and Address are the body and they are repeatable. 
  My issue is that after it reads the line "DET" it is suppose to read the "ADD". However it is looking for "DET" again.</p>
  
  <blockquote>
    <p>Error description:
    error BEC2004: Unexpected data found while looking for:
    'DET'
    The current definition being parsed is RefundsRoot. The stream offset where the error occured is 799. The line number where the error occured is 4. The column where the error occured is 0.</p>
  </blockquote>
  
  <p>Here is the sample</p>
  
  <pre><code>FDR06281339CREDIT REFUND CHECKS                                AC
  HDR9008100000000000100006428
  DET900810000000636992103500048763699210350004876369921035000487STMT, TEST 5                01TEST 5 STMT                                         6902 PINE ST                                        OMAHA             NE68106-2855                  0000000000+0000000000500000                 00FINUT A    +00000000000004900                         FHSC999999          +0000000000500     EN          0099000000000                            +0000000000000+000000000000000000+0000000000000+000000000000000000+0000000000000+0000000000000000000000000000+00009999999999999+00009999999999999+00000000000000000+00000000000000000+999999999999999+99999999999999900000000000+9999999999999990000000000000009900
  ADDF                                                                                                                                                      6902 PINE ST                                                                                                                                                                                                      OMAHA                    NE                         68106-2855USA
  TRL90081000000000001000000020000000000000642800000000000004900000000000000000000
  END000000100000000200000000000000000000004900000000000000000000
  </code></pre>
  
  <p>Here is the schema (due to character limits I've only included related section)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt;
  &lt;xs:schema xmlns="http://Fingerhut.BizTalk.Schemas.FSIn_Refunds" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Fingerhut.BizTalk.Schemas.FSIn_Refunds" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;xs:annotation&gt;
      &lt;xs:appinfo&gt;
        &lt;schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" /&gt;
        &lt;b:schemaInfo standard="Flat File" codepage="65001" default_pad_char="0x0A 0x0D" pad_char_type="hex" 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="true" compile_parse_tables="false" root_reference="RefundsRoot" /&gt;
      &lt;/xs:appinfo&gt;
    &lt;/xs:annotation&gt;
    &lt;xs:element name="RefundsRoot"&gt;
      &lt;xs:annotation&gt;
        &lt;xs:appinfo&gt;
          &lt;b:recordInfo structure="delimited" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" /&gt;
        &lt;/xs:appinfo&gt;
      &lt;/xs:annotation&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
                &lt;xs:complexType name="Detail"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:annotation&gt;
          &lt;xs:appinfo&gt;
            &lt;groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" /&gt;
          &lt;/xs:appinfo&gt;
        &lt;/xs:annotation&gt;
        &lt;xs:element name="DETL-HDR" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="1" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-SYSTEM" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="4" sequence_number="2" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-PRIN-BANK" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="4" sequence_number="3" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-AGENT-BANK" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="4" sequence_number="4" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-ACCOUNT-NUMBER" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="16" sequence_number="5" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-PRMR-PI-ID" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="16" sequence_number="6" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-ENTR-ID" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="16" sequence_number="7" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-PI-NM" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="26" sequence_number="8" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-FILLER" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="2" sequence_number="9" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-PI-ROLE-CD" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="2" sequence_number="10" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-PRIMARY-NAME" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="26" sequence_number="11" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-SECONDARY-NAME" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="26" sequence_number="12" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-ADDRESS-LINE-1" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="26" sequence_number="13" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-ADDRESS-LINE-2" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="26" sequence_number="14" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-CITY" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="18" sequence_number="15" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-STATE" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="2" sequence_number="16" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-POST-CODE" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="10" sequence_number="17" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-REF-NUM" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="18" sequence_number="18" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-CHK-STARTING-NUM" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="5" sequence_number="19" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-NUMBER-OF-CKS" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="4" sequence_number="20" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-DUALITY-FLAG" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="1" sequence_number="21" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-CREDIT-LIMIT" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="14" sequence_number="22" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-NUMBER-OF-PLASTICS" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="23" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="DETL-CHECKING-ACCOUNT-NUM" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="17" sequence_number="24" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:complexType name="Address"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:annotation&gt;
          &lt;xs:appinfo&gt;
            &lt;groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" /&gt;
          &lt;/xs:appinfo&gt;
        &lt;/xs:annotation&gt;
        &lt;xs:element name="ADDR-EXPN-ADDR-RCRD-HEDR-ID" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="1" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-PRMR-CUST-ADDR-FRMT-CD" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="1" sequence_number="2" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-ATTN-LINE-TX" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="3" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-CMPN-NM" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="4" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-HOUS-NR" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="10" sequence_number="5" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-STRT-NM" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="40" sequence_number="6" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-CNTN-ADDR-LINE-1-TX" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="7" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-CNTN-ADDR-LINE-2-TX" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="8" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-CNTN-ADDR-LINE-3-TX" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="9" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-CNTN-ADDR-LINE-4-TX" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="10" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-PO-BOX-TX" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="10" sequence_number="11" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-CITY-NM" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="25" sequence_number="12" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-ST-CD" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="2" sequence_number="13" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-SBDV-TX" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="25" sequence_number="14" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-PSTL-CD" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="10" sequence_number="15" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-CTRY-CD" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="16" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ADDR-FILLER" type="xs:string"&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;b:fieldInfo sequence_number="17" justification="left" pos_length="271" pos_offset="0" /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
        &lt;/xs:element&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:schema&gt;
  </code></pre>