Index

Example: Generate HTML using the full syntax

This example shows how to generate HTML content from a XUL template using the full rule syntax. Two textnodes are used for the generated content. The species is emphasized using the HTML em element. The parentheses are also generated and will appear around the emphasized text.

Note that this example will only work as is in Mozilla builds after July 6th, 2004 or thereabouts. For earlier builds, the inline parentheses will need to be removed or no content will be generated. Some builds also require whitespace to be removed as well.

View   View Data Source

<html:div datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/mammals"
          xmlns:html="http://www.w3.org/1999/xhtml">
  <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"/>
          <triple subject="?animal"
                  predicate="http://www.some-fictitious-zoo.com/rdf#species"
                  object="?species"/>
      </conditions>
      <action>
        <html:p uri="?animal">
          <textnode value="?name"/>
          (<html:em>
            <textnode value="?species"/>
          </html:em>)
        </html:p>
      </action>
    </rule>
  </template>
</html:div>
Copyright © 1999 - 2005 XULPlanet.com