You can also use multiple rules with the simple rule syntax. Here is the previous example rewritten using the simple syntax:

<hbox id="photosList" datasources="template-guide-photos3.rdf"
      ref="http://www.xulplanet.com/rdf/myphotos"
      xmlns:dc="http://purl.org/dc/elements/1.1/">
  <template>
    <rule dc:title="Canal">
      <button uri="rdf:*" image="rdf:*" label="View" orient="vertical"/>
    </rule>
    <rule>
      <image uri="rdf:*" src="rdf:*"/>
    </rule>
  </template>
</hbox>

The result to the user in this example is the same as the previous example. You can also mix simple and extended rules in one template, although you may prefer to use the same style in all rules for consistency.

However, if you are going to be using a number of rules, the template builder is more efficient when using multiple rules using the simple rule syntax. This is because all simple rules will iterate over the same data, usually the children of an RDF container. So the builder only performs this step once and filters the data for each rule.

When using the extended rule syntax, the manner in which the graph is navigated may be different for every rule, so no optimization can be done. The builder needs to process every condition of every rule. If, for example, you have six rules, each with a <member> condition, the builder will need to construct the children six times. You probably won't notice any difference for small amounts of data such as the photos example we've been using, but you might for large datasets. Thus, you will want to use the simple rule syntax when possible.

If you are only going to be using one rule, it doesn't matter, of course. Speaking of using a single rule, the simple rule syntax allows a slight shorthand. You can remove the <rule> element and place the rule's conditions directly on the <template>. There's no performance benefit, but it does save some typing.

<hbox id="photosList" datasources="template-guide-photos3.rdf"
      ref="http://www.xulplanet.com/rdf/myphotos"
      xmlns:dc="http://purl.org/dc/elements/1.1/">
  <template dc:title="Canal">
      <button uri="rdf:*" image="rdf:*" label="View" orient="vertical"/>
  </template>
</hbox>

This example shows only a single photo since a condition is used to filter out the other two photos. Note that in this shorthand, the conditions are placed directly on the <template> element.