You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.


<< XULNotes Author: Chris Waterson Other Docs: XUL Template Primer

XUL Template Primer - Outliner

Contents

Overview
Example
The outlinerrow condition
The outlinerrow action
The outlinercell action
Related Documents

Overview

This document expands on the XUL Template Primer by illustrating how a XUL template can be used as the view for a XUL outliner.

Example

To illustrate how a template can be used as a view for an outliner, we'll examine this XUL document, which builds an outliner view from the contents of an RDF/XML file. The

<?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin" type="text/css"?> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <tree datasources="toc.rdf" ref="urn:root" flags="dont-build-content" flex="1"> <template> <rule> <conditions> <treeitem uri="?uri" /> <triple subject="?uri" predicate="http://home.netscape.com/NC-rdf#subheadings" object="?subheadings" /> <member container="?subheadings" child="?subheading" /> </conditions> <bindings> <binding subject="?subheading" predicate="http://home.netscape.com/NC-rdf#name" object="?name" /> <binding subject="?subheading" predicate="http://home.netscape.com/NC-rdf#page" object="?page" /> </bindings> <action> <treechildren> <treeitem uri="?subheading"> <treerow> <treecell label="?name" /> <treecell label="?page" /> </treerow> </treeitem> </treechildren> </action> </rule> </template> <treecols> <treecol id="ChapterColumn" flex="1" label="Chapter" sort="?name" primary="true" /> <splitter class="tree-splitter" /> <treecol id="PageColumn" flex="1" label="Page" sort="?page" /> </treecols> </tree> </window>

This uses the same RDF/XML file that we used in the nested content example, toc.rdf.

The dont-build-content flag

The dont-build-content flag instructs the builder not to create a content model, and instead go to the RDF datasource directly for each cell that is to be displayed. The dramatically reduces the amount of memory required for a large datasource, as no XUL content model will be constructed in memory.

You may optionally set the properties attribute on the <treeitem> to a whitespace-separted list of varaibles (e.g. ?var) or constants. These will be atomized, and returned to the outliner as the properties that apply to the current row.

The treeitem condition

The <treeitem> element, when used in a rule's <conditions>, is analogous to the <content> test in a content-model based template. Specifically, it will match a row in the tree, and bind the variable specified by the uri attribute to that row's URI (i.e., the URI in the RDF graph to which the row corresponds).

XUL Template Primer
XUL template basics.
XUL Template Primer - Bindings
Illustrates how to use the <bindings> tag in your XUL templates.
XUL Template Primer - Multiple Rules
Illustrates how to write templates with multiple <rule> elements.
XUL Template Primer - Nested Content
Illustrates how a template can be used recursively to build nested content.
XUL Template Reference
Describes the simple XUL template syntax in detail.