Reputation: 1
I have managed to map each line by splitting them horizontally.
The problem comes when (Q1, Q2)
and (Q3, Q4) are not coming together under their respective enclosing tags. Also, we need to take care of a group of lines repeating. Like in the example below I have first two lines repeated again.
Q12222222222
Q21111111111
Q13333333333
Q24444444444
Q35555555555
Q46666666666
Target XSD file given below:
<xs:schema>
<xs:element name="Statement">
<xs:complexType>
<xs:sequence>
<xs:element name="StatementDetails" type="StatementDetailsT" maxOccurs="unbounded"/>
<xs:element name="FinalStatement" type="FinalStatementT" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="StatementDetailsT">
<xs:sequence>
<xs:element name="Q1" type="Q1_T" maxOccurs="1"/>
<xs:element name="Q2" type="Q2_T" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="FinalStatementT">
<xs:sequence>
<xs:element name="Q3" type="Q3_T" maxOccurs="1"/>
<xs:element name="Q4" type="Q4_T" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Q1_T">
<xs:sequence>
<xs:element type="st:string2" name="cIdentifier" fixed="Q1" />
<xs:element type="st:string10" name="sNumber" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Q2_T">
<xs:sequence>
<xs:element type="st:string2" name="cIdentifier" fixed="Q2" />
<xs:element type="st:string11" name="antiDumpingDuty" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Q3_T">
<xs:sequence>
<xs:element type="st:string2" name="cIdentifier" fixed="Q3" />
<xs:element type="st:string10" name="sNumber" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Q4_T">
<xs:sequence>
<xs:element type="st:string2" name="cIdentifier" fixed="Q4" />
<xs:element type="st:string11" name="antiDumpingDuty" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Expected XML should look like given below:
<Statement>
<StatementDetails>
<Q1>
<cIdentifier>Q1</cIdentifier>
<sNumber>2222222222</sNumber>
</Q1>
<Q2>
<cIdentifier>Q2</cIdentifier>
<antiDumpingDuty>1111111111</antiDumpingDuty>
</Q2>
</StatementDetails>
<StatementDetails>
<Q1>
<cIdentifier>Q1</cIdentifier>
<sNumber>3333333333</sNumber>
</Q1>
<Q2>
<cIdentifier>Q2</cIdentifier>
<antiDumpingDuty>4444444444</antiDumpingDuty>
</Q2>
</StatementDetails>
<FinalStatement>
<Q3>
<cIdentifier>Q3</cIdentifier>
<sNumber>5555555555</sNumber>
</Q3>
<Q4>
<cIdentifier>Q4</cIdentifier>
<antiDumpingDuty>6666666666</antiDumpingDuty>
</Q4>
</FinalStatement>
</Statement>
I have applied split in following order:
Repeated Split with Mode:delimited(line starts with),
Reg-ex:Yes, pattern: ^Q[13]
This divides data into 3 segments of two rows each.
Switch contains regular expression : ^Q[12]
, ^Q[34]
.
Then each output of step-2 is applied with Repeated split horizontally, this divides each segment into single lines. Which then applied with multiple split once depending upon column length.
Split and Mapping diagrams attached for reference.
Actual XML file produced by mapping is given below:
<Statement>
<StatementDetails>
<Q1>
<cIdentifier>Q1</cIdentifier>
<sNumber>2222222222</sNumber>
</Q1>
</StatementDetails>
<StatementDetails>
<Q2>
<cIdentifier>Q2</cIdentifier>
<antiDumpingDuty>1111111111</antiDumpingDuty>
</Q2>
</StatementDetails>
<StatementDetails>
<Q1>
<cIdentifier>Q1</cIdentifier>
<sNumber>3333333333</sNumber>
</Q1>
</StatementDetails>
<StatementDetails>
<Q2>
<cIdentifier>Q2</cIdentifier>
<antiDumpingDuty>4444444444</antiDumpingDuty>
</Q2>
</StatementDetails>
<FinalStatement>
<Q3>
<cIdentifier>Q3</cIdentifier>
<sNumber>5555555555</sNumber>
</Q3>
</FinalStatement>
<FinalStatement>
<Q4>
<cIdentifier>Q4</cIdentifier>
<antiDumpingDuty>6666666666</antiDumpingDuty>
</Q4>
</FinalStatement>
</Statement>
Please someone suggest what is going wrong in the structure or mapping? Thanks in advance.
Upvotes: 0
Views: 594
Reputation: 1433
when you connect "RepeatedSplit - horizontal" to "StatementDetails", your mapping will create a "StatementDetails" tag each time the event "RepeatedSplit - horizontal" is found.
This could explain why Q1 and Q2 are not grouped.
I can suggest you to delete this connection, and instead to add a second connection starting from "ROW Q1" to "StatementDetails".
I guess it should create the "StatementDetails" tag only when "Q1" is found.
I am not able to test right now the solution that I am proposing.
Could test and let us know if it worked for you?
Upvotes: 0