17.3. Installing DTDs

epcEdit comes with a number of popular pre-installed DTDs. However, you may want to create documents with other DTDs as well. This section describes the necessary steps for installing a new DTD that should be used by epcEdit.

17.3.1. Installing the DTD files

Before you can use a new DTD in epcEdit, you have to store the DTD in a location where epcEdit can read the DTD an its associated files. We recommend to create a subdirectory for each DTD that you install on your system.

  1. Create a new subdirectory for the DTD an all of its files in a suitable location. The epcEdit example directory can be used as the parent directory for the new DTD-specific directory, but any other directory can be used.

    It would be a good idea to give the directory a name that corresponds to the DTD that you are installing.

  2. Copy the DTD and its associated files (e.g. entity definitions, catalog files, etc) into the DTD subdirectory.

    If you have downloaded the DTD from the internet or if you have received the DTD as an archive file (e.g. as a zip or tar archive), then you should unpack the archive into this directory.

    For the DocBook XML DTD, you could create a directory called docbkx412. On a Unix system, you can use the following commands to create a directory and extract the files from the zip archive into this directory:

    mkdir /usr/local/tksgml/examples/docbkx412
    cd /usr/local/tksgml/examples/docbkx412
    unzip ~/docbkx14.zip

17.3.2. Update the catalog

Your new DTD may include a catalog file (usually named catalog) that contains information about the components of the DTD, their public identifiers, the entity sets, etc.

The DocBook XML DTD comes with a catalog file named docbook.cat. In order to use this catalog file, we must tell epcEdit that it should use this catalog for resolving public identifiers. There are three methods for making the catalog available to epcEdit:

  1. By appending the catalog name to the environment variable SGML_CATALOG_FILES. This method is recommended if you are using different SGML/XML systems which honor this environment variable (such as SP/nsgmls and derived products) and you do not have a central system catalog.

  2. By adding a reference to the catalog to the main system catalog. This is recommended if you have a main SGML catalog file and you want to make the DTD available to all SGML applications on your system.

  3. By adding the catalog to the catalog list in the preferences dialog in epcEdit. This method has the advantage that you can safely experiment with new DTDs without influencing other SGML processing software.

In this example, we use the third approach and make the DTD available to epcEdit alone.

  1. To add the catalog to epcEdit's list of catalog files, bring up the Preferences Dialog by selecting Edit->Preferences from the main menu, and click on the Catalogs tab. The following dialog will appear:

  2. Click on the Add... button to bring up a file selection dialog. In this dialog, choose the name of the catalog file that came with the DTD. In our example, this would be the file /usr/local/tksgml/examples/docbkx412/docbook.cat. Clicking the Open button in the file selection dialog will add the catalog file to the list.

  3. Additionally, you may want to limit the use of the catalog docbook.cat to XML documents. Click on the Use for... button and select XML in the catalog usage dialog (see Figure 15-22 for details).

  4. Finally, click on the Save button in the Preferences dialog to close the dialog and save your modifications.

epcEdit can now load documents that use the newly installed DTD.

17.3.3. Creating a template

If you want to create new documents with this DTD, one additional step is necessary: You should create a template that epcEdit will use for creating new documents.

If the new DTD came with an example document (or if you already have a document for the new DTD), the process of creating a new template is straight forward and simple:

  1. Open the document for the new DTD in epcEdit by selecting File->Open and choosing the appropriate document file.

  2. Select Document->New Template->From Current Document from the main menu. A file selection dialog will appear where you can specify the name of the document template.

  3. Enter an appropriate file name (e.g. docbk41x for documents with the DocBook XML DTD) and click on the Save button to save the new template.

You can now create new documents by simply clicking on the template name in the new document dialog (see Figure 15-1).

If you do not have an example document for the new DTD, you will have to create a new template from scratch. Normally, you would use the template wizard for this task. Alternatively, you can simply create a new document (as describe in Section 3.2) and then derive the template from the document as described above. To create you fist DocBook document without a template, you would select to create a new XML document in the New file dialog and enter the following information:

Clicking on the Ok button would then create a new DocBook document and you could save a template for this document as outlined above.

Note: Please refer to the following section for details about the system identifier and document portability.

17.3.4. Notes about system identifiers

The XML standard specifies that every valid XML document must contain a system identifier in its DOCTYPE statement. The system identifier gives the location of the DTD for your document. This means that the document references an external entity that resides either in the file system of your computer or somewhere on the net. This convention introduces two potential problems:

We suggest to solve this issue by following these recommendations:

Be sure to enter the appropriate system identifier when you create a template for your new documents. epcEdit will not strip off the pathname of a system identifier that you provide in the corresponding dialog of the template wizard.

Tip: We recommend to avoid using absolute pathnames altogether. If you need to use a SYSTEM entry, then put a catalog file in the same directory as the DTD and add a SYSTEM directive like

SYSTEM "docbookx.dtd" "docbookx.dtd"

This seems pointless at a first glance, but it will make epcEdit look for the DTD in the same directory as the catalog file. Add this catalog to epcEdit's internal list of catalog files in the Catalogs tab of the Preferences dialog.