Author |
Message
|
siri2083 |
Posted: Sat May 23, 2009 8:13 pm Post subject: Accessing null values in XMLNSC domain |
|
|
Apprentice
Joined: 16 Apr 2009 Posts: 39
|
Hi,
I am trying to check an element is holding null value or not in XMLNSC domain.
Input message looks like:
<EMP>
<ID>123</ID>
<Name/>
</EMP>
Below is the code:
Set Enviroment.Variables. InputMessage = InputRoot.XMLNSC.EMP;
If Enviroment.Variables. InputMessage.EMP.Name IS NULL THEN
throw user exception;
else do other process;
Now the problem is if name is null, it is working fine. when name is have some sub elements, ex:
<EMP>
<ID>123</ID>
<Name>
<FN>slk</FN>
<LN>rth</LN>
</Name></EMP>
in the above case, Name is not null. But still it is saying that name is null.
Please suggest. |
|
Back to top |
|
 |
Vitor |
Posted: Sun May 24, 2009 1:18 am Post subject: Re: Accessing null values in XMLNSC domain |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
siri2083 wrote: |
Please suggest. |
You could try something like:
Code: |
DECLARE aRef REFERENCE TO InputRoot.XMLNSC.EMP.Name;
MOVE aRef FIRSTCHILD;
IF LASTMOVE(aRef) THEN
...
ELSE
....
END IF; |
Only a suggestion, not tested in any way, coded entirely from memory, other solutions are undoubtably possible, no warrenty express or implied accepted, etc, etc. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Sun May 24, 2009 4:38 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
So you want to find out if the Name element, regardless of what value it has, has any children? |
|
Back to top |
|
 |
MQEnthu |
Posted: Sun May 24, 2009 9:11 pm Post subject: |
|
|
 Partisan
Joined: 06 Oct 2008 Posts: 329 Location: India
|
You want to find out if the Name has value or not ?Or check if it has children FN and LN .. If this is the case, then Try the code snippet posted below in Vitors reply...
Vitor wrote: |
You could try something like:
Code: |
DECLARE aRef REFERENCE TO InputRoot.XMLNSC.EMP.Name;
MOVE aRef FIRSTCHILD;
IF LASTMOVE(aRef) THEN
...
ELSE
....
END IF; |
|
_________________ -----------------------------------------------
It is good to remember the past,
but don't let past capture your future |
|
Back to top |
|
 |
siri2083 |
Posted: Sun May 24, 2009 9:12 pm Post subject: |
|
|
Apprentice
Joined: 16 Apr 2009 Posts: 39
|
Hi mqjeff,
Yes, i want to check Name element is null or not regardless of its child elements and its value.
 |
|
Back to top |
|
 |
MQEnthu |
Posted: Sun May 24, 2009 9:17 pm Post subject: |
|
|
 Partisan
Joined: 06 Oct 2008 Posts: 329 Location: India
|
siri2083 wrote: |
Yes, i want to check Name element is null or not regardless of its child elements and its value. |
Will there be any chances you will get the element name populated, e.g: <Name>xyz</Name>.. or always it will have FN and LN as its child elements when ever name is filled..
Check the schema, how does it look like... _________________ -----------------------------------------------
It is good to remember the past,
but don't let past capture your future |
|
Back to top |
|
 |
siri2083 |
Posted: Sun May 24, 2009 9:28 pm Post subject: |
|
|
Apprentice
Joined: 16 Apr 2009 Posts: 39
|
Hi MQEnthu,
As Name element is of complex type. it will have child elements .
please suggest. |
|
Back to top |
|
 |
MQEnthu |
Posted: Sun May 24, 2009 9:44 pm Post subject: |
|
|
 Partisan
Joined: 06 Oct 2008 Posts: 329 Location: India
|
siri2083 wrote: |
As Name element is of complex type. it will have child elements .
please suggest. |
Try this:
Vitor wrote: |
Code: |
DECLARE aRef REFERENCE TO InputRoot.XMLNSC.EMP.Name;
MOVE aRef FIRSTCHILD;
IF LASTMOVE(aRef) THEN
...
ELSE
....
END IF; |
|
Try and let us know if you face any problem _________________ -----------------------------------------------
It is good to remember the past,
but don't let past capture your future |
|
Back to top |
|
 |
siri2083 |
Posted: Sun May 24, 2009 11:11 pm Post subject: |
|
|
Apprentice
Joined: 16 Apr 2009 Posts: 39
|
Hi All,
Its working fine with above code.
Thank you.
 |
|
Back to top |
|
 |
|