Author |
Message
|
Bichu |
Posted: Wed Sep 20, 2017 5:15 am Post subject: Help required on DFDL parsing issue |
|
|
Centurion
Joined: 16 Oct 2011 Posts: 124 Location: London
|
Hi All,
I need to parse a text message whose format is as follows
Code: |
HR|value1|value2|value3|...|value12|
19|data1|data2|data3|.....|data31|
29|val1|val2|val3|val4|val5|
29|val1|val2|val3|val4|val5|
19|data1|data2|data3|.....|data31|
.
29|val1|val2|val3|val4|val5|
.
.
19|data1|data2|data3|.....|data31|
.
TR|val1|val2|val3|...|val6| |
I tried to create a DFDL to parse the above message but getting parsing error. I created a header tag, body tag and under body element19 and element29.
When I tested, i am getting the header and element19 under body but element 29 is not getting cretaed. could some one help me where i'm going wrong?
I have specified the same settings for element29 as for element 19. I have inspected the dfdl trace logs and tried to rectify the error but couldnt proceed anymore.
Is this the correct way to parse these kind of messages when two different kind of rows comes in a messages without any order.
Please help. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Sep 20, 2017 5:42 am Post subject: Re: Help required on DFDL parsing issue |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Bichu wrote: |
I have inspected the dfdl trace logs and tried to rectify the error but couldnt proceed anymore. |
It might help if you shared the actual error? Or is it the situation that the parser is adding all the data to the previous element?
Better information, better advice.
Bichu wrote: |
Is this the correct way to parse these kind of messages when two different kind of rows comes in a messages without any order.
|
Is what the best way? You've really not given a lot of detail here.
If it was me, I'd define a header, a body and a trailer as a sequence with the body repeating in an unbounded way and the body being a choice between a 19 and a 29.
Other parsing schemes are undoubtedly possible and may be better. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Sep 20, 2017 5:48 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
If the data actually matches what you've posted, you could manage with a single element that repeats in a unbounded way defined thus:
Code: |
<record type>|<optional element 1>|<optional element 2>| ... |<optional element 31>|
|
This would parse HRs, 19s, 29s, TRs because the only difference appears to be the number of elements.
I doubt the actual data is that simple. but if it is..... _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
timber |
Posted: Wed Sep 20, 2017 7:04 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Have you looked at the DFDL Trace in the IIB toolkit? What did it tell you? |
|
Back to top |
|
 |
chaitanyauk |
Posted: Sun Oct 15, 2017 8:55 pm Post subject: |
|
|
Apprentice
Joined: 16 Apr 2017 Posts: 30
|
Hi,
In the schema definition of DFDL give min and max occurs of the header as 1. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Oct 16, 2017 3:41 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
chaitanyauk wrote: |
Hi,
In the schema definition of DFDL give min and max occurs of the header as 1. |
That's an interesting thought.
It tells the parser that there's only going to be one HR record in whatever position in the message it finds it.
It doesn't tell the parser that the HR has to be the first record.
Does it provide a means for the model to tell that a 19 has finished and a 29 has started?
Or that there's more than one 19?
Or more than one 29?
And that 29s must stop repeating when there's another 19?
And that 19's and 29's must stop repeating when there's a TR record?
These are the things that the model needs to describe.
Bichu needs to analyze the data to figure out how to construct the model to match the answers.
Vitor has already posted a very standard pattern for modelling this kind of message.
It might not process the message correctly for Bichu's problem. . But that's because it assumes one set of a answers to those questions, and Bichu's problem may need a different set of answers. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
|