PDA

View Full Version : Constraining a datapath


antun
02-26-2004, 12:25 PM
Datapaths can be constrained just like other attributes in LZX. For example, say you wanted the datapath of a <text> element to resolve to:

myds:/myroot/mynode[3]/@txt

... but you wanted the node number (3) to be variable as well as the name of the attribute (txt). You could constrain it as usual:


<canvas debug="true">
<dataset name="myds">
<myroot>
<mynode txt="Hi there" />
<mynode txt="Bye there" />
<mynode txt="Smile" />
</myroot>
</dataset>

<view name="container">
<attribute name="attrName" value="txt" type="string" />
<attribute name="nodeNum" value="3" type="number" />
<text name="myText"
datapath="$once{ 'myds:/myroot/mynode['
+ parent.nodeNum
+ ']/@'
+ parent.attrName }" />
</view>
</canvas>


Enjoy!

zvi
10-24-2006, 12:25 AM
I have found that datapath="$once{...}" does not always work well because it initializes too late.

Use datapath="$immediately{...}" instead.

Zvi