Topic Options
#29710 - 02/07/08 01:50 PM XPath Conditions
Jobin.G Offline
Member

Registered: 03/15/04
Posts: 68
Loc: Qu
Hi, it would be nice to be able to use Xpath conditions in expressions...

Lets say My XML is structured that way:

Code:
<xml...>
<ROOT>
   <CLIENT NUM="1">Alfredo</CLIENT>
   <CLIENT NUM="2">Steeve</CLIENT>
</ROOT>
A conditional XPath would look like this :
/ROOT/CLIENT[@NUM > 1]/

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 :
/ROOT/CLIENT/ADRESS[@TYPE='POSTAL']

Thanks

Top
#29711 - 02/08/08 02:27 PM Re: XPath Conditions
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1926
Loc: Objectif Lune, Montreal, Qc
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!
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#29712 - 02/11/08 09:07 AM Re: XPath Conditions
Jobin.G Offline
Member

Registered: 03/15/04
Posts: 68
Loc: Qu
Is it possible to have an example to do this using Talk ?

Thanks.

Top
#29713 - 02/11/08 11:50 AM Re: XPath Conditions
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1926
Loc: Objectif Lune, Montreal, Qc
You could use something like this:
Code:
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.
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#29714 - 02/11/08 01:14 PM Re: XPath Conditions
Jobin.G Offline
Member

Registered: 03/15/04
Posts: 68
Loc: Qu
Ok...
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"

Thanks
Guillaume

Top