Learn about XUL, a subset of XML used to describe user interfaces, that helps you to make rich user interfaces with nothing more complicated than a text editor. In the fourth part of this series you will learn about dialog boxes and wizards.
To store RDF in a file that applications are able to use, you need to use the RDF/XML syntax. There are other implementations, such as N3, but RDF/XML works very well with Mozilla and may appeal to those of you that have some XML experience. As we’ve been discussing RDF already, we will begin by creating the RDF/XML file, although in reality, it would probably be the XUL file that you would create first. Nevertheless, in a text editor, begin again with the XML declaration:
<?xml version="1.0"?>
This is not strictly necessary, but should be included for well-formedness. Next, you need to add the RDF container with some namespace properties and the RDF and chrome namespaces:
Next you need to tell Mozilla that you’re describing a list of your applications:
<RDF:Bag about="urn:mozilla:package:root">
I have placed this in a bag container, which is standard RDF syntax for an unordered list. If I wanted to create an ordered list, it would be an <RDF:Seq> sequence. Your application is then defined as an item of the list:
Once this has been added, you need to close off the RDF container:
</RDF:RDF>
And save the file as contents.rdf in the same folder that your wizard application will reside in. This can be any folder, but I would recommend creating a chrome folder in your XUL folder and saving both the RDF and the wizard files in that.
You might be wondering how you could use this file to describe two XUL files. No? Well I’ll tell you how anyway, because sooner or later, you will want to know. It’s simple; all you do is add a second block of code similar to the first, but with the filename of your second XUL file. Then whole file would look like this:
It’s not elegant, and you would think that being a list you could just add the second RDF:Resource statement to the first bag, but doing this will simply not work.