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 filtered set of menus
This template generates a recursive menu but filters out all animals where specimens is 0. The template builder cannot express negation, so we need to use an empty rule. For animals with no specimens, this empty rule will match and generate no content. To check for specimens, we use an attribute on the rule, declared with a namespace, that matches the specimens predicate in the datasource.
<hbox>
<button label="Animals" type="menu" datasources="animals.rdf"
ref="http://www.some-fictitious-zoo.com/all-animals"
xmlns:animals="http://www.some-fictitious-zoo.com/rdf#">
<template>
<rule iscontainer="true">
<menupopup>
<menu uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
</menupopup>
</rule>
<rule animals:specimens="0"/>
<rule>
<menupopup>
<menuitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
</menupopup>
</rule>
</template>
</button>
</hbox>
