Example: Generate a set of menulists
This template iterates over a list of the animal classes. For each class, it generates a menulist. This template uses two rules. In the first rule, we use the simple syntax to match all containers and will generate a vbox with a label in it. The label is bound to the name predicate.
The second rule matches all non-containers which will be the individual animals. We use the full syntax despite that the simple rule syntax could be used since we are only iterating over a container. The condition generates the list of children of the classes. Since the template builder does recursion automatically, the second rule will apply to the inner items. The content will be inserted as children of the parent's hbox (which is defined in the first rule). The menulist and menupopup is only generated once for each list of children since the uri attribute is used on the menuitem tag.
<vbox datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/all-animals"> <template> <rule iscontainer="true"> <hbox align="left" uri="rdf:*"> <label value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/> </hbox> </rule> <rule> <conditions> <content uri="?uri"/> <member container="?uri" child="?animal"/> <triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/> </conditions> <action> <menulist> <menupopup> <menuitem uri="?animal" label="?name"/> </menupopup> </menulist> </action> </rule> </template> </vbox>