views:

126

answers:

1

Hi, I've gotten trouble with passing XML data into XUL template.

Look:

For example, we have the datasource XML with the next structure:

<people>
 <person name="Joe"/>
 <person name="Tom"/>
 <person name="Lisa"/>
 <person name="Bob"/>
</people>

In this case we may use the next template in XUL:

<template>
 <query expr="person"/>
 <action>
  <listitem uri="?" label="?name"/>
 </action>
</template>

The question is what should I put into the listitem's label attribute in case datasource XML has such structure:

<people>
 <person>Joe</person>
 <person>Tom</person>
 <person>Lisa</person>
 <person>Bob</person>
</people>

Thank you in advance.

+1  A: 

Probably using <assign>:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;

<people id="famouspeople" xmlns="">
  <person>Napoleon Bonaparte</person>
  <person>Cleopatra</person>
</people>

<listbox datasources="#famouspeople" ref="*" querytype="xml">
  <template>
    <query expr="person">
      <assign var="?name" expr="./text()"/>
    </query>

    <action>
      <listitem uri="?" label="?name"/>
    </action>
  </template>
</listbox>

</window>
Nickolay
Thank you, assign did help.
Eugene