Focal Point
Xpath check

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/8097063906

September 06, 2011, 01:13 PM
Gopal_mys
Xpath check
Hi,

I am using iWay ISM 5.5,

I am trying to work out a condition which checks for presence of particular field in the transformer and maps it to the output.

root
child1 ABC /child1
child2 ABC /child2
/root

I am trying to use a IF condition like /root/child1 does have a value use that, else use /root/child2.

The IF condition works fine if the file contains /child1 under root,no matter the field is empty are not.

One such file contains

root
child2 ABC /child2
/root

Here lies the problem I am not getting the value of child2 as the child1 is not present.

Also i tried to using @Exists to check if child1 does exists use that, else child2, not working.

If the file doesn't contain child1 under root, I am not getting the value of child2

Please let me know if there is some way to get child2 value if the file doesnot contain child1

Syntax of the xml file i am using is correct, Above one is just a example.


iWay ISM 5.5/iWay ISM 6.0 on Windows.
September 07, 2011, 07:26 AM
AdeH
Hi,
Can you use [CODE] tags around the XML in your post for clarity...

What conditional operator are you using in the IF statement in the first example that is working? '=' ? '!=' ? '=='?


iWay 5.5 SMSP1 and 6.0.1 on Intel/Linux
September 07, 2011, 09:08 AM
Gopal_mys
Hi AdeH,
I am using iWay ISM 5.5(Transformer) on Windows 2003 server.

This is the original file,

<root>

<child1>ABC</child1>

<child2>123</child2>

</root>


Mapping condition is "If the string lenth of the expression root/child1 is != zero,then take the value root/child1, else take the value from root/child2".

This works fine is the file is of type above.
meaning I am getting the value ABC from the above IF condition.

But when the file is like this
<root>

<child2>123</child2>

</root>


that is without the child1 element,

The If condition resolves to false and it should take value from child2,this is not happening.

So I even tried the @Exists on child1 instead of string length check on child1, but I am not getting the value of child2.


iWay ISM 5.5/iWay ISM 6.0 on Windows.
September 07, 2011, 09:28 AM
Igor Y
I've noticed, that sometimes the transform functions do not work as they are supposed to in the mappings.

Create two elements,map one to child1 and second to child2, encapsulate them with invisible groups and set filters to show child1 group, if child1 exists( use @EXISTS function) and hide the child2 group, if child1 exists.


iWay Service Manager (6.0.1 - patch.62627)
DMC Version 7 Release 7
September 21, 2011, 10:37 AM
Gopal_mys
Thanks Igor,

Best option was to create two elements and also everything depends on the context setting on the group element.

The way it works in Transformer.


iWay ISM 5.5/iWay ISM 6.0 on Windows.