XPath Conditions

Posted by: Jobin.G

XPath Conditions - 02/07/08 01:50 PM

Hi, it would be nice to be able to use Xpath conditions in expressions...

Lets say My XML is structured that way:

   <CLIENT NUM="1">Alfredo</CLIENT>
   <CLIENT NUM="2">Steeve</CLIENT>
A conditional XPath would look like this :

This example is a little bit weak because it would be possible to loop on iteration 2 to 0..

A perfect case of use would be you have three different adresses for a customer wich have the same structure and a different type :

Posted by: Philippe F.

Re: XPath Conditions - 02/08/08 02:27 PM

Yes, we are aware of this limitation in the XML implementation.

We designed it this way for the sake of performance since PPtalk is already able to handle such types of expressions natively. We therefore did not need to include all the extra logic in the XML interpreter, which could have had a negative impact on performance.

Nonetheless, we will keep you suggestion in our database in case we find an efficient way of implementing it.

Thanks for your comments!
Posted by: Jobin.G

Re: XPath Conditions - 02/11/08 09:07 AM

Is it possible to have an example to do this using Talk ?

Posted by: Philippe F.

Re: XPath Conditions - 02/11/08 11:50 AM

You could use something like this:
show(if((strtoint(XmlGet('/ROOT/CLIENT/@NUM')) > 2),'Greater than 2','Less than or equal to 2'))
This displays Greater than 2 if the client number is greater than 2, otherwise it displays Less than or equal to 2.

You can even design very complex expressions by wrapping them into a global function that returns a specific value based on just about any amount of processing you want. You then specify that global function as your condition.
Posted by: Jobin.G

Re: XPath Conditions - 02/11/08 01:14 PM

I understand the way you ment it.

But I think Xpath would be a lot more powerfull and easier to design.

However I understand very well the reasons why its done that way and that Talk is an acceptable "workaround"