Create a schema for the OutPut file

92 views Asked by At

I am trying to create a output file schema which should be of the below format.

MEMBER,1,134,134,Jo, ,Arch,1,S,M
BENEFIT,1,M,1,89,7,1,1,20110101,20120731,11
BENEFIT,1,D,2,89,3,11,5,20110101,20120731,16
MEMBER,14,448,448,Cli,M,Ast,1,M,M
BENEFIT,14,D,2,89,3,11,5,20170101,17000101,16
BENEFIT,14,M,1,89,7,1,1,20170101,17000101,11
BENEFIT,14,M,1,89,7,1,1,20150101,20161231,11

So in the Flat File schema, should I create two records one for the Member (with one as the Max Occur) and One for Benefit (max occur to unbounded)? enter image description here

Am I doing it right

1

There are 1 answers

0
Dijkgraaf On

Does your input XML message contain multiple Members?

If so you will want to add a Sequence Group with a Max Occurs set to either the maximum number of Members or Unbounded. And then yes, Member = 1 and Benefit unbounded.

Repeating Sequence Schema

Also you should be using tag identifiers in Member and Benefit set to MEMBER and BENEFIT respectively, so if you ever have to use the schema to parse the file you can do so successfully.

enter image description here

Schema for reference

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.41367483" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.41367483" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
      <b:schemaInfo standard="Flat File" codepage="65001" 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="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" root_reference="Root" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Root">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0xD 0xA" child_order="postfix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo>
            <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
          </xs:appinfo>
        </xs:annotation>
        <xs:sequence maxOccurs="unbounded">
          <xs:annotation>
            <xs:appinfo>
              <groupInfo sequence_number="1" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
            </xs:appinfo>
          </xs:annotation>
          <xs:element name="Member">
            <xs:annotation>
              <xs:appinfo>
                <b:recordInfo tag_name="MEMBER" structure="delimited" child_delimiter_type="char" child_delimiter="," child_order="prefix" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" />
              </xs:appinfo>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:annotation>
                  <xs:appinfo>
                    <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:element name="EMPLOYEE_ID_01" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="1" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="Subscriber_ID" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="2" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="PrimaryID" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="3" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="F_Name" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="4" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="M_Initial" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="5" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="L_Name" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="6" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="R_Code" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="7" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="Marital" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="8" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="Gender" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <fieldInfo sequence_number="9" justification="left" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
          <xs:element maxOccurs="unbounded" name="Benefit">
            <xs:annotation>
              <xs:appinfo>
                <b:recordInfo tag_name="BENEFIT" structure="delimited" child_delimiter_type="char" child_delimiter="," child_order="prefix" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="2" />
              </xs:appinfo>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:annotation>
                  <xs:appinfo>
                    <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:element name="EMPPLOYEE_ID_02" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="1" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="L_Code" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="2" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="E_Number" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="3" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="C_Number" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="4" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="Suffix" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="5" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="Account" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="6" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="Plan_ID" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <fieldInfo justification="left" sequence_number="7" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="E_Date" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="8" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="T_Date" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <fieldInfo justification="left" sequence_number="9" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
                <xs:element name="C_O" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="10" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Note: If you do use Tag Identifier you will either have to change the Child order to Prefix, or include the first coma in the Tag Identifier and keep it Infix.