Author |
Message
|
harry123 |
Posted: Mon Feb 18, 2013 11:38 am Post subject: Customize delimiter in message model |
|
|
Newbie
Joined: 30 Oct 2012 Posts: 9
|
Hi
I have modeled a CSV message using DFDL parser in WMB V8. The message looks as:
BASIC|359656||0250157841|10182012
Now I need to create another message model with 2 different delimiters.
sample message as this:
BASIC=359656||0250157841|10182012
where '=' is a delimiter for first element and for all rest of the elements, the delimiter is '|'.
In message model, I see that we set the separator property to a default value (like ',' '|') for all the elements one time in the sequence properties.
Is there any way we could set the separator individually for each element.
Thanks,
Harry |
|
Back to top |
|
 |
kimbert |
Posted: Mon Feb 18, 2013 1:12 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
'=' is a delimiter for first element |
I wonder...is it really a delimiter. Or is 'BASIC=' an initiator for the whole record?
Quote: |
Is there any way we could set the separator individually for each element |
There is. But I don't think you need that. it looks as if most of the elements are using |. It is only the first element that has 'BASIC=' before it. And that could be modelled as an initiator.
If you really do need a different separator for each element then you can set either the initiator or the terminator property on each element. |
|
Back to top |
|
 |
harry123 |
Posted: Mon Feb 18, 2013 2:23 pm Post subject: |
|
|
Newbie
Joined: 30 Oct 2012 Posts: 9
|
Hi Kimbert,
BASIC= is not an initiator for my whole record.
BASIC is the value of my first element and = is the delimiter for that element.
When I set the terminator property of my first element to '=' , the parsing was unsuccessful with the following error.
Separator is missing for 'sequence' group contained within element 'BASIC'. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Feb 18, 2013 3:06 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Here's what is happening:
1. the DFDL parser successfully parses the first element, and assigns the value 'BASIC' to it
2. The terminator '=' for the first element is also found successfully.
3. The sequence group that contains the first element ( and all the others ) has a separator of |. So the next thing that the parser expects is a separator. It doesn't find a | in the data, so it complains.
I assume that you have seen all of this in the DFDL Trace view in the WMB toolkit?
Your model currently looks like this:
Code: |
Root
Complex Type
Sequence Group separator='|'
element1 terminator='='
element2
...
elementN |
You need to change it to look like this:
Code: |
Root
Complex Type
Sequence Group separator='' ( i.e. no separator )
element1 terminator='='
Sequence Group separator='|'
element2
...
elementN |
Alternatively, remove the terminator on element 1 and set the separator for its parent sequence group to '='. Your choice. |
|
Back to top |
|
 |
harry123 |
Posted: Mon Feb 18, 2013 3:14 pm Post subject: |
|
|
Newbie
Joined: 30 Oct 2012 Posts: 9
|
Thank you Kimbert. That really helps. |
|
Back to top |
|
 |
|