Using multiple DTDs

Normally you have a single DTD (Document Type Definition) to localize a specific XUL file. But there are situations where you want to use multiple DTDs, for example to localize common widgets used in all your XUL files, additionally to the ones specific to the file.

Single DTD

To make strings in your XUL file localizable, you normally add a DTD declaration at the beginning of the file like this:

<!DOCTYPE window SYSTEM "chrome://myextension/locale/mainwindow.dtd">

where "window" is the local name of the document (root) element.

Assuming you have an entity called someButton.label defined in mainwindow.dtd, you can access the entity like this:

<button id="somebutton" label="&someButton.label">

Multiple DTDs

If you want to use multiple DTDs with your XUL file, you can simply list all of the DTDs inside your DTD declaration:

<!DOCTYPE window [
  <!ENTITY % commonDTD SYSTEM "chrome://myextensions/locale/common.dtd">
  %commonDTD;
  <!ENTITY % mainwindowDTD SYSTEM "chrome://myextension/locale/mainwindow.dtd">
  %mainwindowDTD;
]>

You can now access the entities declared in the DTDs as shown above. Assume you have an entity okButton.label defined in file common.dtd. Then accessing entities from both DTDs would look like this:

<button id="somebutton" label="&someButton.label">
...
<button id="okbutton" label="&okButton.label">

Note that there is no such thing as namespaces with multiple DTDs. You have to make sure by yourself that the entities defined in the various DTDs do not clash.