PDA

View Full Version : Can't bind List to XML source


eHaggis
06-08-2006, 06:10 PM
I'm new at this so please bear with me.

I'm trying to create a little navigation widget but can't seem to get the list component to bind to an XML data source. I have a Tabslider with some general headings but then I want to have a database generated list of topics under each one. The idea is to put in a list within each of the areas within the Tabslider and bind them to different datasets.

Here's the XML source that is returned from my web page:

<NewDataSet>
<Table>
<GenreID>0</GenreID>
<Name>Blues</Name>
<Playcount>0</Playcount>
<Rating>0</Rating>
</Table>
<Table>
<GenreID>8</GenreID>
<Name>Jazz</Name>
<Playcount>0</Playcount>
<Rating>0</Rating>
</Table>
<Table>
<GenreID>12</GenreID>
<Name>Other</Name>
<Playcount>0</Playcount>
<Rating>0</Rating>
</Table>
<Table>
<GenreID>13</GenreID>
<Name>Pop</Name>
<Playcount>0</Playcount>
<Rating>0</Rating>
</Table>
<Table>
<GenreID>17</GenreID>
<Name>Rock</Name>
<Playcount>0</Playcount>
<Rating>0</Rating>
</Table>
</NewDataSet>


Here's my lzx file:

<canvas bgcolor="#EAEAEA" width="640" height="700">

<dataset name="dset2"
autorequest="true"
type="http"
src="http://localhost/TestNTAXML"
querystring="usp=usp_SelectUsedGenres"/>

<simplelayout axis="y" inset="20"/>
<view layout="axis:y;spacing:4">
<list width="130">
<listitem datapath="dset2:/NewDataSet/Tables"
text="Name/text()"
value="Name/text()"/>
</list>
</view>

</canvas>


Can anyone tell me what I'm doing wrong? Any help will be greatly appreciated!!

paserry
06-08-2006, 07:44 PM
hi

<listitem datapath="dset2:/NewDataSet/Tables"

Tables?
You use <Table> tag in your xml.

eHaggis
06-09-2006, 03:54 AM
Thanks! I've been staring at this so long I completely missed that.

My problem is not completely solved, however. Now I get the list to show with the correct number of rows but they are all blank. I must have something wrong in:

text="Name/text()"
value="Name/text()"/>


That is what worked for me using the Grid component but it does not seem to work here. Any suggestions?

notzippy
06-09-2006, 07:30 AM
try
text="$path{'Name/text()'}"
value="$path{'Name/text()'}"/>

eHaggis
06-09-2006, 02:27 PM
THANKS! That did it. i've been pulling my hair out. Part of my problem was that the online demo has slightly different code which does not work.

Here's what is in the list_example.lzx that is part of the Laszlo in 10 Minutes demo (Which is excellent otherwise):

<list id="a1" width="130" oninit="selectItemAt(1)" shownitems="3">
<textlistitem datapath="items:/item" text="$path{"text()"}" value="$path{"@value"}"/>
</list>


Notice that the sigle quotes and double quotes are reversed from what you provided.

Thanks again.

paou
06-12-2006, 12:03 AM
Actually to me, the quotes don't look reversed, they're just plain wrong.

If they were just reversed then it would have no impact, it doesn't matter in laszlo if you write "something('here')" or 'something("there")', apart from the fact I personally find the latter harder to read.

text="$path{"text()"}" the text() code is (incorrectly) outside the quotes and should probably generate a compiler warning??

Note: My local copy of list_example.lzx looks different and (correctly) uses '$path{"text()"}'