Home arrow XML arrow Page 2 - An Introduction to XUL Part 4

Using the RDF/XML Syntax - XML

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.

TABLE OF CONTENTS:
  1. An Introduction to XUL Part 4
  2. Using the RDF/XML Syntax
  3. Creating the Wizard
  4. Adding to the installed-chrome.txt file
By: Dan Wellman
Rating: starstarstarstarstar / 7
June 13, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
 

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:

<RDF:RDF xmlns:RDF="http://www.w3.org/1999/
         02/22-rdf-syntax-ns#"
         xmlns:chrome="http://www.mozilla.org/rdf/chrome#">

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:

<RDF:li resource="urn:mozilla:package:mywizard"/>
</RDF:Bag>

You now need to provide a description of your application:

<RDF:Description about="urn:mozilla:package:mywizard"
          chrome:displayName="Wizard"
          chrome:author="Dan Wellman"
          chrome:name="mywizard"
          chrome:version="1.0"/>

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:

<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/
         02/22-rdf-syntax-ns#"
         xmlns:chrome="http://www.mozilla.org/rdf/chrome#">

<RDF:Bag about="urn:mozilla:package:root">
  <RDF:li RDF:resource="urn:mozilla:package:fredswizard"/>
</RDF:Bag>

<RDF:Description about="urn:mozilla:package:fredswizard"
          chrome:displayName="Freds Wizard"
          chrome:author="Fred"
          chrome:name="fredswizard"
          chrome:extension="false"/>

<RDF:Bag about="urn:mozilla:package:root">
  <RDF:li RDF:resource="urn:mozilla:package:danswizard"/>
</RDF:Bag>

<RDF:Description about="urn:mozilla:package:danswizard"
          chrome:displayName="Dans Wizard"
          chrome:author="Dan"
          chrome:name="Danswizard"
          chrome:extension="false"/>
</RDF:RDF>

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.



 
 
>>> More XML Articles          >>> More By Dan Wellman
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

XML ARTICLES

- Google Docs and Xpath Data Functions
- Flex Array Collection Sort and Filtering
- The Flex Tree Control
- Flex List Controls
- Working with Flex and Datagrids
- How to Set Up Podcasting and Vodcasting
- Creating an RSS Reader Application
- Building an RSS File
- An Introduction to XUL Part 6
- An Introduction to XUL Part 5
- An Introduction to XUL Part 4
- An Introduction to XUL Part 3
- An Introduction to XUL Part 2
- An Introduction to XUL Part 1
- XML Matters: Practical XML Data Design and M...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: