Author |
Message
|
CAONIMA |
Posted: Thu Feb 11, 2016 7:31 am Post subject: DFDL Model Error |
|
|
Acolyte
Joined: 03 Dec 2014 Posts: 65
|
Hi All,
I parse a sample text file through the DFDL Model
Here is the text file:
Quote: |
CAOCA1 11 51 71
CAOCA2 12 52 72
CAOCA3 13 53 73
|
Here is the XSD file:
Code: |
<xsd:element dfdl:length="12" dfdl:lengthKind="explicit" ibmSchExtn:docRoot="true" name="EDI852">
<xsd:complexType>
<xsd:sequence dfdl:separator="">
<xsd:element dfdl:lengthKind="implicit" dfdl:occursCountKind="implicit" dfdl:terminator="%CR;%LF;%WSP*;" maxOccurs="unbounded" name="record">
<xsd:complexType>
<xsd:sequence dfdl:separator="" dfdl:separatorSuppressionPolicy="never">
<xsd:element dfdl:initiator="" dfdl:length="6" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value1" name="field1" type="xsd:string"/>
<xsd:element dfdl:initiator="%WSP*;" dfdl:length="2" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value2" name="field2" type="xsd:string"/>
<xsd:element dfdl:initiator="%WSP*;" dfdl:length="2" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value3" name="field3" type="xsd:string"/>
<xsd:element dfdl:initiator="" dfdl:length="6" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value4" name="field4" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element> |
And here is the exception:
Quote: |
error: CTDP3000E: Unexpected end of data at byte offset '18' while parsing element '#xscd(/schemaElement::EDI852/type::0/model::sequence/schemaElement::record/type::0/model::sequence/schemaElement::field4)'. The parser encountered the end of the data stream or the end of a parent element. |
Only the last one ,71,cannot parse in.
Can anyone can help me figure it out?
Thank you very much. |
|
Back to top |
|
 |
maurito |
Posted: Thu Feb 11, 2016 7:54 am Post subject: Re: DFDL Model Error |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
CAONIMA wrote: |
Hi All,
I parse a sample text file through the DFDL Model
Here is the text file:
Quote: |
CAOCA1 11 51 71
CAOCA2 12 52 72
CAOCA3 13 53 73
|
Here is the XSD file:
Code: |
<xsd:element dfdl:length="12" dfdl:lengthKind="explicit" ibmSchExtn:docRoot="true" name="EDI852">
<xsd:complexType>
<xsd:sequence dfdl:separator="">
<xsd:element dfdl:lengthKind="implicit" dfdl:occursCountKind="implicit" dfdl:terminator="%CR;%LF;%WSP*;" maxOccurs="unbounded" name="record">
<xsd:complexType>
<xsd:sequence dfdl:separator="" dfdl:separatorSuppressionPolicy="never">
<xsd:element dfdl:initiator="" dfdl:length="6" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value1" name="field1" type="xsd:string"/>
<xsd:element dfdl:initiator="%WSP*;" dfdl:length="2" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value2" name="field2" type="xsd:string"/>
<xsd:element dfdl:initiator="%WSP*;" dfdl:length="2" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value3" name="field3" type="xsd:string"/>
<xsd:element dfdl:initiator="" dfdl:length="6" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value4" name="field4" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element> |
And here is the exception:
Quote: |
error: CTDP3000E: Unexpected end of data at byte offset '18' while parsing element '#xscd(/schemaElement::EDI852/type::0/model::sequence/schemaElement::record/type::0/model::sequence/schemaElement::field4)'. The parser encountered the end of the data stream or the end of a parent element. |
Only the last one ,71,cannot parse in.
Can anyone can help me figure it out?
Thank you very much. |
Probably because you are saying
Code: |
xsd:element dfdl:length="12"
|
Look at the DFDL trace and work out what is being parsed and what is wrong with it.
Last edited by maurito on Thu Feb 11, 2016 7:57 am; edited 1 time in total |
|
Back to top |
|
 |
CAONIMA |
Posted: Thu Feb 11, 2016 7:56 am Post subject: Re: DFDL Model Error |
|
|
Acolyte
Joined: 03 Dec 2014 Posts: 65
|
Yes, I figured it out, thank you very much |
|
Back to top |
|
 |
CAONIMA |
Posted: Thu Feb 11, 2016 1:12 pm Post subject: Re: DFDL Model Error |
|
|
Acolyte
Joined: 03 Dec 2014 Posts: 65
|
I have one more question,
All the lines are well formatted fix length except the last line, it is different format than the lines above?
How can I set the DFDL to do that?
Many thanks! |
|
Back to top |
|
 |
kimbert |
Posted: Thu Feb 11, 2016 3:25 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
We cannot advise you unless you tell us *how* the last line is different from the others. The phrase 'it is different format than the lines above' does not tell us very much. _________________ 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 |
|
 |
maurito |
Posted: Fri Feb 12, 2016 12:40 am Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
Maybe define an unbounded array for the first n records, and then the different last one ?. |
|
Back to top |
|
 |
CAONIMA |
Posted: Fri Feb 12, 2016 6:04 am Post subject: |
|
|
Acolyte
Joined: 03 Dec 2014 Posts: 65
|
Thank you for your reply.
The last line is like:
Quote: |
CAOCA1 11 51 71
CAOCA2 12 52 72
CAOCA3 13 53 73
HOO1 234 90 |
|
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Feb 12, 2016 6:08 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
So you need to account for it in the DFDL model, set it up with a discriminator and make sure the model will match the data.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
maurito |
Posted: Fri Feb 12, 2016 6:13 am Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
fjb_saper wrote: |
So you need to account for it in the DFDL model, set it up with a discriminator and make sure the model will match the data.
Have fun  |
Don't even need a discriminator. Set up an unbounded array for the first 'n' records, and then a record for the last one. When the last record is hit, then DFDL will know it is not one of the array, so will try to parse it with the next definition in the model. This will work because the last record is different to all the previous. If it had the same structure then yes, a discriminator or another way of working out the difference will be needed , maybe an initiator |
|
Back to top |
|
 |
CAONIMA |
Posted: Fri Feb 12, 2016 6:52 am Post subject: |
|
|
Acolyte
Joined: 03 Dec 2014 Posts: 65
|
maurito wrote: |
fjb_saper wrote: |
So you need to account for it in the DFDL model, set it up with a discriminator and make sure the model will match the data.
Have fun  |
Don't even need a discriminator. Set up an unbounded array for the first 'n' records, and then a record for the last one. When the last record is hit, then DFDL will know it is not one of the array, so will try to parse it with the next definition in the model. This will work because the last record is different to all the previous. If it had the same structure then yes, a discriminator or another way of working out the difference will be needed , maybe an initiator |
Thank you for your reply.
I have already set it as unbounded. And set the initiator, but it said DFDL cannot find the initiator. |
|
Back to top |
|
 |
timber |
Posted: Fri Feb 12, 2016 6:53 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
@CAONIMA: maurito is correct. You will need to add another element, after 'record'. Call it 'trailer' and describe it accurately using DFDL properties.
As maurito says, you should not require a discriminator. The DFDL parser *should* try to parse the trailer line as a 'record', fail, back out and parse it as a 'trailer' instead.
Next steps:
- adjust the model
- Test using the DFDL test perspective
- Read the DFDL Trace and check that everything you see matches what you expect.
- Test the edge cases.
You are using dfdl:initiator="%WSP*;" to consume the space(s) between the elements on each line. Two questions on that:
- Can you get more than one space between the elements?
If so, then it is not a fixed-length format. If not, then you should change the value to "%SP;" ( a single space )
- Did you consider modelling the space(s) as an infix separator on the sequence group? That would be the normal approach to this type of data format. |
|
Back to top |
|
 |
