Re: Flat file to XML

Home Page Forums BizTalk 2004 – BizTalk 2010 Flat file to XML Re: Flat file to XML

#17203

Here is the schema created:

 <?xml version="1.0" encoding="utf-16" ?>
– <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
– <xs:annotation>
– <xs:appinfo>
  <b:schemaInfo count_positions_by_byte="false" parser_optimization="speed"
lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true"
allow_early_termination="false" standard="Flat File" root_reference="Root" />
  <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="true"
sequence_number="1" child_order="default" child_delimiter_type="hex"
child_delimiter="0x0D 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="1" name="HDR">
– <xs:annotation>
– <xs:appinfo>
  <b:recordInfo sequence_number="1" structure="delimited"
preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false"
child_delimiter_type="hex" child_delimiter="0x7C" tag_name="HDR"
child_order="default" />
  </xs:appinfo>
  </xs:annotation>
– <xs:complexType>
– <xs:sequence>
– <xs:annotation>
– <xs:appinfo>
  <b:groupInfo sequence_number="0" />
  </xs:appinfo>
  </xs:annotation>
– <xs:element name="Field1" type="xs:string">
– <xs:annotation>
– <xs:appinfo>
  <b:fieldInfo sequence_number="1" justification="left" />
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
– <xs:element name="Field2" type="xs:string">
– <xs:annotation>
– <xs:appinfo>
  <b:fieldInfo sequence_number="2" justification="left" />
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
– <xs:element minOccurs="0" maxOccurs="unbounded" name="BDY">
– <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_order="default" child_delimiter="0x7C"
tag_name="BDY" />
  </xs:appinfo>
  </xs:annotation>
– <xs:complexType>
– <xs:sequence>
– <xs:annotation>
– <xs:appinfo>
  <b:groupInfo sequence_number="0" />
  </xs:appinfo>
  </xs:annotation>
– <xs:element name="Field1" type="xs:string">
– <xs:annotation>
– <xs:appinfo>
  <b:fieldInfo sequence_number="1" justification="left" />
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
– <xs:element name="Field2" type="xs:string">
– <xs:annotation>
– <xs:appinfo>
  <b:fieldInfo sequence_number="2" justification="left" />
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
– <xs:element minOccurs="0" maxOccurs="1" name="MSG">
– <xs:annotation>
– <xs:appinfo>
  <b:recordInfo sequence_number="3" structure="delimited"
preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false"
tag_name="MSG" child_order="default" child_delimiter_type="hex"
child_delimiter="0x7C" />
  </xs:appinfo>
  </xs:annotation>
– <xs:complexType>
– <xs:sequence>
– <xs:annotation>
– <xs:appinfo>
  <b:groupInfo sequence_number="0" />
  </xs:appinfo>
  </xs:annotation>
– <xs:element name="Field1" type="xs:string">
– <xs:annotation>
– <xs:appinfo>
  <b:fieldInfo sequence_number="1" justification="left" />
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
– <xs:element name="Field2" type="xs:string">
– <xs:annotation>
– <xs:appinfo>
  <b:fieldInfo sequence_number="2" justification="left" />
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
– <xs:element minOccurs="0" maxOccurs="1" name="DOC">
– <xs:annotation>
– <xs:appinfo>
  <b:recordInfo sequence_number="4" structure="delimited"
preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false"
child_order="default" child_delimiter_type="hex" child_delimiter="0x7C"
tag_name="DOC" />
  </xs:appinfo>
  </xs:annotation>
– <xs:complexType>
– <xs:sequence>
– <xs:annotation>
– <xs:appinfo>
  <b:groupInfo sequence_number="0" />
  </xs:appinfo>
  </xs:annotation>
– <xs:element name="Field1" type="xs:string">
– <xs:annotation>
– <xs:appinfo>
  <b:fieldInfo sequence_number="1" justification="left" />
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:schema>

And the test file:

HDR|File|A Header test
BDY|Name|A Body test
BDY|Name|A Body test2
MSG|To file|A Message
DOC|HDR|File|A Header test
BDY|Name|A Body test
BDY|Name|A Body test2
MSG|To file|A Message

Note: The DOC record contains all records from HDR to MSG.

Thanks for your helping.