Index

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.

View   View Data Source

<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>
Copyright © 1999 - 2005 XULPlanet.com