CAONIMA |
Posted: Fri Feb 12, 2016 7:29 am Post subject: |
|
|
Acolyte
Joined: 03 Dec 2014 Posts: 65
|
Thank you for your reply.
Now it has the exception said;
Quote: |
fatal: CTDP3058E: Separator '%CR;%LF;' not found at offset '93528' for sequence or choice within element '/EDI852[1]'. |
My XSD is :
Code: |
<xsd:complexType>
<xsd:sequence dfdl:initiatedContent="no" dfdl:initiator="" dfdl:separator="%CR;%LF;" dfdl:sequenceKind="ordered">
<xsd:element dfdl:initiator="" dfdl:lengthKind="implicit" dfdl:terminator="" maxOccurs="unbounded" name="record">
<xsd:complexType>
<xsd:sequence dfdl:initiatedContent="no" dfdl:initiator="" dfdl:separator="%CR;%LF;" dfdl:sequenceKind="ordered">
<xsd:element dfdl:lengthKind="implicit" dfdl:occursCountKind="implicit" dfdl:terminator="%CR;%LF;%WSP*;" maxOccurs="unbounded" name="record">
<xsd:complexType>
<xsd:sequence dfdl:separator="" dfdl:separatorSuppressionPolicy="never">
<xsd:element dfdl:initiator="" dfdl:length="6" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value1" name="field1" type="xsd:string"/>
<xsd:element dfdl:initiator="%WSP*;" dfdl:length="2" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value2" name="field2" type="xsd:string"/>
<xsd:element dfdl:initiator="%WSP*;" dfdl:length="2" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value3" name="field3" type="xsd:string"/>
<xsd:element dfdl:initiator="" dfdl:length="6" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value4" name="field4" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element dfdl:initiator="H" dfdl:length="11" dfdl:lengthKind="explicit" maxOccurs="unbounded" name="trailer"> <xsd:element dfdl:initiator="R" dfdl:length="425" dfdl:lengthKind="explicit" maxOccurs="unbounded" name="trailer">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="425"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence> |
Thank you for all your kindly reply |
|
Back to top |
|
 |
maurito |
Posted: Fri Feb 12, 2016 7:33 am Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
CAONIMA wrote: |
Thank you for your reply.
Now it has the exception said;
Quote: |
fatal: CTDP3058E: Separator '%CR;%LF;' not found at offset '93528' for sequence or choice within element '/EDI852[1]'. |
My XSD is :
Code: |
<xsd:complexType>
<xsd:sequence dfdl:initiatedContent="no" dfdl:initiator="" dfdl:separator="%CR;%LF;" dfdl:sequenceKind="ordered">
<xsd:element dfdl:initiator="" dfdl:lengthKind="implicit" dfdl:terminator="" maxOccurs="unbounded" name="record">
<xsd:complexType>
<xsd:sequence dfdl:initiatedContent="no" dfdl:initiator="" dfdl:separator="%CR;%LF;" dfdl:sequenceKind="ordered">
<xsd:element dfdl:lengthKind="implicit" dfdl:occursCountKind="implicit" dfdl:terminator="%CR;%LF;%WSP*;" maxOccurs="unbounded" name="record">
<xsd:complexType>
<xsd:sequence dfdl:separator="" dfdl:separatorSuppressionPolicy="never">
<xsd:element dfdl:initiator="" dfdl:length="6" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value1" name="field1" type="xsd:string"/>
<xsd:element dfdl:initiator="%WSP*;" dfdl:length="2" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value2" name="field2" type="xsd:string"/>
<xsd:element dfdl:initiator="%WSP*;" dfdl:length="2" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value3" name="field3" type="xsd:string"/>
<xsd:element dfdl:initiator="" dfdl:length="6" dfdl:lengthKind="explicit" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="value4" name="field4" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element dfdl:initiator="H" dfdl:length="11" dfdl:lengthKind="explicit" maxOccurs="unbounded" name="trailer"> <xsd:element dfdl:initiator="R" dfdl:length="425" dfdl:lengthKind="explicit" maxOccurs="unbounded" name="trailer">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="425"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence> |
Thank you for all your kindly reply |
and why have you set up %CR;%LF; as separator ?..
The message is clear, cannot find a separator with that configuration, and you do not have one in your input data.
I think it is time for you to start following timber's advice, debug it for yourself rather that ask every time you find a problem. You can use the trace to see what is happening. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Feb 12, 2016 7:57 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
maurito wrote: |
You can use the trace to see what is happening. |
Or the DFDL tester. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
CAONIMA |
Posted: Fri Feb 12, 2016 8:49 am Post subject: |
|
|
Acolyte
Joined: 03 Dec 2014 Posts: 65
|
Thank you for all your reply,
This is already figure out. |
|
Back to top |
|
 |
|