Author |
Message
|
[EG]Slayer |
Posted: Wed Apr 13, 2011 7:04 am Post subject: Testing a tag existence with ESQL with XMLNSC |
|
|
Novice
Joined: 01 Aug 2008 Posts: 16
|
Hi,
I've something strange with MessageBroker V7.0.0.2 testing a field existence in an xml message.
<Flow>
<Data>
<Customer>Smith</Customer>
</Data>
</Flow>
With Message Broker V6 using XML parser:
IF(InputRoot.XML.Flow.Data.Customer IS NULL)
THEN
RETURN(TRUE);
ELSE
RETURN(FALSE);
END IF;
--> When testing the result is FALSE
With Message Broker V7.0.0.2 using XMLNSC parser:
IF(InputRoot.XMLNSC.Flow.Data.Customer IS NULL)
THEN
RETURN(TRUE);
ELSE
RETURN(FALSE);
END IF;
--> When testing the result is TRUE
If I use CARDINALITY instead of IS NULL, it works but what's the problem with IS NULL??
Thanks for your help |
|
Back to top |
|
 |
Vitor |
Posted: Wed Apr 13, 2011 7:07 am Post subject: Re: Testing a tag existence with ESQL with XMLNSC |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
[EG]Slayer wrote: |
If I use CARDINALITY instead of IS NULL, it works but what's the problem with IS NULL?? |
If you're used either code sample with the example XML given, I'd have expected neither to test true for NULL as the value appears to be Smith.
In an actual example is the Customer tag actually NULL or is it empty? I suspect the XMLNSC domain is far more rigerous on such matters than the XML domain (which you shouldn't be using in v6) was and is.
(P.S. - next time you post a thread in the wrong forum, just add to it asking for it to be moved. No need to edit & repost. ) _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Apr 13, 2011 7:28 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
And before any IBM'ers get in...
You should not be using the XML Parser for any new development. It has been deprecated for at least two releases now. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
[EG]Slayer |
Posted: Wed Apr 13, 2011 7:49 am Post subject: |
|
|
Novice
Joined: 01 Aug 2008 Posts: 16
|
Yes I know,
That's old flows still existing (developped with message broker 2.1), we want to update them with the xmlnsc parser
For Vitor, here is just a example to explain my problem
It's not the same for us if the tag <Customer> is empty or if there is no tag <Customer> ... |
|
Back to top |
|
 |
Vitor |
Posted: Wed Apr 13, 2011 8:05 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
[EG]Slayer wrote: |
For Vitor, here is just a example to explain my problem
It's not the same for us if the tag <Customer> is empty or if there is no tag <Customer> ... |
I suspected that. I think you'll find the W3C XML specification considers those 2 cases to be different (even if you don't) & the XMLNSC parser respects that.
You'll need code to get round this. One less computationally expensive option that CARDINALITY is LENGTH(FIELDVALUE(Customer)) = 0.
Or for the pedantic LENGTH(TRIM BOTH(FIELDVALUE(Customer))) = 0.
Other possibly better solutions undoubtably exist and may fit your needs in a way these examples (which are offered without warranty & have not even been syntax checked) don't. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Apr 13, 2011 11:11 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
Back to top |
|
 |
rekarm01 |
Posted: Wed Apr 13, 2011 5:02 pm Post subject: Re: Testing a tag existence with ESQL with XMLNSC |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
[EG]Slayer wrote: |
what's the problem with IS NULL?? |
The problem is that "IS NULL?" and "EXISTS?" are two different questions, with two possibly different answers.
Elements do not require non-NULL values in order to exist.
For example, XMLNSC.Folder elements don't have any values at all, and nillable XMLNSC.Field elements can have NULL values.
[EG]Slayer wrote: |
With Message Broker V7.0.0.2 using XMLNSC parser:
...
--> When testing the result is TRUE |
Vitor wrote: |
If you've used either code sample with the example XML given, I'd have expected neither to test true for NULL as the value appears to be 'Smith'. |
Vitor is correct. 'Smith' IS almost always NOT NULL, regardless of parser.
For other suggestions, check here. |
|
Back to top |
|
 |
|