Example: Generate items with strings from various nodes concatenated

This template generates a label listing favorite animals. We use a set of triples to get the human names, the list of animals, and the animal names. In the label, we put a number of variables to display a somewhat formatted string. The ^ symbol means to concatenate without adding a space, and is used here to pluralize the animal name. Naturally, this technique will only work for words for which adding an s is the correct way to pluralize it.

The results are displayed in an arbitrary order since the favorite animals list is not in a sequence. Note that both the human names and the animal names are displayed correctly even though we iterate over the favorite animals. This is because the template builder maintains the variable bindings for each step of the process.

View   View Data Source

<vbox datasources="animals.rdf" ref="">
          <content uri="?uri"/>
          <member container="?uri" child="?human"/>
          <triple subject="?human"
          <triple subject="?human"
          <triple subject="?favoriteAnimal"
        <label uri="?favoriteAnimal" value="?humanname likes ?animalname^s"/>
Copyright © 1999 - 2005