Would some kind soul please advice me or help me out with this flat file? I do not know how to achieve what I want.
As you can see below there are a few fields which can be used as tag identifiers.
We have 'S' for the start tag, 'I' for customer information, 'F' for invoice details, 'N' for the note section and lastly 'E' for the end section. As you can see there are repeating records as well and this mix of nesting and the use of positional records is giving me trouble.
So, every F-section (customer) has its own set of repeating invoice with note.
I did try the tips on this wonderful post but in this issue no nesting exists unfortunately.
The strange thing is that I can manage to get what I want if I do not take into consideration the positional records. If I just take the entire data and put it into one field (i.e. entire F without positioning) I can get the structure right and that includes the repeating. But they are positional, I, F and N and all my struggle always yields in an error either stating that it is looking for a tag identifier letter or that it is looking for a carriage return and end of line. Any help would be greatly appreciated as I have been struggling with this for quite a while now.
Sample file:
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+
So what I think I would like to achieve (unless any of you have a better setup) is a schema that looks like this:
S
---I
-F
-N
-F
-N
-I
-F
-N
-F
-N
E
I cooked up an example for you, this will validate with your sample message. I made this without the Wizard. Although the Wizard is a great starting point to get to know some things, complex nesting should just be tried out by hand.
A few things to notice:
Your child order is infix for every repeating record.
You don't have a child order for non-repeating ones, instead, these are specified as positional.
The delimiter is a linefeed if it's repeating. This means on every repeating record you have that delimiter specified or you've specified a default one at the <Schema> level.
I think your problem was partially about recognizing the pattern, as you see in my sample, the pattern is different; After the I row, there is a repeating pattern of F and N rows, which i encapsulated in a record named Repeatingchild.
You could still make your pattern work;
Edit my sample below by removing the Repeatingchild record and placing all elements at the Repeating record.
Set Parser Optimization to Complexity at the <Schema> level, if you don't do this, it will have trouble with the I record.
What's still missing is your exact positional mapping for each field, but I've proven the positionality with the Irecord_part1 and Irecord_part2 i placed in. What i would do next is still use the wizard for each row individually to make all the row elements. So split out each row and run the Wizard on each row type.
To make it even more pretty, you could make individual schema's representing the header and the trailer. So i guess the S record would be the header, and the E record would be the trailer.
<?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>
The trick is, in one step of the Wizard, you select an entire repeating group (I...N) and set that of one Repeating element.
The Wizard will then drill down into the I...N and have you define sub-records, which can also be repeating Groups or Records with Fields.
There's nothing wrong with running the Wizard multiple times to get the structure right. We've all done it...many times.
Related
i have a flat file with header and trailers with Tag Identifiers as APTHDR and APTDTL respectively.
The current file has me miffed however, as it has a repeating record issue.
File Structure:
20data for the summary information
HE Header of record
DE Detail of record
HE Header of record
DE Detail of record
DE Detail of record
20 trailler data
record 20 = one instance for summary, one instance for trailler
record.
record HE: one HE have multiple DE. one file have multiple HE.
this is the data example:
20201117125512HH 001APPOINTMENT DATA 85372
HE0350100000001 1 2CROS04202020-11-25012020-11-25 15:30:00.000000 PIC077120 128027 2020-11-17 12:50:52.000265 N N 0000004390000000000186000000 00000 PIC077120 023095412
DE035010000000C116780360635000000439PIC077120 023095412
HE0350100000001 1 2CACG05002020-11-25012020-11-25 14:00:00.000000 3501382191/, 183699 2020-11-17 12:51:02.000864 N Y NS0000013210083300043754000000 00000 3501382191/, 1621476023035082
DE035010000000C3100203821910000010013501382191/, 1621476023035082
DE035010000000C3100202566840000001003501382191/, 1621476023035082
DE035010000000C3100203826550000001073501382191/, 1621476023035082
DE035010000000C3100203852630000000203501382191/, 1621476023035082
DE035010000000C3100203746790000000183501382191/, 1621476023035082
DE035010000000C3100202903510000000753501382191/, 1621476023035082
20201117125512TT 001000000000000000000110000000000
I get the results in the correct placement if I use a single set, but once I try to create a multiple record file it get hosed.
I just have no idea how to fix it.
Thanks!
First of all you need to create 3 schemas, a Header, a Body and a Trailer.
Split the file you have into those components so you can test each schema against that part, for the body just have the one HE and multiple DE.
Then you need to create a pipeline with a flat file disassemble component and set all three schema in the properties.
Deploy these, create a receive port and location that uses the pipeline, and have something subscribing to the messages.
Example schemas
Header schema
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO68310662" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.SO68310662" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo standard="Flat File" root_reference="Header" 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" />
<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="Header">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="postfix" 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 name="HeaderRecord">
<xs:annotation>
<xs:appinfo>
<b:recordInfo sequence_number="1" structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="0" />
</xs:appinfo>
</xs:annotation>
<xs:element name="DateTime">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_length="14" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:element>
<xs:element name="Field" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_length="64" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Body Schema
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO68310662" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.SO68310662" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo standard="Flat File" root_reference="Body" 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" />
<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="Body">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="postfix" 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 name="HeaderRecord">
<xs:annotation>
<xs:appinfo>
<b:recordInfo sequence_number="1" structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name=" HE" />
</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 justification="left" pos_length="263" sequence_number="1" pos_offset="3" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="DetailRecord">
<xs:annotation>
<xs:appinfo>
<b:recordInfo sequence_number="2" structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name=" DE" />
</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 justification="left" sequence_number="1" pos_length="63" pos_offset="3" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Trailer schema
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO68310662" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.SO68310662" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo standard="Flat File" root_reference="Header" 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" />
<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="Header">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="postfix" 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 name="TrailerRecord">
<xs:annotation>
<xs:appinfo>
<b:recordInfo sequence_number="1" structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="0" />
</xs:appinfo>
</xs:annotation>
<xs:element name="DateTime">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_length="14" sequence_number="1" pos_offset="1" />
</xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:element>
<xs:element name="Field" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_length="37" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Output message 1
<Body xmlns="http://Scratch.SO68310662">
<HeaderRecord xmlns="">
<Field1>0350100000001 1 2CACG05002020-11-25012020-11-25 14:00:00.000000 3501382191/, 183699 2020-11-17 12:51:02.000864 N Y NS0000013210083300043754000000 00000 3501382191/, 1621476023035082</Field1>
</HeaderRecord>
<DetailRecord xmlns="">
<Field1>035010000000C3100203821910000010013501382191/, 1621476023035082</Field1>
</DetailRecord>
<DetailRecord xmlns="">
<Field1>035010000000C3100202566840000001003501382191/, 1621476023035082</Field1>
</DetailRecord>
<DetailRecord xmlns="">
<Field1>035010000000C3100203826550000001073501382191/, 1621476023035082</Field1>
</DetailRecord>
<DetailRecord xmlns="">
<Field1>035010000000C3100203852630000000203501382191/, 1621476023035082</Field1>
</DetailRecord>
<DetailRecord xmlns="">
<Field1>035010000000C3100203746790000000183501382191/, 1621476023035082</Field1>
</DetailRecord>
<DetailRecord xmlns="">
<Field1>035010000000C3100202903510000000753501382191/, 1621476023035082</Field1>
</DetailRecord>
</Body>
Output message 2
<Body xmlns="http://Scratch.SO68310662">
<HeaderRecord xmlns="">
<Field1>0350100000001 1 2CROS04202020-11-25012020-11-25 15:30:00.000000 PIC077120 128027 2020-11-17 12:50:52.000265 N N 0000004390000000000186000000 00000 PIC077120 023095412</Field1>
</HeaderRecord>
<DetailRecord xmlns="">
<Field1>035010000000C116780360635000000439PIC077120 023095412</Field1>
</DetailRecord>
</Body>
I am a newer in BizTalk and I must create an XSD-schema from a CSV-file:
As you can see, it includes header and orders. Every order has it's own order-header - row with name of the shop and filled Period field, but with empty Quantity, Price, Cost and Currency fields. Every order has few positions, which have filled all fields, except Period. Every order-header has ItemNumber = 0. How to create correct flat file schema in this situation?
OrderDate;OrderNumber;ItemNumber;DESCRIPTION_LONG;Quantity;Price;Cost;Period;Currency
30-04-17;9;0;Shop: McDonalds;;;;2017-04;
30-04-17;9;1;Double burger;2;5,99;11,98;;USD
30-04-17;9;2;Coca-Cola;2;2,19;4,38;;USD
30-04-17;10;0;Shop: Hunting and fishing;;;;2017-04;
30-04-17;10;1;Fishing rod;2;10,90;21,80;;USD
30-04-17;10;2;Bait;5;1,00;5,00;;USD
30-04-17;10;3;Hunting gun;1;999,00;999,00;;USD
I think the best option is parse your Flat File to an XML without trying to 'force' the final structure, as Pieter said on before answer. Something like this:
<Root xmlns="http://BizTalkMassCopy.FlatFileSchema3">
<Header xmlns="">
<HeaderOrderDate>OrderDate</HeaderOrderDate>
<HeaderOrderNumber>OrderNumber</HeaderOrderNumber>
<HeaderItemNumber>ItemNumber</HeaderItemNumber>
<HeaderDescription>DESCRIPTION_LONG</HeaderDescription>
<HeaderQuantity>Quantity</HeaderQuantity>
<HeaderPrice>Price</HeaderPrice>
<HeaderCost>Cost</HeaderCost>
<HeaderPeriod>Period</HeaderPeriod>
<HeaderCurrency>Currency</HeaderCurrency>
</Header>
<OrderItem xmlns="">
<OrderDate>30-04-17</OrderDate>
<OrderNumber>9</OrderNumber>
<ItemNumber>0</ItemNumber>
<Description>Shop: McDonalds</Description>
<Quantity></Quantity>
<Price></Price>
<Cost></Cost>
<Period>2017-04</Period>
<Currency></Currency>
</OrderItem>
<OrderItem xmlns="">
<OrderDate>30-04-17</OrderDate>
<OrderNumber>9</OrderNumber>
<ItemNumber>1</ItemNumber>
<Description>Double burger</Description>
<Quantity>2</Quantity>
<Price>5,99</Price>
<Cost>11,98</Cost>
<Period></Period>
<Currency>USD</Currency>
</OrderItem>
<OrderItem xmlns="">
<OrderDate>30-04-17</OrderDate>
<OrderNumber>9</OrderNumber>
<ItemNumber>2</ItemNumber>
<Description>Coca-Cola</Description>
<Quantity>2</Quantity>
<Price>2,19</Price>
<Cost>4,38</Cost>
<Period></Period>
<Currency>USD</Currency>
</OrderItem>
<OrderItem xmlns="">
<OrderDate>30-04-17</OrderDate>
<OrderNumber>10</OrderNumber>
<ItemNumber>0</ItemNumber>
<Description>Shop: Hunting and fishing</Description>
<Quantity></Quantity>
<Price></Price>
<Cost></Cost>
<Period>2017-04</Period>
<Currency></Currency>
</OrderItem>
<OrderItem xmlns="">
<OrderDate>30-04-17</OrderDate>
<OrderNumber>10</OrderNumber>
<ItemNumber>1</ItemNumber>
<Description>Fishing rod</Description>
<Quantity>2</Quantity>
<Price>10,90</Price>
<Cost>21,80</Cost>
<Period></Period>
<Currency>USD</Currency>
</OrderItem>
<OrderItem xmlns="">
<OrderDate>30-04-17</OrderDate>
<OrderNumber>10</OrderNumber>
<ItemNumber>2</ItemNumber>
<Description>Bait</Description>
<Quantity>5</Quantity>
<Price>1,00</Price>
<Cost>5,00</Cost>
<Period></Period>
<Currency>USD</Currency>
</OrderItem>
<OrderItem xmlns="">
<OrderDate>30-04-17</OrderDate>
<OrderNumber>10</OrderNumber>
<ItemNumber>3</ItemNumber>
<Description>Hunting gun</Description>
<Quantity>1</Quantity>
<Price>999,00</Price>
<Cost>999,00</Cost>
<Period></Period>
<Currency>USD</Currency>
</OrderItem>
</Root>
With a flat schema similar to this:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://BizTalkMassCopy.FlatFileSchema3" targetNamespace="http://BizTalkMassCopy.FlatFileSchema3" 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 name="Header">
<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 name="HeaderOrderDate" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="HeaderOrderNumber" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="HeaderItemNumber" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="HeaderDescription" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="HeaderQuantity" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="5" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="HeaderPrice" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="6" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="HeaderCost" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="7" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="HeaderPeriod" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="8" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="HeaderCurrency" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="9" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="OrderItem">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" child_delimiter_type="char" child_delimiter=";" child_order="infix" sequence_number="2" 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 name="OrderDate" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="OrderNumber" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ItemNumber" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Description" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Quantity" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="5" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Price" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="6" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Cost" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="7" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Period" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="8" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Currency" 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:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
And then use a map to obtain the final result, with grouping mechanism such as Grouping in Biztalk Map Based on Multiple Elements
You might be able to do this using tag Identifiers (see https://blogs.msdn.microsoft.com/biztalknotes/2013/02/05/flat-file-schema-creation-with-tag-identifiers-in-the-input-flat-file-repeating-in-a-random-fashion/ for an example), but I'm not 100% sure this would work without issues, since the identifier (ItemNumber = 0) is not in the beginning of the line. My experience shows me the Flat file disassembler probing has limited success in those cases.
My general recommendation to people in this case would be not to try and 'force' structure in your flat file schema, since obviously your flat file structure does not have it. What I see is that each line has the same structure/format. It's only functionally different.
From that perspective I would go for a Flat File schema matching your CSV-file structure (one type of record with comma-separated fields and with a newline as a line delimiter) and, from there, map to a schema which makes more sense functionally.
My solution is,
Create a source schema for parse your flat file.
Create a destination schema for grouped result
Create a map for group your source schema.
Add this Inline XSLT Scripts to your map
For the first script functoid
<xsl:key name="groups" match="Order" use="OrderNumber"/>
For the second script functoid
<xsl:for-each select="Order[generate-id(.)=generate-id(key('groups',OrderNumber))]">
<xsl:sort select="OrderNumber" order="ascending"/>
<xsl:choose>
<xsl:when test="OrderDate != 'OrderDate'">
<Order>
<OrderDate><xsl:value-of select="OrderDate/text()" /></OrderDate>
<OrderNumber><xsl:value-of select="OrderNumber/text()" /></OrderNumber>
<Description><xsl:value-of select="Description/text()" /></Description>
<Period><xsl:value-of select="Period/text()" /></Period>
<Items>
<xsl:for-each select="key('groups',OrderNumber)">
<xsl:choose>
<xsl:when test="ItemNumber > '0'">
<Item>
<ItemNumber><xsl:value-of select="ItemNumber" /></ItemNumber>
<Quantity><xsl:value-of select="Quantity" /></Quantity>
<Price><xsl:value-of select="Price" /></Price>
<Cost><xsl:value-of select="Cost" /></Cost>
<Currency><xsl:value-of select="Currency" /></Currency>
</Item>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</Items>
</Order>
</xsl:when>
</xsl:choose>
</xsl:for-each>
Test your map and get this output.
<ns0:Orders xmlns:ns0="http://BizTalkServerTestProject.FlatFileSchema6">
<Order>
<OrderDate>30-04-17</OrderDate>
<OrderNumber>10</OrderNumber>
<Description>Shop: Hunting and fishing</Description>
<Period>2017-04</Period>
<Items>
<Item>
<ItemNumber>1</ItemNumber>
<Quantity>2</Quantity>
<Price>10,90</Price>
<Cost>21,80</Cost>
<Currency>USD</Currency>
</Item>
<Item>
<ItemNumber>2</ItemNumber>
<Quantity>5</Quantity>
<Price>1,00</Price>
<Cost>5,00</Cost>
<Currency>USD</Currency>
</Item>
<Item>
<ItemNumber>3</ItemNumber>
<Quantity>1</Quantity>
<Price>999,00</Price>
<Cost>999,00</Cost>
<Currency>USD</Currency>
</Item>
</Items>
</Order>
<Order>
<OrderDate>30-04-17</OrderDate>
<OrderNumber>9</OrderNumber>
<Description>Shop: McDonalds</Description>
<Period>2017-04</Period>
<Items>
<Item>
<ItemNumber>1</ItemNumber>
<Quantity>2</Quantity>
<Price>5,99</Price>
<Cost>11,98</Cost>
<Currency>USD</Currency>
</Item>
<Item>
<ItemNumber>2</ItemNumber>
<Quantity>2</Quantity>
<Price>2,19</Price>
<Cost>4,38</Cost>
<Currency>USD</Currency>
</Item>
</Items>
</Order>
</ns0:Orders>
You can find full source code of the schemas and the map from this URL.http://blog.sarslan.com/group-source-schema-in-a-map/
I have a positional flat file which contains records with a repeating sequence, like this;
TOKEN NAME LABEL VALUE LABEL VALUE LABEL VALUE LABEL VALUE ..
The TOKEN identifies the type of record, the name is a name value, and the LABEL (10 positions) and VALUE (50 positions) pairs can repeat a not-fixed number of times (1..*).
I have defined a flat file schema as below; It contains a (1..*), with a LABEL and a VALUE with the correct positional data:
Both LABEL and VALUE have a minOccurs and a maxOccurs of 1.
The problem I have is that BizTalk does not seam to be able to handle this situation. When I generate a (native) instance for this schema I get the following output:
TOKEN NAME LABEL VALUE
(It generates only a single instance of LABEL VALUE).
When I try to read a file that has multiple occurrences of LABEL VALUE pairs (5), it gives me the following XML:
<FILE xmlns="http://schemas.demo/2015/01">
<RepeatingRecord xmlns="">
<NAME>NAME</NAME>
<LABEL>LABEL</LABEL>
<LABEL>VALUE</LABEL>
<LABEL>LABEL</LABEL>
<LABEL>VALUE</LABEL>
<LABEL>LABEL</LABEL>
<LABEL>VALUE</LABEL>
<LABEL>LABEL</LABEL>
<LABEL>VALUE</LABEL>
<LABEL>LABEL</LABEL>
<LABEL>VALUE</LABEL>
</RepeatingRecord>
</FILE>
So I only get LABEL tags, but no VALUE tags. The contents of the VALUE parts are placed wrongly in a LABEL tag.
I would expect the following XML:
<FILE xmlns="http://schemas.demo/2015/01">
<RepeatingRecord xmlns="">
<NAME>NAME</NAME>
<LABEL>LABEL</LABEL>
<VALUE>VALUE</VALUE>
<LABEL>LABEL</LABEL>
<VALUE>VALUE</VALUE>
<LABEL>LABEL</LABEL>
<VALUE>VALUE</VALUE>
<LABEL>LABEL</LABEL>
<VALUE>VALUE</VALUE>
<LABEL>LABEL</LABEL>
<VALUE>VALUE</VALUE>
</RepeatingRecord>
</FILE>
How can I define a flat file schema with a repeating sequence in the record?
I currently have the following schema:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://schemas.goudse.nl/irma/adapter/2015/01" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.goudse.nl/irma/adapter/2015/01" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo standard="Flat File" root_reference="FILE" default_pad_char="0x20" pad_char_type="hex" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="true" generate_empty_nodes="false" allow_early_termination="true" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" document_type="ASFBatchFlatFileSchema" version="2015.01" schema_type="document" default_child_order="postfix" child_delimiter_type="hex" default_child_delimiter="0x0D 0x0A" />
<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="FILE">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="default" notes="Een compleet bestand" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="0" />
</xs:appinfo>
</xs:annotation>
<xs:element minOccurs="1" maxOccurs="unbounded" name="RepeatingRecord">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="TOKEN " notes="Data behorende bij de schadebrief" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="0" />
</xs:appinfo>
</xs:annotation>
<xs:element name="NAME" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" pos_length="12" pos_offset="6" pad_char_type="hex" pad_char="0x20" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="2" />
</xs:appinfo>
</xs:annotation>
<xs:element minOccurs="1" maxOccurs="1" name="LABEL" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_length="10" pad_char_type="hex" pad_char="0x20" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="1" maxOccurs="1" name="VALUE" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_length="50" pad_char_type="hex" pad_char="0x20" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
and the following test data file (replaced spaces with periods for clarity, the schema defines spaces for padding).
TOKEN.NAME........LABEL.....VALUE.............................................LABEL.....VALUE.............................................LABEL.....VALUE.............................................LABEL.....VALUE.............................................LABEL.....VALUE.............................................
UPDATE
What I did not mention in this question (for sake of simplicity) is that this record is used in a flat file with multiple kinds of different records, so splitting this record into child-records is not a viable solution.
I was able to validate the input from the top of your post with the following, hopefully it gets you ont he right track:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://BizTalk_Server_Project2.FlatFileSchema2" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BizTalk_Server_Project2.FlatFileSchema2" 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="FILE" />
</xs:appinfo>
</xs:annotation>
<xs:element name="FILE">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="positional" 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 name="FILE_Child1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="6" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="FILE_Child2" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="5" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="unbounded" name="FILE_Child3">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="positional" sequence_number="3" 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 name="FILE_Child3_Child1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="6" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="FILE_Child3_Child2" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="6" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
BizTalk newbie here...
I have a flat file output schema which consists of 4 child records, and for each input record, the map needs to write each of the child records. The issue that I am having is that the output is coming out in this order:
Rec 1
Rec 1
Rec 2
Rec 2
Rec 3
Rec 3
Rec 4
Rec 4
The specs call for the file in this order:
Rec 1
Rec 2
Rec 3
Rec 4
Rec 1
Rec 2
etc
I have tried creating the schema in several different ways, I have asked coworkers with more BizTalk experience, and I have googled 'til my eyes are crossed, but I have yet to find a solution.
I have considered, but not yet tried, using XSLT to sort the output, but the difficulty that I foresee in that method is that each of the child records is a different length and some of the child records have additional key fields.
Hoping someone has prior experience with this situation.
1/2/14 update:
Here's the current output schema:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://SonomaCounty.BizTalk.EFS.APImport.Schemas.PSSinglePayVoucherFF" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://SonomaCounty.BizTalk.EFS.APImport.Schemas.PSSinglePayVoucherFF" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="SinglePayVoucher">
<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:element maxOccurs="unbounded" name="VoucherHeader">
<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:element name="RowID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="BusinessUnit" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VchrBldKeyC1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VchrBldKeyN1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VoucherID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="5" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VoucherStyle" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="6" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="InvoiceID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="7" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="InvoiceDt" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="8" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VendorSetID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="9" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VendorID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="10" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Origin" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="11" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="GrossAmt" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="12" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="MatchAction" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="13" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VchrApprvlFlg" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="14" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VchrSrc" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="15" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="VoucherLine">
<xs:complexType>
<xs:sequence>
<xs:element name="RowID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="BusinessUnit" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VchrBldKeyC1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VchrBldKeyN1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VoucherID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="5" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VoucherLineNbr" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="6" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Descr" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="7" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="QtyVchr" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="8" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="UnitOfMeasure" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="9" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ShipToID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="10" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="VoucherDist">
<xs:complexType>
<xs:sequence>
<xs:element name="RowID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="BusinessUnit" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VchrBldKeyC1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VchrBldKeyN1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VoucherID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="5" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VoucherLineNum" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="6" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DistribLineNum" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="7" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="GLBusUnit" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="8" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Account" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="9" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DeptID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="10" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="FundCode" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="11" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="QtyVchr" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="12" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="MerchAmt" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="13" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="VoucherVendor">
<xs:complexType>
<xs:sequence>
<xs:element name="RowID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="BusinessUnit" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VchrBldKeyC1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VchrBldKeyN1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VoucherID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="5" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Name1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="6" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Name2" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="7" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Address1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="8" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Address2" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="9" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="City" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="10" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="State" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="11" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Zip" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="12" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Here's is a sample input schema:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://SonomaCounty.BizTalk.EFS.APImport.Schemas.ProbationRestitutionFF" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://SonomaCounty.BizTalk.EFS.APImport.Schemas.ProbationRestitutionFF" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="RestitutionPayment">
<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:element maxOccurs="unbounded" name="Detail">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" child_order="infix" sequence_number="2" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="hex" child_delimiter="0x09" />
</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="VNum" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Name" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Address1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Address2" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="CityStateZip" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="5" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="AcctName" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="6" wrap_char_type="char" wrap_char=""" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Cat" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="7" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Ref" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="8" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DisbAmt" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="9" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Your situation is fairly common and the solution an be pretty eash depending on home much control you have over the two schemas.
For your flat file, Rec 1-4 must be children of the same Parent:
<RecordsParent>
<Rec1/>
<Rec1/>
<Rec1/>
<Rec1/>
</RecordsParent>
RecordsParent should be maxOccurs=unbounded.
Then, from the source schema, use a Looping Functoid to connect the parent of Rec 1-4 sources to RecordsElement.
This will cause the Mapper to add an additional for-each around the parent elements which in most cases will give you the output you want.
BizTalk flat file schema with nested nodes is giving me some trouble. What is happening is that the child record delimiter is showing up as data in the last field. I followed the recipe from this old blog post.
Managing Flat Files in BizTalk 2004
Here is the input and schema are here.
https://bitbucket.org/kirk98445/stuff/src/90becbaa638b1bc42555cf84f2a1a4cb4f3cd3fc?at=master
Result is that the xml looks fine for the most part except for the crlf in the user and ponumber fields.
<Orders xmlns="http://KS.Biztalk.EDI.Common.Amtech.ASN.FlatFileSchema1"><Header><user>USER_1234
</user></Header><Order><OrderHeader><ponumber>PO_001
</ponumber></OrderHeader><LineItems><LineItem><item>Item32 33</item></LineItem><LineItem><item>Item63 45</item></LineItem></LineItems></Order><Order><OrderHeader><ponumber>PO_002
</ponumber></OrderHeader><LineItems><LineItem><item>Item454 12</item></LineItem></LineItems></Order></Orders>
There are issues with your schema.
Record "Orders" - The Child Delimiter Type property is not set for a delimited record.
Record "Order" - The Child Delimiter Type property is not set for a delimited record.
Usually with this sort of flat file I would create one schema for the header, and then one for the Order & Order Lines. Then in the flat file dissembler define set the Header schema and the Document schema to the above two.
This way it will de-batch you will get a message for each purchase order in the file.
But if you want it in a single schema, try this schema that uses a Sequence Group node.
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://KS.Biztalk.EDI.Common.Amtech.ASN.FlatFileSchema1" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" elementFormDefault="qualified" targetNamespace="http://KS.Biztalk.EDI.Common.Amtech.ASN.FlatFileSchema1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo standard="Flat File" root_reference="Orders" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="true" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" child_delimiter_type="hex" default_child_delimiter="0x0D 0x0A" default_child_order="postfix" />
<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="Orders">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="postfix" 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="1" maxOccurs="1" name="Header">
<xs:annotation>
<xs:appinfo>
<b:recordInfo sequence_number="1" structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="HEADER" child_delimiter_type="hex" child_delimiter="0x09" child_order="prefix" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="0" />
</xs:appinfo>
</xs:annotation>
<xs:element name="user" 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 maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="2" />
</xs:appinfo>
</xs:annotation>
<xs:element name="OrderHeader">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="PURCHASE" child_order="prefix" child_delimiter_type="hex" child_delimiter="0x09" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="0" />
</xs:appinfo>
</xs:annotation>
<xs:element name="ponumber" 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:element maxOccurs="unbounded" name="LineItem">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="LINEITEM" child_delimiter_type="hex" child_delimiter="0x09" child_order="prefix" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<b:groupInfo sequence_number="0" />
</xs:appinfo>
</xs:annotation>
<xs:element name="item" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo sequence_number="1" justification="left" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Qty" 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:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>