Posted: Wed Mar 16, 2011 9:10 am Post subject: Element existence check, followed by empty value test
Acolyte
Joined: 07 Oct 2005 Posts: 74 Location: England
A general query. Based on an XSD we have some optional elements in the XML(NSC) tree, surprise surprise.
We want to execute path A if the element either does not exist or has a null/ empty string value, or execute path B otherwise. So path A if element does not exist in incoming tree or does exist but is empty. Path B only if element exists and has a non-zero length value.
In ESQL I would use IF EXISTS syntax to confirm that the element exists and then check the element value for the empty string (""). A colleague is using the IF element IS NOT NULL syntax which seems to do both the check for existence and also for null/ empty string value. This is during a debug session, so the debug may be doing something additional. Either way, what approach do you use in this case?
Using broker toolkit and runtime 6.1.4 on windows XP.
Those are three separate conditions, and your code should check for them separately.
- IF EXISTS to see whether the field is in the message tree
- IS NULL / IS NOT NULL to check whether it has an explicit null value
( for XMLNSC this is only possible if xsi:nil=true in the xsd )
- FIELDVALUE(fieldref)="" to check whether the field is the empty string.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum