PDA

View Full Version : "The markup in the document following the root element must be well-formed."


insolit
03-31-2008, 09:05 AM
I have a main.lzx file that defines the layout for my application.
The my aim is to build separate lzx files that will be included in a specific place of that layout, using the include tag <include href="...lzx" />

The layout lzx loads well, but when i include the following lzx file:

<dataset name="dset" src="configuration.xml"/>

<simplelayout axis="y" />

<view datapath="dset:/Configuration/AvailableTypes">
<simplelayout axis="y" />
<text datapath="Type/text()"/>
</view>

I get the following compilation error: "configurator.lzx:3:2: The markup in the document following the root element must be well-formed."

"main.lzx" file has the following content:

<canvas width="100%" height="100%" bgcolor="0xc92222" debug="true">

<simplelayout axis="y" />
<!-- Header (displays a header and also contains a space "editableHeader" that might be used to show some information) -->

<view name="header" bgcolor="0x773c3c" width="100%" resource="images/logo.jpg">
<view name="logo" resource="images/logo.jpg" height="144" width="638" />
<view name="editableHeader" bgcolor="0xf3c614"
x="${parent.logo.width}" width="100%" height="${parent.logo.height}" />
</view>

<!-- Left area (container for a possible menu)
<view name="left" bgcolor="0x584f29" width="200" height="100%" y="${canvas.header.height}" /> -->

<!-- Application area -->
<view name="application" bgcolor="0x139b13" height="${canvas.height - canvas.header.height}" width="100%">
<simplelayout axis="y" />
<attribute name="cdHeight" value="100" type="number" />
<attribute name="bdHeight" value="100" type="number" />
<attribute name="confHeight" value="${this.height - (this.cdHeight + this.bdHeight)}" type="number" />

<view name="configurationDisplay" bgcolor="0x13409b" width="100%" height="${parent.cdHeight}" />

<view name="configurator" bgcolor="0x6a99f9" width="100%" height="${parent.confHeight}">
<include href="configurator.lzx" />
</view>

<view name="budgetDisplay" bgcolor="0xf3c614" width="100%" height="${parent.bdHeight}" />
</view>
</canvas>

antun
03-31-2008, 09:33 AM
Do you have <library> tags at the root of your included file?

-Antun

insolit
03-31-2008, 09:49 AM
Well I did not put it because I read in "Laszlo in Action" that putting <library> tag in an included file would make it be loaded right in the start and I don't want it happen to happen. The behavior i was expecting was something like the include in php, that basically inserts the content of the the included file in the point where it was included.

Also I still not understand the way to include xml files meant to be used as libraries. The only way I found to make these work was by defining the dataset under <canvas>. If i insert it under a child of canvas, there's no way i can access it. Any ideas of what I'm doing wrong?

Thanks for your reply.

senshi
03-31-2008, 12:10 PM
Well I did not put it because I read in "Laszlo in Action" that putting <library> tag in an included file would make it be loaded right in the start and I don't want it happen to happen. The behavior i was expecting was something like the include in php, that basically inserts the content of the the included file in the point where it was included.
There's one caveat when you use that approach:
XML-files must be well-formed, which means there must a single root-element. In your case, you've got three root-elements:

dataset
simplelayout
view


The only way I found to make these work was by defining the dataset under <canvas>. If i insert it under a child of canvas, there's no way i can access it. Any ideas of what I'm doing wrong?
If the dataset is not a child of the canvas, it won't be in the global application scope, therefore you need to use the "local-dataset" style:

<view>
<dataset name="ds" ><data>hello</data></dataset>
<text datapath="local:parent.ds:/data/text()" />
</view>

insolit
04-01-2008, 01:23 AM
Thank you for your enlightenment Senshi.
At some point I though i needed a way to point the path of my dataset when not defined in canvas, but I was not aware of that "local:..." syntax. Thanks for the tip. Is that documented anywhere?

Also thank you for the XML tip, I now understand what was going on.

Best regards.

senshi
04-01-2008, 11:36 AM
At some point I though i needed a way to point the path of my dataset when not defined in canvas, but I was not aware of that "local:..." syntax. Thanks for the tip. Is that documented anywhere?

Yes, in the Dev-Guide, Chapter 37. "Data Access and Binding (http://www.openlaszlo.org/lps4/docs/developers/databinding.html)" - "Dataset Scope (http://www.openlaszlo.org/lps4/docs/developers/databinding.html#d0e89444)"