XUL, the XML-based UI language used in Mozilla products, has supported templating for a while now. Unfortunately, the only datasources you could use to drive the templates were RDF-based datasources. This has been a hurdle for some, including me, to really dive into XUL templates.
Recently, Neil Deakin landed support for generic XML datasources, so I no longer have an excuse to not use XUL templates. Here’s an example:
// Use a predefined RDF datasource <vbox datasources="rdf:bookmarks" ref="NC:BookmarksRoot" flex="1"> <template> <button uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#Name"/> </template> </vbox>
// Use an inline XML datasource or a URL-based XML datasource <people id="peeps"> <person name="billy"/> <person name="jimmy"/> </people> <vbox id="list" datasources="#peeps" ref="." querytype="xml"> <template> <button uri="?" label="?name"/> </template> </vbox>
The results are the same: A list of
<button> elements are generated inside the
<vbox>. Here is some developer information on XML datasources. You can test the new XML datasources in the latest Firefox 3a6 / XULRunner 1.9a6 releases.
Also, be on the lookout for SQL-based XUL template datasources too!