Just an update. Chris Janik has been helping me off-list and I can now render the dataset:

<canvas>

<dataset name="dset" request="true" type="http" src="http://static.livingcosmos.org/tmp/asanas.xml"/>

<class name="asanaview" bgcolor="blue" >

<attribute name="asana" type="string" />
<attribute name="imgurl" type="string"/>

<simplelayout axis="y" spacing="4"/>

<text bgcolor="green" text="${classroot.asana}" />
<view resource="${classroot.imgurl}"/>

</class>

<window>

<view height="400">
<simplelayout axis="x" spacing="4"/>
<view>
<simplelayout axis="y" spacing="4"/>

<asanaview name="av" datapath="dset:/asanas/asana/" asana="$path{'name/text()'}" imgurl="$path{'img_url/text()'}" />
</view>
<scrollbar/>
</view>

</window>

</canvas>



On 4/15/2011 5:17 PM, P T Withington wrote:
Have a look here:  http://bit.ly/dFVIe7 which says:

When a view's datapath matches more than one data node, one instance of the 
view is created for each match.
OpenLaszlo makes it very easy to automatically map over your dataset creating 
an instance for each match.

On 2011-04-15, at 13:13, Terrence Brannon wrote:

Hello, the examples in "Laszlo in 10 minutes" do not apply to my case. I am
trying to create instances of a class where the binding of the instance
attributes occur via an XML dataset.

I have developed code that renders a single instance of my data:


<canvas>

<class name="asanaview" bgcolor="blue" width="300" height="200">
<attribute name="asana" type="string" />
<attribute name="imgurl" type="string"/>

<simplelayout axis="y" spacing="4"/>

<text bgcolor="green" text="${classroot.asana}" />
<view width="${parent.width}" stretches="both"
resource="${classroot.imgurl}"/>

</class>

<window>

  <asanaview asana="Creeping Swan" imgurl="
http://www.yinyga.com/images/asana_swan_sleeping.gif"; />
<scrollbar/>
</window>

</canvas>

but I'd like to have it iterate over a data structure with several instances
of that data:

<asanas>

<asana>
<img_url>http://www.yinyoga.com/images/asana_swan.gif</img_url>
<name>Swan</name>
<page_url>http://www.yinyoga.com/ys2_2.0_asanas_swan.php</page_url>
</asana>

<asana>
<img_url>http://www.yinyoga.com/images/asana_swan_sleeping.gif</img_url>
<name>Sleeping Swan</name>
<page_url>http://www.yinyoga.com/ys2_2.0_asanas_swan_sleeping.php</page_url>
</asana>

<asana>
<img_url>http://www.yinyoga.com/images/asana_toe_squat.gif</img_url>
<name>Toe Squat</name>
<page_url>http://www.yinyoga.com/ys2_2.0_asanas_toe_squat.php</page_url>
</asana>

</asanas>

and render each one... the trick is that these two lines:


<text bgcolor="green" text="${classroot.asana}" />
<view width="${parent.width}" stretches="both"
resource="${classroot.imgurl}"/>

must be rewritten to be sensitve to which instance they are in and the class
instancing must be done as a function of the dataset.

Reply via email to