3.3. Create Recompiled DTD Subset

Emacs will perform syntax highlighting and indent correctly on DocBook XML files if you provide it with the proper Document Type Declarations (DTD) file. These two features will make your XML file look pretty and help you spot errors.

To create a loadable Parsed DTD file:

  1. Find the parent file for the group of DocBook files. You will recognize this file by the header <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN". An easy way to find this parent file is to use the command grep DocBook *.xml. Once you find the parent file, open it in Emacs with the command emacs <parentfile>.xml (where <parentfile>.xml is the parent file you found.

  2. Choose DTD -> Parse DTD from the pulldown menu.

  3. You will know the parsing is finished when you see the message Fontifying...done at the bottom of your screen. Save the parsed DTD to a file by choosing DTD -> Save Parsed DTD from the pulldown menu.

  4. Press Enter to save the file to the default filename or rename the file keeping the .ced extension. It can be useful to name it something generic such as docbook.ced so you can refer to it when opening all DocBook files. This file can also be copied from directory to directory to be loaded.

[Tip]Tip

You can also use the Emacs command Meta-x sgml-parse-prolog to parse the file, and then use the command Meta-x sgml-save-dtd to save the parsed DTD to a .ced file.