PDA

View Full Version : xpath predicate with child text = literal?


thegladio
10-27-2004, 02:31 AM
I must be doing something really stupid but I cannot for the life of me figure out why the following code does not work the way I would like it to.

<canvas>

<combobox defaulttext="Choose One...">
<textlistitem
datapath="myData:/myXML/person[show = 'simpsons']"
text="$path{'firstName/text()'}"
value="$path{'lastName/text()'}" />
</combobox>

<dataset name="myData">
<myXML>
<person>
<firstName>Homer</firstName>
<lastName>Simpson</lastName>
<show>simpsons</show>
</person>
<person>
<firstName>Marge</firstName>
<lastName>Simpson</lastName>
<show>simpsons</show>
</person>
<person>
<firstName>Vinny</firstName>
<lastName>Barbarino</lastName>
<show>Welcome Back, Kotter!</show>
</person>
</myXML>
</dataset>

</canvas>

Obviously, the combox box should only display two entries not three. What am I doing wrong? Is this not legal XPath?

neilweber
01-20-2005, 03:47 PM
In this posting dated 12/29/03, http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=546, Antun says XPath predicates aren't supported, but will be supported in the next release. What is the status of predicate support?

passif
01-21-2005, 12:45 AM
I've also hit this problem - however there is a way to get past this. Means your data structure will have to change slightly. The following code should do what you want to though as the supported xpath syntax does work with attributes.

<canvas>

<combobox defaulttext="Choose One...">
<textlistitem
datapath="myData:/myXML/person[@show = 'simpsons']"
text="$path{'firstName/text()'}"
value="$path{'lastName/text()'}" />
</combobox>

<dataset name="myData">
<myXML>
<person show="simpsons">
<firstName>Homer</firstName>
<lastName>Simpson</lastName>
</person>
<person show="simpsons">
<firstName>Marge</firstName>
<lastName>Simpson</lastName>
</person>
<person show="Welcome Back, Kotter">
<firstName>Vinny</firstName>
<lastName>Barbarino</lastName>
</person>
</myXML>
</dataset>

</canvas>