PDA

View Full Version : Creating dynamic Datapaths


Grig
04-04-2003, 02:04 PM
I'm trying to translate an LZX file to French. To do this we are using datapath="en_data:/" at the top most level of about 5 different views. We also use some absolute paths in some hard to reach sections with something like:

<text datapath="en_data:/sub/sub/text()"/>

What is the best way to change ALL the root paths from 'en_data:/' to 'fr_data:/' ?

I've tried a few things, but nothing seems to work right. Has anyone done this before? I was thinking about having 1 global root path and then pointing that datapath to the appropriate language dataset.

Thanks,
Grig
:)

adam
04-21-2003, 08:48 AM
Hi Grig,
Probably the easiest way to do this is to map a very high-level enclosing view to the dataset and then to map all the other datapaths relative to it

<view name="outerview" datapath="fr_data:/">
....
<view datapath="path/@attr"/>



This way, when you change the datapath on outerview (using setDatapath) all the interior datapaths will update.

Grig
04-21-2003, 10:24 AM
This is what I ended up doing:

Set up a HTTP datasource:
<datasource type="http" name="languageHTTP">
<dataset name="langData" autorequest="true" src="en_dataset.xml"/>
</datasource>


Assign text views to the tree of data:
<view datapath="langData:/">
<text datapath="previous/sub/text()"/>
</view>


In cases where there are 2 datapaths required for functioning, I used absolute paths for the text:
<text datapath="langData:/previous/sub/text()"/>


I used this to change pointers for all paths with 1 call:
canvas.languageHTTP.langData.setURL("fr_dataset.xml");

- Grig