Example: Match items from two lists

Here we want to determine which of Robert's pets are also his favorite animals. Essentially, we want to find out what items appear in two lists. The results we desire are 'Chameleon' and 'Tarantula'. To begin, we iterate over Robert's favorite animals using the first triple. Next, we use another triple and a member to iterate over Robert's pets. Both a triple and a member are necessary to get from Robert to the pet container and finally to the pets.

The key here is that both lists use the same variable 'favoriteAnimal'. This causes the template to first generate the list of favorite animals and add them to this variable, since this condition comes first in the list of rules. Then, it builds the list of pets, and adjusts the same variable to filter out the ones that don't match both lists.

View   View Data Source

<vbox datasources="animals.rdf" ref="">
          <content uri="?uri"/>
          <triple subject="?uri"
          <triple subject="?uri"
          <member container="?pets" child="?favoriteAnimal"/>
          <triple subject="?favoriteAnimal"
        <label uri="?favoriteAnimal" value="?name"/>
Copyright © 1999 - 2005