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.
Back to XUL: Uniting XUL and RDF - The Registration Process (Page 2 of 4 )
Now for the registration process. If you had used plain text labels throughout your file, you would be able to open this file in Mozilla in a kind of low privilege, view only mode. It would be opened using the standard File àOpen method, but as a chrome URL has not been used, it would not have file system access or anything like that.
To register your file with Mozilla then, you need to browse to the Mozilla chrome directory (C:\Program Files\mozilla.org\Mozilla\chrome) and find a file called installed-chrome.txt. Even though this is a simple text file, it will look a little odd when viewed in Notepad, so I would recommend using something a little more powerful (I use a fantastic freeware application called nPad2).
So open the file and you will see basically a list of all of the chrome that makes up the Mozilla interface. Go to the end of the file and add the following instruction:
If you have saved the interface file in another location, adjust the above line of code accordingly. Also, make sure that you hit the return key after entering the final forward-slash.
Also in the chrome folder is a file called chrome.rdf which you need to delete. Now open Mozilla, and this file will reappear in the chrome directory. Provided you entered the above instruction correctly, you should be able to find a section in the chrome.rdf file describing the Interface file we have created. This will denote successful registration of the interface file.
There still remains something that needs to be done, however, before we can finally view our interface. We need to make, and register, the DTD file.
Open a new file in your text editor and begin once more with the XML declaration:
Now for each of the entity references from the interface file, you need to add an entity declaration:
<!ENTITY fileLabel "File">
This is an easy file to code. As the example shows, you declare each entity using the !ENTITY keyword followed by the entity reference name, followed by the string you want displayed double-quoted. Easy. Now for the rest of the file:
<!ENTITY menuseparatorLabel "Insert menu seperator">
<!ENTITY formsTooltip "Insert Form Element">
<!ENTITY textboxLabel "Insert textbox">
<!ENTITY listboxLabel "Insert list box">
<!ENTITY radioLabel "Insert radio button">
<!ENTITY windowsTooltip "Insert Window Element">
<!ENTITY windowLabel "Insert window">
<!ENTITY wizardLabel "Insert wizard">
<!ENTITY editorLabel "Insert editor">
<!ENTITY browserLabel "Insert browser">
<!ENTITY iframeLabel "Insert iframe">
<!ENTITY titlebarLabel "Insert titlebar">
This file should be saved with a .dtd extension in the en-US folder. The file name should match the filename of the main XUL file, in this case, interface.dtd. There will be more text strings to add to this file at some point in the future, as we will need to add the text this is displayed in the help pop-up, but we can add that later, once we have coded the additional window itself.
Now, the final step before we are able to take a look at the fruits of our labor is to register the DTD and link it to the XUL file.