Author |
Message
|
IIB_Intel |
Posted: Fri Jul 07, 2017 4:23 am Post subject: Removing empty tags from XML using DFDL |
|
|
Acolyte
Joined: 07 May 2015 Posts: 64
|
My input message is a fixed length message and I am using DFDL parser to parse and validate it.
Then I am converting/Serializing into an XML. Few fields in the input can have value as blank spaces, dfdl, on xml conversion is creating empty xml tags for those fields.
Is there any setting in the dfdl schema that I can use on these fields so that if the value of a field in the input is blank spaces it doesn't create empty tag in xml? |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jul 07, 2017 4:27 am Post subject: Re: Removing empty tags from XML using DFDL |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
IIB_Intel wrote: |
My input message is a fixed length message and I am using DFDL parser to parse and validate it.
Then I am converting/Serializing into an XML. Few fields in the input can be blank space, dfdl, on xml conversion is creating empty xml tags for those fields.
Is there any setting in the dfdl schema that I can use on these fields so that if the value of a fields in the input is blank spaces it doesn't create empty tag in xml? |
You do not specify whether the field is optional or nillable in XML. So there is no straight answer. Once you have figured this out you can look at your DFDL definition for null values for the field in question, and handle the XML accordingly...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
IIB_Intel |
Posted: Fri Jul 07, 2017 4:41 am Post subject: |
|
|
Acolyte
Joined: 07 May 2015 Posts: 64
|
I tried by specifying few fields as option in DFDL schema and trying various combination of null & nillable values but it still creates those empty xml tags. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jul 07, 2017 4:48 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
If you're trying to change the XML output, then you need to change the XML model... (xsd) _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
IIB_Intel |
Posted: Fri Jul 07, 2017 6:20 am Post subject: |
|
|
Acolyte
Joined: 07 May 2015 Posts: 64
|
There is just one dfdl model being used. First I use that to parse incoming fixed length then convert it to xml.
Are you saying I need to create 2 message schema and do mapping between them? |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jul 07, 2017 6:35 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You need to model both your input message and your output message.
If one is DFDL and one is XML, then you need separate models.
ss _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
IIB_Intel |
Posted: Fri Jul 07, 2017 11:26 am Post subject: |
|
|
Acolyte
Joined: 07 May 2015 Posts: 64
|
And of-course I would need mapping between two models? |
|
Back to top |
|
 |
timber |
Posted: Sun Jul 09, 2017 2:55 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
Is there any setting in the dfdl schema that I can use on these fields so that if the value of a field in the input is blank spaces it doesn't create empty tag in xml? |
No, but I don't blame you for asking.
If the length of an element in the input bitstream is non-zero then it *will* appear in the message tree. You can control whether DFDL parses it as a normal (logical) value or as a NULL value. This is by design, btw. DFDL is a parsing technology, not a mapping technology. Including this feature would have blurred that line. |
|
Back to top |
|
 |
mbsa |
Posted: Mon Jul 10, 2017 8:59 am Post subject: |
|
|
Apprentice
Joined: 04 Mar 2013 Posts: 41
|
I had the requirement of removing empty tags in the xml. I used COALESCE function which default NULL while mapping optional fields to get rid of empty tags. |
|
Back to top |
|
 |
IIB_Intel |
Posted: Tue Jul 11, 2017 5:17 am Post subject: |
|
|
Acolyte
Joined: 07 May 2015 Posts: 64
|
I can parse a fixed length message with dfdl parse and easily convert it to xml (ofcourse xml will have empty strings).
I am thinking of writing a generic esql method to remove all empty tags instead of doing a 2nd mapping. |
|
Back to top |
|
 |
|