Back to XUL: Uniting XUL and RDF
(Page 1 of 4 )
In the previous article in this series, we put together the main interface file. Before you can see how it will look, however, you need to describe it in a language that Mozilla can understand. This article will show you how to create the appropriate RDF file, register it with Mozilla's chrome directory, and in general get to the point where you can see the fruits of your labors over the previous two articles.
Now we have our main interface file, and I can imagine that you’re eager to see how it will look. But before you can get even a glimpse of it (due to the use of entity references instead of text) there are several things you need to do.
First, you need to describe the interface file in a language that Mozilla can understand; it needs to be described in the language of the Resource Description Framework (RDF.) Its very name gives us an idea of the mechanism for how it works; the XUL file is a resource, and the RDF file describes it.
The idea behind this framework for description is to enable information that would normally be separate to have identifiable relationships defined about it. RDF enables you to write machine (and human) readable data about data – metadata in fact.
The motivation behind this is of course, the semantic web. This is a term that you may have heard, and is a vision of the W3C of an intelligent web where information is autonomously shared. For a general example, image being able to search not for every web page that contains a target word or phrase, but for every page that contains a particular word in a particular context.
Getting back to the subject from which we’ve strayed, let’s create the RDF file that Mozilla needs in order to understand our interface. The implementation of RDF you are going to use is the RDF/XML strain. As such, your file will need to begin with the XML declaration:
<?xml version="1.0"?>
The RDF:RDF container is used as the top level container, and namespace attributes are used to define the child elements in use:
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
Next, the RDF:Bag element describes the overall package:
<RDF:Bag about="urn:mozilla:package:root">
<RDF:li RDF:resource="urn:mozilla:package:interface"/>
</RDF:Bag>
As you can see, the name of the resource is stated using the RDF list element (RDF:li.)
Finally, additional information about the package is defined using the RDF:Description element:
<RDF:Description about="urn:mozilla:package:interface"
chrome:displayName="XUL Edit Lite"
chrome:author="Dan Wellman"
chrome:name="interface"
chrome:version="1.0"/>
The description element uses the same URN (Uniform Resource Name) that you specify in the RDF:Bag element to tie the information to the interface. Finally, the RDF:RDF element is closed:
</RDF:RDF>
Save this file as contents.rdf in the content folder.
Next: The Registration Process >>
More XML Articles
More By Dan Wellman