Reputation: 7625
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.
Upvotes: 1
Views: 3392
Reputation: 21641
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>
Upvotes: 2