|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
IB 9 DFDL choice |
« View previous topic :: View next topic » |
Author |
Message
|
GmanZA |
Posted: Mon Feb 24, 2014 11:11 am Post subject: IB 9 DFDL choice |
|
|
Newbie
Joined: 24 Feb 2014 Posts: 5
|
How do you define a complex recurring structure in DFDL in IB 9?
Structure something like this
Header
Data type 1
Data type 2
Data type 1
Data type 1
Data type 1
Data type 2
Trailer
Type 1 is always followed by a type 2, creating sets of data.
Choice within a sequence does not seem to work for this scenario. Each data type is identified by a group of initiators. And it does not look like max occurs on sequence can be changed to unbound?
Your urgent help is much appreciated. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Feb 24, 2014 12:23 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
it does not look like max occurs on sequence can be changed to unbound? |
Correct. Some xsd features are not allowed in DFDL, and repeating groups are one example of that. If you want a repeating choice then you must wrap the choice group in an element, and set maxOccurs on the element. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
GmanZA |
Posted: Mon Feb 24, 2014 12:56 pm Post subject: |
|
|
Newbie
Joined: 24 Feb 2014 Posts: 5
|
Thanks for they quick response Kimbert
My definition has header as implicit as length kind then new element i defined as delimeted and trailer as implicit again. When testing parsing a test file it fails with an error saying the expected initiator is that of the trailer and not one of the data types.
Do you perhaps have an example that you can share? |
|
Back to top |
|
 |
