Index

Example: Generate a list of items using a binding

This template demonstrates the difference between the triple and binding elements. The first box uses a triple for matching a person's last name. Sarah's last name is not specified in the datasource, so she will not match the conditions. However, in the second box, she does appear since a binding is used instead. The binding allows variables to be assigned values without preventing the condition from matching if a value was not found.

View   View Data Source

<vbox style="border: 1px solid red;"
      datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/humans">
  <template>
    <rule>
      <conditions>
          <content uri="?uri"/>
          <member container="?uri" child="?human"/>
          <triple subject="?human"
                  predicate="http://www.some-fictitious-zoo.com/rdf#name"
                  object="?name"/>
          <triple subject="?human"
                  predicate="http://www.some-fictitious-zoo.com/rdf#lastName"
                  object="?lastname"/>
      </conditions>
      <action>
        <label uri="?human" value="?name ?lastname"/>
      </action>
    </rule>
  </template>
</vbox>
<vbox style="border: 1px solid blue;"
      datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/humans">
  <template>
    <rule>
      <conditions>
          <content uri="?uri"/>
          <member container="?uri" child="?human"/>
          <triple subject="?human"
                  predicate="http://www.some-fictitious-zoo.com/rdf#name"
                  object="?name"/>
      </conditions>
      <bindings>
          <binding subject="?human"
                   predicate="http://www.some-fictitious-zoo.com/rdf#lastName"
                   object="?lastname"/>
      </bindings>
      <action>
        <label uri="?human" value="?name ?lastname"/>
      </action>
    </rule>
  </template>
</vbox>
Copyright © 1999 - 2005 XULPlanet.com