9 Templates

This section describes the data binding facilities of XUL, called templates. A XUL template allows a content author to present live data as arbitrary XUL elements, without writing complex content construction and synchronization code.

A template is a collection of rules that are used to build XUL content from one or more datasources, and is how an author embeds data into a XUL document. A template specifies a content pattern of XUL elements, along with the conditions indicate when the pattern should be used. XUL elements are constructed by copying the pattern and substituting appropriate values derived from the datasource. If the information in the datasource changes, the content is altered accordingly. This page is still under construction.

9.1 Datasources

9.1.1 Background

A XUL template builds its content from one or more datasources. A datasource is a collection of tuples that form an RDF [*] data model. The tuples from each datasource are merged, and treated as a single RDF data model.

Each tuple consists of a subject, a predicate, and an object. The subject of the tuple must be a resource in RDF sense; the predicate must be a property, and the object may either be a resource or a literal.

For example, the following tuples describe the contents of a simple address book:

Tuples may be interpreted as a labelled, directed graph. The above example yields a graph as follows:

9.1.2 The datasources attribute

The datasources attribute may be specified on any XUL element. This attribute indicates the list of the datasources that should be used to build the template's content. The attribute should be a whitespace-separated list of URIs that identify individual RDF datasources; for example, the URLs of RDF/XML data files.

9.2 Rules

9.2.1 Variable Substitution

9.3 Conditions

9.3.1 The <content> element

9.3.2 The <triple> element

9.3.3 The <member> element

9.4 Bindings

9.5 Actions

9.6 Complete Example

9.7 Shorthand Syntax

9.8 Outliner Syntax

A XUL template may be used with the outliner widget. In this case, the XUL template is not used to build a content model; instead, it implements a view for the outliner object.