kimbert |
Posted: Mon Feb 24, 2014 1:06 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I don't have an example ( custom message formats are almost always unique), but I can help anyway.
Quote: |
it fails with an error saying the expected initiator is that of the trailer and not one of the data types. |
OK - so the DFDL parser obviously thought it was supposed to find another occurrence of the choice element. Without seeing your DFDL schema it's hard to be sure, but I would guess that you have set the 'Occurs Count Kind' property incorrectly. It should be set to 'implicit'.
The Length Kind property controls how the length of the entire structure is determined, and 'implicit' is the correct setting for almost all complex elements.
If my guess is wrong, or if it still doesn't work then
a) post your xsd ( in [c o d e] tags please
b) post the relevant section of the DFDL trace ( available in the DFDL Debug perspective on one of the tabs near the bottom of the screen ) _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
GmanZA |
Posted: Mon Feb 24, 2014 1:46 pm Post subject: |
|
|
Newbie
Joined: 24 Feb 2014 Posts: 5
|
Thanks again for the response. Below the code and trace.
Code: |
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:ibmDfdlExtn="http://www.ibm.com/dfdl/extensions" xmlns:ibmSchExtn="http://www.ibm.com/schema/extensions" xmlns:recFixLengthFieldsFmt="http://www.ibm.com/dfdl/RecordFixLengthFieldFormat" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.ibm.com/dfdl/RecordFixLengthFieldFormat" schemaLocation="IBMdefined/RecordFixLengthFieldFormat.xsd"/>
<xsd:annotation>
<xsd:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format byteOrder="{$dfdl:byteOrder}" encoding="{$dfdl:encoding}" escapeSchemeRef="recFixLengthFieldsFmt:RecordEscapeScheme" occursCountKind="fixed" ref="recFixLengthFieldsFmt:RecordFixLengthFieldsFormat" separatorSuppressionPolicy="anyEmpty"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:element dfdl:lengthKind="implicit" dfdl:outputNewLine="{$dfdl:outputNewLine}" ibmSchExtn:docRoot="true" name="main">
<xsd:complexType>
<xsd:sequence dfdl:separator="%CR;%LF;%WSP*;">
<xsd:element dfdl:initiator="02" dfdl:lengthKind="implicit" dfdl:outputNewLine="{$dfdl:outputNewLine}" minOccurs="1" name="header">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="4" dfdl:representation="text" dfdl:textPadKind="padChar" dfdl:textStringJustification="right" name="header_e_1" type="xsd:string"/>
<xsd:element dfdl:length="8" dfdl:representation="text" name="header_e_2" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="header_e_3" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="header_e_4" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="header_e_5" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="header_e_6" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="header_e_7" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="header_e_8" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="header_e_9" type="xsd:string"/>
<xsd:element dfdl:length="10" dfdl:representation="text" name="header_e_10" type="xsd:string"/>
<xsd:element dfdl:length="8" dfdl:representation="text" name="header_e_11" type="xsd:string"/>
<xsd:element dfdl:length="116" dfdl:outputNewLine="%LF;" dfdl:representation="text" name="header_e_12" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element dfdl:initiator="04" dfdl:lengthKind="implicit" dfdl:outputNewLine="{$dfdl:outputNewLine}" minOccurs="1" name="subHeader">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="4" dfdl:representation="text" name="subHeader_e_1" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subHeader_e_2" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subHeader_e_3" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subHeader_e_4" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subHeader_e_5" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subHeader_e_6" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="subHeader_e_7" type="xsd:string"/>
<xsd:element dfdl:length="10" dfdl:representation="text" name="subHeader_e_8" type="xsd:string"/>
<xsd:element dfdl:length="130" dfdl:representation="text" name="subHeader_e_9" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element dfdl:lengthKind="implicit" dfdl:occursCountKind="implicit" maxOccurs="unbounded" name="groupingElement">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:initiator="20 60" dfdl:lengthKind="implicit" dfdl:occursCountKind="implicit" dfdl:outputNewLine="{$dfdl:outputNewLine}" maxOccurs="unbounded" name="dataType1">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="6" dfdl:representation="text" name="dataType1_e_1" type="xsd:string"/>
<xsd:element dfdl:length="11" dfdl:representation="text" name="dataType1_e_2" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="dataType1_e_3" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="dataType1_e_4" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="dataType1_e_5" type="xsd:string"/>
<xsd:element dfdl:length="11" dfdl:representation="text" name="dataType1_e_6" type="xsd:string"/>
<xsd:element dfdl:length="1" dfdl:representation="text" name="dataType1_e_7" type="xsd:string"/>
<xsd:element dfdl:length="11" dfdl:representation="text" name="dataType1_e_8" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="dataType1_e_9" type="xsd:string"/>
<xsd:element dfdl:length="2" dfdl:representation="text" name="dataType1_e_10" type="xsd:string"/>
<xsd:element dfdl:length="1" dfdl:representation="text" name="dataType1_e_11" type="xsd:string"/>
<xsd:element dfdl:length="2" dfdl:representation="text" name="dataType1_e_12" type="xsd:string"/>
<xsd:element dfdl:length="1" dfdl:representation="text" name="dataType1_e_13" type="xsd:string"/>
<xsd:element dfdl:length="30" dfdl:representation="text" name="dataType1_e_14" type="xsd:string"/>
<xsd:element dfdl:length="30" dfdl:representation="text" name="dataType1_e_15" type="xsd:string"/>
<xsd:element dfdl:length="20" dfdl:representation="text" name="dataType1_e_16" type="xsd:string"/>
<xsd:element dfdl:length="16" dfdl:representation="text" name="dataType1_e_17" type="xsd:string"/>
<xsd:element dfdl:length="2" dfdl:representation="text" name="dataType1_e_18" type="xsd:string"/>
<xsd:element dfdl:length="12" dfdl:representation="text" name="dataType1_e_19" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element dfdl:initiator="22 62" dfdl:lengthKind="implicit" dfdl:outputNewLine="{$dfdl:outputNewLine}" name="dataType2">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="6" dfdl:representation="text" name="dataType2_e_1" type="xsd:string"/>
<xsd:element dfdl:length="11" dfdl:representation="text" name="dataType2_e_2" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="dataType2_e_3" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="dataType2_e_4" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="dataType2_e_5" type="xsd:string"/>
<xsd:element dfdl:length="11" dfdl:representation="text" name="dataType2_e_6" type="xsd:string"/>
<xsd:element dfdl:length="1" dfdl:representation="text" name="dataType2_e_7" type="xsd:string"/>
<xsd:element dfdl:length="11" dfdl:representation="text" name="dataType2_e_8" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="dataType2_e_9" type="xsd:string"/>
<xsd:element dfdl:length="2" dfdl:representation="text" name="dataType2_e_10" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="dataType2_e_11" type="xsd:string"/>
<xsd:element dfdl:length="30" dfdl:representation="text" name="dataType2_e_12" type="xsd:string"/>
<xsd:element dfdl:length="30" dfdl:representation="text" name="dataType2_e_13" type="xsd:string"/>
<xsd:element dfdl:length="50" dfdl:representation="text" name="dataType2_e_14" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element dfdl:initiator="92" dfdl:lengthKind="implicit" dfdl:outputNewLine="{$dfdl:outputNewLine}" minOccurs="1" name="subTrailer">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="4" dfdl:representation="text" name="subTrailer_e_1" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subTrailer_e_2" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subTrailer_e_3" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subTrailer_e_4" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subTrailer_e_5" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subTrailer_e_6" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subTrailer_e_7" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="subTrailer_e_8" type="xsd:string"/>
<xsd:element dfdl:length="12" dfdl:representation="text" name="subTrailer_e_9" type="xsd:string"/>
<xsd:element dfdl:length="12" dfdl:representation="text" name="subTrailer_e_10" type="xsd:string"/>
<xsd:element dfdl:length="12" dfdl:representation="text" name="subTrailer_e_11" type="xsd:string"/>
<xsd:element dfdl:length="96" dfdl:representation="text" name="subTrailer_e_12" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element dfdl:initiator="94" dfdl:lengthKind="implicit" dfdl:outputNewLine="{$dfdl:outputNewLine}" minOccurs="1" name="trailer">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="2" name="trailer_e_1" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="trailer_e_2" type="xsd:string"/>
<xsd:element dfdl:length="8" dfdl:representation="text" name="trailer_e_3" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="trailer_e_4" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="trailer_e_5" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="trailer_e_6" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="trailer_e_7" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="trailer_e_8" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="trailer_e_9" type="xsd:string"/>
<xsd:element dfdl:length="4" dfdl:representation="text" name="trailer_e_10" type="xsd:string"/>
<xsd:element dfdl:length="10" dfdl:representation="text" name="trailer_e_11" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="trailer_e_12" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="trailer_e_13" type="xsd:string"/>
<xsd:element dfdl:length="6" dfdl:representation="text" name="trailer_e_14" type="xsd:string"/>
<xsd:element dfdl:length="106" dfdl:representation="text" dfdl:terminator="" name="trailer_e_15" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema> |
Trace:
Feb 24, 2014, 11:44:11 PM info: Offset: 544. Did not find initiator for 'dataType1'
[dfdl = /testDFDL/sample.xsd, scd = #xscd(/schemaElement::main/type::0/model::sequence/schemaElement::groupingElement/type::0/model::sequence/schemaElement::dataType1), 59]
Feb 24, 2014, 11:44:11 PM info: Offset: 544. Element 'dataType1' is empty because the initiator was not found in the data stream.
[dfdl = /testDFDL/sample.xsd, scd = #xscd(/schemaElement::main/type::0/model::sequence/schemaElement::groupingElement/type::0/model::sequence/schemaElement::dataType1), 105]
Feb 24, 2014, 11:44:11 PM error: CTDP3041E: Initiator '20' not found at offset '544' for element '/main[1]/groupingElement[1]/dataType1[2]'.
Feb 24, 2014, 11:44:11 PM info: Offset: 544. Parser was unable to resolve data on the current branch and will evaluate the next available branch beginning at offset '544' owned by the 'sequence' group contained within element 'groupingElement'.
[dfdl = /testDFDL/sample.xsd, scd = #xscd(/schemaElement::main/type::0/model::sequence/schemaElement::groupingElement/type::0/model::sequence), 220]
Feb 24, 2014, 11:44:11 PM info: Offset: 544. Occurrence '2' of element 'dataType1' was not found in the data. occursCountKind is 'implicit' so no more occurrences of this element will be expected.
[dfdl = /testDFDL/sample.xsd, scd = #xscd(/schemaElement::main/type::0/model::sequence/schemaElement::groupingElement/type::0/model::sequence/schemaElement::dataType1), 173]
Feb 24, 2014, 11:44:11 PM info: Offset: 544. Starting to process element 'dataType2'.
[dfdl = /testDFDL/sample.xsd, scd = #xscd(/schemaElement::main/type::0/model::sequence/schemaElement::groupingElement/type::0/model::sequence/schemaElement::dataType2), 61]
Feb 24, 2014, 11:44:11 PM info: Offset: 544. Did not find initiator for 'dataType2'
[dfdl = /testDFDL/sample.xsd, scd = #xscd(/schemaElement::main/type::0/model::sequence/schemaElement::groupingElement/type::0/model::sequence/schemaElement::dataType2), 59]
Feb 24, 2014, 11:44:11 PM info: Offset: 544. Element 'dataType2' is empty because the initiator was not found in the data stream.
[dfdl = /testDFDL/sample.xsd, scd = #xscd(/schemaElement::main/type::0/model::sequence/schemaElement::groupingElement/type::0/model::sequence/schemaElement::dataType2), 105]
Feb 24, 2014, 11:44:11 PM error: CTDP3041E: Initiator '22' not found at offset '544' for element '/main[1]/groupingElement[1]/dataType2[1]'.
Feb 24, 2014, 11:44:11 PM fatal: CTDP3041E: Initiator '22' not found at offset '544' for element '/main[1]/groupingElement[1]/dataType2[1]'.
Last edited by GmanZA on Mon Feb 24, 2014 11:09 pm; edited 1 time in total |
|
Back to top |
|
 |
kimbert |
Posted: Mon Feb 24, 2014 3:44 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Looks as if your trace was truncated - probably because it was too long. Please take the time to post only the *relevant* portion of the trace, as I requested. I don't see why I ( or anybody else ) should do that part for you. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
GmanZA |
Posted: Tue Feb 25, 2014 1:35 am Post subject: |
|
|
Newbie
Joined: 24 Feb 2014 Posts: 5
|
Ok, I now have the DFDL parsing, but the result is not quite as expected.
What I am getting is.
Code: |
Header
Group
DataType1
Group
DataType2
Group
DataType1
Group
DataType1
Group
DataType2
Trailer
|
What i was expecting
Code: |
Header
Group
DataType1
DataType2
Group
DataType1
DataType1
DataType2
Trailer
|
Is this type of layout achievable?
Last edited by GmanZA on Tue Feb 25, 2014 10:45 am; edited 2 times in total |
|
Back to top |
|
 |
kimbert |
Posted: Tue Feb 25, 2014 7:19 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Sorry if this sounds picky, but please can you edit your last post and put [c o d e] tags around your message layouts ( use the button just above the edit window ). That way, the indentation will be preserved and I will be able to see the structure. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Feb 26, 2014 2:45 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
In that case you do not need a choice group at all.
You need a structure like this:
Code: |
element name="document"
sequence group
element name="header"
element name="Group" maxOccurs="unbounded"
sequence group
element name="DataType1" maxOccurs="unbounded"
element name="DataType2" minOccurs=0 maxOccurs=1
|
or something similar.
In other words, group consecutive DataType1's together, and always start a new Group after a single DataType2. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|