Index

Example: Recursively generate a list of items

This template iterates over a list of children but does this recursively. First it generates a list of children, then for each child node, repeat the template to get the grandchildren nodes. The action requires an <vbox> since the nested elements are added as children of the tag with the uri attribute. If we had used the label instead, the nested items would be generated as children of the label and they would not show on screen. Some style rules have been used to show the structure of the generated content.

View   View Data Source

<vbox datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/all-animals">
  <template>
    <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>
        <vbox uri="?animal" style="border: 1px solid grey; margin: 1em;">
          <label value="?name"/>
        </vbox>
      </action>
    </rule>
  </template>
</vbox>
Copyright © 1999 - 2005 XULPlanet.com