Author |
Message
|
547c547 |
Posted: Wed Aug 26, 2015 4:33 am Post subject: DFDL delimited message |
|
|
 Acolyte
Joined: 16 Jun 2014 Posts: 51
|
Is that possible to have optional values in delimited message .
for example:
JOHN 2 M
MARIE 22 F HR
MADDY 65 M BP
First name : firstname -- JOHN -- MARIE -- MADDY
AGE : age -- 2 -- 22 -- 65
GENDER : gender code -- M -- F -- M
JOB : optional -- HR
Health : optional -- BP
Can I parse this way? Please suggest.. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 26, 2015 4:46 am Post subject: Re: DFDL delimited message |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
547c547 wrote: |
Is that possible to have optional values in delimited message . |
547c547 wrote: |
Please suggest.. |
I suggest you build a DFDL model that describes this.
Perhaps if you gave a few more details on what led you to this question? With specific reference to any DFDL models which failed to parse such a message and that led you to ask the question? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
547c547 |
Posted: Wed Aug 26, 2015 10:38 pm Post subject: Re: DFDL delimited message |
|
|
 Acolyte
Joined: 16 Jun 2014 Posts: 51
|
Vitor wrote: |
547c547 wrote: |
Is that possible to have optional values in delimited message . |
547c547 wrote: |
Please suggest.. |
I suggest you build a DFDL model that describes this.
Perhaps if you gave a few more details on what led you to this question? With specific reference to any DFDL models which failed to parse such a message and that led you to ask the question? |
I am trying to create generic dfdl for different input messages.. My requirement, I tried using pattern and expression. Could you please help me out with his.. I am stuck with this.. |
|
Back to top |
|
 |
maurito |
Posted: Wed Aug 26, 2015 11:15 pm Post subject: Re: DFDL delimited message |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
547c547 wrote: |
I am trying to create generic dfdl for different input messages.. My requirement, I tried using pattern and expression. Could you please help me out with his.. I am stuck with this.. |
If you are unable to create a simple CSV model using the DFDL editor then you most probably need to talk to your manager/team leader and get some formal education.
People in this forum will help you when you have problems, but they will not do it for you, nor they educate you. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 27, 2015 4:32 am Post subject: Re: DFDL delimited message |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
547c547 wrote: |
I am trying to create generic dfdl for different input messages.. |
I got that from your original post; some messages have all the fields, some don't. It's not that uncommon, nor that hard to model.
547c547 wrote: |
I tried using pattern and expression. |
And if that didn't work, you should probably try something else.
547c547 wrote: |
Could you please help me out with his.. I am stuck with this.. |
Stuck with what?
The example you posted is a very simple model and you could probably adapt one of the patterns to parse it. Seriously. There's nothing complicated about it and that includes the fact that some of the fields are optional.
I don't understand the problem. So I can't speak to it. Unless the problem is "I can't be asked to work this out", in which case I won't speak to it, but I don't sense that's the problem.
You've got a record. It has 4 fields: name, age, gender, job, health. The last 2 fields are optional. Put tags round that & you've got a DFDL schema.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
timber |
Posted: Thu Aug 27, 2015 12:22 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
I agree with the others - this looks like a fairly standard file format containing delimited lines of text. The CSV wizard would be a good starting point - just change the separator from comma to %SP;.
Don't forget to use the DFDL debugger, and the DFDL Trace. |
|
Back to top |
|
 |
547c547 |
Posted: Sat Aug 29, 2015 8:41 pm Post subject: Re: DFDL delimited message |
|
|
 Acolyte
Joined: 16 Jun 2014 Posts: 51
|
maurito wrote: |
547c547 wrote: |
I am trying to create generic dfdl for different input messages.. My requirement, I tried using pattern and expression. Could you please help me out with his.. I am stuck with this.. |
If you are unable to create a simple CSV model using the DFDL editor then you most probably need to talk to your manager/team leader and get some formal education.
People in this forum will help you when you have problems, but they will not do it for you, nor they educate you. |
Thank you so much for your suggestion.. I didnt try or asked you to educate or do it for me.. I just wanted to know if that is possible or not..
I read in info center that we can miss few element in delimited message.
I tried to do that.. Which is not possible.. I know it is possible only in case
JOHN M HR
MARIE HR(two spacess)
I asked if that is possible without two spacess.....
Anyhow.. Thanks for your try..I appreciate that |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Aug 31, 2015 4:33 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
DFDL is capable of processing lots of messages.
It does, however, need to know what fields to find and where or how they stop.
There's nothing in DFDL that says "I can't use two spaces".
If your over all records are ended with line feeds, then you can use those as delimiters. If you have a certain value at the front of each record, ideally one that tells you what type of record it is, then you can use those as initiators.
If your fields are fixed width, then you can use that to tell DFDL where each field stops. If your records are variable length, then you either need to have each field have a different type from the one before and after it (string,int, then string for example), or you need something that says "this is the end of one field" or "this is the start of one field". These are separators or indicators.
You can create fields that are optional. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
Vitor |
Posted: Mon Aug 31, 2015 4:58 am Post subject: Re: DFDL delimited message |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
547c547 wrote: |
I read in info center that we can miss few element in delimited message.
I tried to do that.. Which is not possible.. I know it is possible only in case
JOHN M HR
MARIE HR(two spacess)
I asked if that is possible without two spacess..... |
I didn't understand any of that.
I don't understand why that very simple format couldn't be parsed in DFDL.
I don't understand what difference having one or two spaces makes to anything.
 _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
timber |
Posted: Mon Aug 31, 2015 12:02 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
OK - this needs more careful attention. Here is the original question:
Quote: |
Is that possible to have optional values in delimited message .
for example:
JOHN 2 M
MARIE 22 F HR
MADDY 65 M BP |
The answer is 'yes and no'.
Your records have *two* optional, trailing fields. Job and Health ( in that order ). This line is OK:
...because you have omitted the final field on the line only.
This is not OK:
...because the Health field appears in the position where the Job field should be.
The DFDL parser *can* parse a format like this - but you will need to tell the DFDL parser how to reliably recognise a Job field. Then, if the Health field occurs as the 4th field the DFDL parser can tell that it is not a Job field and re-parse it as a Health field.
In your second post, you said 'I tried using pattern and expression'. That sounds like it could work...but you did not give *any* details about what you tried, or what happened.
Next step:
- Please post a DFDL trace showing what happens when you try to parse 'MADDY 65 M BP'. For bonus points, post your DFDL schema as well. |
|
Back to top |
|
 |
|