I have to flatfiles that i need to convert into UBL using Biztalk.
Everything is fine until I reach the end of the flatfiles.
One of them looks like this
RZ0100120400R;RZ01-00120400;RAZER MAMBA 2012 EL;2;739,77;2013.06.12
RZ0100580100R;RZ01-00580100;RAZER NAGA 2012;1;482,38;2013.06.12
RZ0400590100R;RZ04-00590100;RAZER TIAMAT EXPERT;2;605,3;2013.06.12
TOTA;L FAKTURAVÆRDI;EKSKL. MOMS;;18.667,30;
the other one like this:
382908;382908;Anymode Samsung Gal;4;88,87;2013.06.13
382909;382909;Anymode Samsung Gal;4;88,87;2013.06.13
ANYMODESAMSUN;ANYMODE SAMSU;ANYMODE ANYMODE SAM;4;88,87;2013.06.13
;;;;;
TOTA;L FAKTURAVÆRDI;EKSKL. MOMS;;8.116,31;
If I make a schemas for one the other one won't work. So my question is. How do I make a schema that can take both of them, without problems?? I just need something to ajust for the empty line in the first example. I am using Visual Studio Flatfile Wizard.
You could make the record/line in question as well as all of its child field elements optional (Min Occurs = 0).
Sample Schema (tested with both sample flat files provided...):
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://SampleProject.FlatFileSchema1" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://SampleProject.FlatFileSchema1" 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="infix" 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:element minOccurs="0" maxOccurs="unbounded" name="line">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" child_delimiter_type="char" child_delimiter=";" child_order="infix" 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:element minOccurs="0" name="Child1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Child2" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Child3" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Child4" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Child5" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="5" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Child6" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="6" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Hope that helps!
Best regards
Philipp