enzhu
10-11-2007, 05:40 AM
Hello! I'm writing a zipcode program looks like this:
<canvas debug="true">
<dataset name="dsX">
<i c="T72B83" k="CAN"/>
<i c="382983928" k="USA"/>
</dataset>
<dataset name="dsY">
<i p="321458234" r="USA"/>
<i p="873623782" r="USA"/>
<i p="E32P78" r="CAN"/>
</dataset>
<class name="zipcode">
<attribute name="country" type="string" value="USA"/>
<handler name="ondata">
var z1, z2;
if (country == "USA") {
z1= this.data.substr(0, 5);
z2 = this.data.substr(5, 4);
} else {
z1 = this.data.substr(0, 3);
z2 = this.data.substr(3, 3);
}
Debug.write(z1 + " " + z2);
</handler>
</class>
<zipcode datapath="dsX:/i/@c" country="$path{'dsX:/i/@k'}"/>
<zipcode datapath="dsY:/i/@p" country="$path{'dsY:/i/@r'}"/>
</canvas>
When I call <zipcode ... />, I'd like country to get the attribute value I specified, of course from the same row as the datapath. Now when I tried this, it gives me:
ERROR: «lz.zipcode».country="$path{'dsX:/i/@k'}" matched 2 nodes
T72 B83
ERROR: «lz.zipcode».country="$path{'dsX:/i/@k'}" matched 2 nodes
382 983
ERROR: «lz.zipcode».country="$path{'dsY:/i/@r'}" matched 3 nodes
321 458
ERROR: «lz.zipcode».country="$path{'dsY:/i/@r'}" matched 3 nodes
873 623
ERROR: «lz.zipcode».country="$path{'dsY:/i/@r'}" matched 3 nodes
E32 P78
I understand why this happens, but is there a way for me to tell it you should take the attribute value from the same row as the datapath?
I also understand if I use same attribute name in both dsX and dsY then I should be ok, I can get country from onData handler by xpathQuery. However, if just in the case like I have now, is it possible?
Thank you very much.
<canvas debug="true">
<dataset name="dsX">
<i c="T72B83" k="CAN"/>
<i c="382983928" k="USA"/>
</dataset>
<dataset name="dsY">
<i p="321458234" r="USA"/>
<i p="873623782" r="USA"/>
<i p="E32P78" r="CAN"/>
</dataset>
<class name="zipcode">
<attribute name="country" type="string" value="USA"/>
<handler name="ondata">
var z1, z2;
if (country == "USA") {
z1= this.data.substr(0, 5);
z2 = this.data.substr(5, 4);
} else {
z1 = this.data.substr(0, 3);
z2 = this.data.substr(3, 3);
}
Debug.write(z1 + " " + z2);
</handler>
</class>
<zipcode datapath="dsX:/i/@c" country="$path{'dsX:/i/@k'}"/>
<zipcode datapath="dsY:/i/@p" country="$path{'dsY:/i/@r'}"/>
</canvas>
When I call <zipcode ... />, I'd like country to get the attribute value I specified, of course from the same row as the datapath. Now when I tried this, it gives me:
ERROR: «lz.zipcode».country="$path{'dsX:/i/@k'}" matched 2 nodes
T72 B83
ERROR: «lz.zipcode».country="$path{'dsX:/i/@k'}" matched 2 nodes
382 983
ERROR: «lz.zipcode».country="$path{'dsY:/i/@r'}" matched 3 nodes
321 458
ERROR: «lz.zipcode».country="$path{'dsY:/i/@r'}" matched 3 nodes
873 623
ERROR: «lz.zipcode».country="$path{'dsY:/i/@r'}" matched 3 nodes
E32 P78
I understand why this happens, but is there a way for me to tell it you should take the attribute value from the same row as the datapath?
I also understand if I use same attribute name in both dsX and dsY then I should be ok, I can get country from onData handler by xpathQuery. However, if just in the case like I have now, is it possible?
Thank you very much.