WARNING: Most of this content (with the exception of the Mozilla 1.9 XPCOM reference) is very old, and can be expected to be out of date and possibly obsolete. For better XUL documentation, please visit the XUL hub at the Mozilla Developer Center.
Example: Generate a list of items using a binding
This template demonstrates the difference between the triple and binding elements. The first box uses a triple for matching a person's last name. Sarah's last name is not specified in the datasource, so she will not match the conditions. However, in the second box, she does appear since a binding is used instead. The binding allows variables to be assigned values without preventing the condition from matching if a value was not found.
<vbox style="border: 1px solid red;"
datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/humans">
<template>
<rule>
<conditions>
<content uri="?uri"/>
<member container="?uri" child="?human"/>
<triple subject="?human"
predicate="http://www.some-fictitious-zoo.com/rdf#name"
object="?name"/>
<triple subject="?human"
predicate="http://www.some-fictitious-zoo.com/rdf#lastName"
object="?lastname"/>
</conditions>
<action>
<label uri="?human" value="?name ?lastname"/>
</action>
</rule>
</template>
</vbox>
<vbox style="border: 1px solid blue;"
datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/humans">
<template>
<rule>
<conditions>
<content uri="?uri"/>
<member container="?uri" child="?human"/>
<triple subject="?human"
predicate="http://www.some-fictitious-zoo.com/rdf#name"
object="?name"/>
</conditions>
<bindings>
<binding subject="?human"
predicate="http://www.some-fictitious-zoo.com/rdf#lastName"
object="?lastname"/>
</bindings>
<action>
<label uri="?human" value="?name ?lastname"/>
</action>
</rule>
</template>
</vbox>
