Author |
Message
|
mqsid |
Posted: Wed May 16, 2007 7:38 am Post subject: difference for tag with no value and no tag at all--XMLNSC |
|
|
Newbie
Joined: 26 Jan 2007 Posts: 5
|
I am having trouble differentiating empty value for the tag and having no tag at all in the input XML.
I tried using,
IF InputRoot.XMLNSC.X:Message.Y:Payload.Y:abc IS NULL THEN
SET xyz = 'xyz';
ELSEIF InputRoot.XMLNSC.X:Message.Y:Payload.Y:abc = '' THEN
SET xyz = 'abc';
END IF;
But the first condition is becoming true for both no tag and tag with empty value.
How can I differentiate these two scenarios?
Any thoughts would be appreciated. |
|
Back to top |
|
 |
Vitor |
Posted: Wed May 16, 2007 8:01 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
I think if you use XMLNS rather than XMLNSC it will leave the whitespace in for you.
I'd be interested to know if I'm right.....  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqsid |
Posted: Wed May 16, 2007 9:01 am Post subject: |
|
|
Newbie
Joined: 26 Jan 2007 Posts: 5
|
It works fine with XMLNS. The condition specified in my previous post does the job.
But why is it not working with XMLNSC?
Is this some kind of bug or do you think there is an alter way of doin so with XMLNSC? |
|
Back to top |
|
 |
jbanoop |
Posted: Wed May 16, 2007 10:43 am Post subject: |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
try using CARDINALITY(). If cardinality is 0 that means tag does not exist in the message. |
|
Back to top |
|
 |
Vitor |
Posted: Wed May 16, 2007 11:52 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqsid wrote: |
It works fine with XMLNS. The condition specified in my previous post does the job.
But why is it not working with XMLNSC?
|
The compact parser (which why it's a C) removes whitespace. So when you test for "" it's not there. Bug, feature - who can say? _________________ Honesty is the best policy.
Insanity is the best defence.
Last edited by Vitor on Wed May 16, 2007 11:57 am; edited 1 time in total |
|
Back to top |
|
 |
kimbert |
Posted: Wed May 16, 2007 11:54 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
It's a defect. And it will be fixed - IBM is well aware that this distinction is an important one for many users. For now, I suggest that you get it working using CARDINALITY but put a TODO comment next to the code stating that it's a temporary workaround. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 16, 2007 11:55 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I'd use FIELDNAME instead of Cardinality. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mqsid |
Posted: Wed May 16, 2007 1:07 pm Post subject: |
|
|
Newbie
Joined: 26 Jan 2007 Posts: 5
|
Thank you for all ur assitance. I am going with CARDINALITY as of now. |
|
Back to top |
|
 |
|