Author |
Message
|
WBI_user |
Posted: Thu Oct 11, 2001 6:23 pm Post subject: |
|
|
Partisan
Joined: 07 Aug 2001 Posts: 386
|
I need to find out what is the value in MQSI
for an empty XML field. I cretaed a simple XML message
<TEST><DATA1>12</DATA1><DATA2></DATA2></test>
and a MRM definition
'testmsg' with 2 elements DATA1 and DATA2
In the compute node I have
SET OutputRoot.MRM.DATA1=InputRoot.XML.TEST.DATA1
SET OutputRoot.MRM.DATA2=InputRoot.XML.TEST.DATA2
I got an error saying unexpected NULL encountered for DATA2 filed and I think this is expected.
So I add an IF statement
IF InputRoot.XML.TEST.DATA2 is NULL THEN
SET OutputRoot.MRM.DATA2 = ' ';
But I got the same error. I ran the trace. The trace said that the statement
IF InputRoot.XML.TEST.DATA2 is NULL is evaluated to false.
I am confused.
Can some one tell me what is the value of an empty XML field (i.e. an XML field with just the begin tag and end tag).
I think it is NULL. But the trace said it is not. What is it ?
I need to find out how I can handle empty XML fields of an incoming XML message. |
|
Back to top |
|
 |
Outdesign |
Posted: Fri Oct 12, 2001 2:59 am Post subject: |
|
|
Apprentice
Joined: 16 Sep 2001 Posts: 38 Location: Hampshire, UK
|
In MQSI 'NULL' has multiple meanings ...
In this instance, a path reference to an element that does not exist will return NULL.
In your example the element does exist, but is an empty element.
-- Check if an element does not exist
IF InputRoot.XML.TEST.DATA2 IS NULL THEN
...
-- Check if an element is empty
-- Note, this is two single quotes with no space inbetween
IF InputRoot.XML.TEST.DATA2 = '' THEN
...
|
|
Back to top |
|
 |
kwelch |
Posted: Sat Oct 13, 2001 7:33 am Post subject: |
|
|
 Master
Joined: 16 May 2001 Posts: 255
|
Thanks Kelvin and Outdesign! This is the answer that I was looking for in my prior post. I just want to clarify something though. Is <DATA2></DATA2> the same as <DATA2/> ? This is where you would check for = '' ? and if no DATA2 tags are present, the NULL check would be true?
Thanks for any clarification on this.
Karen |
|
Back to top |
|
 |
Outdesign |
Posted: Mon Oct 15, 2001 8:58 am Post subject: |
|
|
Apprentice
Joined: 16 Sep 2001 Posts: 38 Location: Hampshire, UK
|
Karen,
There are two forms of notation to represent an element which has no content
<empty></empty> and <empty/>
Hence, <DATA2></DATA2> and <DATA2/> are exactly the same.
And yes, you are correct about the empty element and non exist element checking.
[ This Message was edited by: Outdesign on 2001-10-15 09:59 ] |
|
Back to top |
|
 |
kwelch |
Posted: Mon Oct 15, 2001 9:53 am Post subject: |
|
|
 Master
Joined: 16 May 2001 Posts: 255
|
Outdesign,
Thank you for the clarification!
Where is this information documented? I searched in the MQSI docs I have and didn't find much.
Karen
|
|
Back to top |
|
 |
Outdesign |
Posted: Tue Oct 16, 2001 2:37 am Post subject: |
|
|
Apprentice
Joined: 16 Sep 2001 Posts: 38 Location: Hampshire, UK
|
Karen,
This is an XML concept and *not* specific to MQSI.
I am not aware if this is explicitly documented in the MQSI manuals.
My reference sources were :
(1)
W3C Extensible Markup Language (XML) 1.0 (Second Edition) specification
http://www.w3.org/TR/2000/REC-xml-20001006#sec-starttags
(2)
The XML Companion, Second Edition by Neil Bradley,
Publisher Addison-Wesley, ISBN 0201674866
And I have used it successfully in my messageflows
|
|
Back to top |
|
 |
kwelch |
Posted: Tue Oct 23, 2001 9:58 am Post subject: |
|
|
 Master
Joined: 16 May 2001 Posts: 255
|
Thanks. I will check out those references.
Karen |
|
Back to top |
|
 |
|