Author |
Message
|
jkh |
Posted: Wed Oct 09, 2013 7:09 am Post subject: Remove fields with value null from a tree |
|
|
Newbie
Joined: 09 Oct 2013 Posts: 5
|
Hi,
I have a challenge with a cobol message that should be mapped to XML.
Empty fields in the cobol message are translated to NULL value in the message tree by the CWF parser. I do not want to have these NULL fields in my xml message. How can I remove all fields in the cobol tree with value NULL?
Is there a simple SELECT statement or should I make a procedure going throw each field and investigate if the fiedvalue is NULL or?
Thanks
Jakob |
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Oct 09, 2013 7:29 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Whats the point of removing these fields ? Why do you as the developer care if an LMT element is null ? What impact does a Null element have on your logic ? _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
jkh |
Posted: Wed Oct 09, 2013 10:08 pm Post subject: |
|
|
Newbie
Joined: 09 Oct 2013 Posts: 5
|
The receiver has created a WSDL (and used it for years) where all elements should be longer than 1 and null has length 0. That is why all null elements should be removed.... |
|
Back to top |
|
 |
dogorsy |
Posted: Wed Oct 09, 2013 10:32 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
You don't need to do anything. If you use ESQL for the mapping, assigning a NULL to an element in a XMLNSC tree results in that element being deleted.
Your challenge is not in the input data. You get some input, perform a transformation and get the output. All you need to think about is the transformation from input to output, NOT how to modify the input tree. What I said above about XMLNC is ONE way of doing it, there are many more. It is up to you to work out which one works best for you. |
|
Back to top |
|
 |
jkh |
Posted: Wed Oct 09, 2013 11:53 pm Post subject: |
|
|
Newbie
Joined: 09 Oct 2013 Posts: 5
|
Thanks for the feed back! I am using a mapping node and not ESQL. I have made the mapping and now I either for each field in the mapping node put in a test for null before the mapping or make a smart routine that remove all nulls... |
|
Back to top |
|
 |
kimbert |
Posted: Thu Oct 10, 2013 2:22 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
If you use ESQL for the mapping, assigning a NULL to an element in a XMLNSC tree results in that element being deleted. |
Sometimes. But there are two types of null in ESQL.
1. Delete the field:
SET OutputRoot.XMLNSC.root.record1.field1 = NULL;
2. Set the value of the field to null
SET OutputRoot.XMLNSC.root.record1.field1 VALUE = NULL;
I think the OP is talking about the latter. In which case, there may be some logic required. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Oct 10, 2013 2:27 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Is there a simple SELECT statement or should I make a procedure going throw each field and investigate if the fiedvalue is NULL or? |
It could be done using a JavaCompute node that
- uses XPath to obtain an array of all elements in OutputRoot that have empty string as their value
- walks the array and deletes every such element
Probably could be done using ESQL SELECT. I'm not sufficiently expert to know how. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 10, 2013 5:50 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kimbert wrote: |
Probably could be done using ESQL SELECT. I'm not sufficiently expert to know how. |
Not sufficiently expert? What hell is this? Who are you, and what have you done with the real kimbert?
 _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|