PDA

View Full Version : set view's dynamic x and y attribute value from datapath


dong_xin00
03-24-2005, 08:20 AM
I have a view like:
<view datapath="component" x="$path{'x/@value'}" y="$path{'y/@value'}">

which works fine, however, I want to set the x and y value by the current one sub or add some integer value, I tried:
x="$path{'x/@value'}-5"

which will recieve an error:
The value of the 'x' attribute uses a deprecated syntax. Use x="${$path{'x/@value'}-5}" instead.

then I tried
x="${$path{'x/@value'}-5}"
which will recieve an error:
Syntax error: the token "{" was not expected at this position.

I am wondering what was wrong or it can not be done in this way?

Thanks in advance.

jeffburton
03-25-2005, 07:35 AM
Try this:

<canvas width="100%" height="100%">
<dataset name="test">
<stuff>
<x>100</x>
<y>100</y>
</stuff>
</dataset>
<view datapath="test:/stuff"
x="${this.datapath.xpathQuery('x/text()') * 3}"
y="${this.datapath.xpathQuery('y/text()') / 2}"
width="50" height="50" bgcolor="red"/>
</canvas>