Author |
Message
|
rahulk01 |
Posted: Fri Sep 18, 2020 4:19 am Post subject: Issue while escaping special character in DFDL parser |
|
|
Apprentice
Joined: 26 Dec 2019 Posts: 35
|
Hi,
I have a requirement where I am trying to set % in a text field, something like below:
SET rBelopRecord.RESERVASJONNR = 'O' || '%';
But after being validated by the DFDL parser in the output message, it appears as "O%.
How do I make this " go away from the output message being generated. |
|
Back to top |
|
 |
rahulk01 |
Posted: Fri Sep 18, 2020 4:33 am Post subject: |
|
|
Apprentice
Joined: 26 Dec 2019 Posts: 35
|
So far I have tried escaping % in the following manner:
'%%'
'"%'
'"%"'
but nothing seems to work, everytime it just adds " before the entire text |
|
Back to top |
|
 |
rahulk01 |
Posted: Fri Sep 18, 2020 5:38 am Post subject: |
|
|
Apprentice
Joined: 26 Dec 2019 Posts: 35
|
providing more information:
the escape scheme in my DFDL definition is as below:
<dfdl:defineEscapeScheme name="RecordEscapeScheme">
<dfdl:escapeScheme escapeKind="escapeBlock" escapeBlockStart='"' escapeBlockEnd='"' escapeCharacter='"'
escapeEscapeCharacter='"' extraEscapedCharacters='%#x0D; %#x0A;' generateEscapeBlock="whenNeeded"></dfdl:escapeScheme>
</dfdl:defineEscapeScheme>
I even tried setting the escapeKind to escapeCharacter and used the esql statement:
SET rBelopRecord.IDENTIFIER9 = 'O' || '"%'; and in another occasion as
SET rBelopRecord.IDENTIFIER9 = 'O' || '""%';
but none worked |
|
Back to top |
|
 |
timber |
Posted: Fri Sep 18, 2020 2:04 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Thanks for the clear problem description - we appreciate it when people tell us what they have already tried. It saves our time as well as yours.
I can definitely help you with this, but first I will need the following information:
- what type of data format are you trying to write? ( you have only quoted the escape scheme, so I know nothing at all about the rest of the DFDL schema)
- You said that the output appears as "O%. Surely you mean "O%" because escapeKind is set to 'escapeBlock' which will start and end the entire field value with the escape character.
- Do you have any need for escaping at all? If so, what are the requirements for escaping of delimiters? |
|
Back to top |
|
 |
rahulk01 |
Posted: Sun Sep 20, 2020 9:43 pm Post subject: |
|
|
Apprentice
Joined: 26 Dec 2019 Posts: 35
|
timber wrote: |
Thanks for the clear problem description - we appreciate it when people tell us what they have already tried. It saves our time as well as yours.
I can definitely help you with this, but first I will need the following information:
- what type of data format are you trying to write? ( you have only quoted the escape scheme, so I know nothing at all about the rest of the DFDL schema)
- You said that the output appears as "O%. Surely you mean "O%" because escapeKind is set to 'escapeBlock' which will start and end the entire field value with the escape character.
- Do you have any need for escaping at all? If so, what are the requirements for escaping of delimiters? |
I see your point here. The escape schemes were set be default when I created the DFDL parser, so I did not touch them.
I have created a DFDL parser to send feed to a mainframe application (whose copybook we never got). This application uses % and * as their field separators, so I needed my DFDL parser to understand % and * as just literals, so escaping their special meaning was required.
I tried removing the entire escapeScheme and that has solved my problem.
You are correct, I do not need escaping at all, so have removed them. |
|
Back to top |
|
 |
timber |
Posted: Mon Sep 21, 2020 3:18 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
This application uses % and * as their field separators |
Are these fields variable-length? If so, please pick one of the following options:
a) the characters % and * can never, ever appear in the value of any of these fields.
b) there is a chance that % and * might appear in at least one of these fields, sometimes. |
|
Back to top |
|
 |
rahulk01 |
Posted: Mon Sep 21, 2020 3:23 am Post subject: |
|
|
Apprentice
Joined: 26 Dec 2019 Posts: 35
|
timber wrote: |
Quote: |
This application uses % and * as their field separators |
Are these fields variable-length? If so, please pick one of the following options:
a) the characters % and * can never, ever appear in the value of any of these fields.
b) there is a chance that % and * might appear in at least one of these fields, sometimes. |
Option b is valid in this scenario. |
|
Back to top |
|
 |
timber |
Posted: Mon Sep 21, 2020 5:34 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
If the delimiters can appear within the data then you definitely do require an escape scheme. Your current solution is not safe. It only appears to work correctly because your are not testing with data values that include % and *.
You cannot just invent an escape scheme, though. You will need to speak to the team that owns the mainframe application. The mainframe app will probably be expecting a particular escape character to be used. When they have answered that question, you can set up a custom escape scheme as described here:
https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/df00110_.htm
Probably, you will need to set escapeKind='escapeCharacter', not 'escapeBlock' |
|
Back to top |
|
 |
rahulk01 |
Posted: Mon Sep 21, 2020 5:50 am Post subject: |
|
|
Apprentice
Joined: 26 Dec 2019 Posts: 35
|
timber wrote: |
If the delimiters can appear within the data then you definitely do require an escape scheme. Your current solution is not safe. It only appears to work correctly because your are not testing with data values that include % and *.
You cannot just invent an escape scheme, though. You will need to speak to the team that owns the mainframe application. The mainframe app will probably be expecting a particular escape character to be used. When they have answered that question, you can set up a custom escape scheme as described here:
https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/df00110_.htm
Probably, you will need to set escapeKind='escapeCharacter', not 'escapeBlock' |
Well what has been done so far is, the delimiter is defined at each element level in the DFDL. % is not going to come as a part of the data (confirmed). * can be a part of the data, but thankfully only in those elements whose delimiter is not * (but rather %).
So I guess, removing the escape scheme should be a safe option. |
|
Back to top |
|
 |
timber |
Posted: Mon Sep 21, 2020 7:03 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
So I guess, removing the escape scheme should be a safe option |
Thanks for clarifying - I agree with that. |
|
Back to top |
|
 |
|