# Using The XML Catalog

In this tutorial, we will demonstrate the use of the XML Catalog. Add the Example “Editing and validating XML files”. Select File -> New -> Other -> Examples -> Editing and Validating XML files. To demonstrate the XML Catalog, let’s use Invoice.dtd and Invoice.xml located in the XMLExamples project.

1. Create a new folder “Invoice2” in the project “XMLExamples”.
2. Move Invoice.dtd located in XMLExamples\Invoice\ to the new location XMLExamples\Invoice2.
3. Validate Invoice.xml. See the validating XML tutorial. Notice the file is not valid. This is because Invoice.dtd cannot be found. To fix this error, we shall add an entry into the XML Catalog (demonstrated below).

## Adding and Removing Entries from the XML Catalog

The XML Catalog can be accessed through the preferences.

1. Select “Window -> Preferences” to launch the Preferences dialog.
2. Expand the “Web and XML” heading and select “XML Catalog”.

The dialog should appear as shown below.

### Adding an XML Catalog Entry

1. From the Preferences XML Catalog dialog, select “New…”.
2. In the “New XML Catalog Entry” dialog, fill in the values as they appear below.
3. Click “OK” to finish. Notice there is a new entry, InvoiceId, under “User Specified Entries”.
4. Validate Invoice.xml again. Notice it is now valid.

### Removing and Editing an XML Catalog Entry

To remove or edit an entry, simply select the entry and click on “Delete” or “Edit…”.

## Importing and Exporting a Catalog

XML Catalog entries can be saved to a file for later use. This avoids users having to add entries to an XML Catalog when they have already done so in a previous workspace. From the “Advanced XML Catalog Preferences” dialog, the importing and exporting XML Catalog options are available.

### Exporting XML Catalog settings

1. Selecting the “Export…” button on the “Advanced XML Catalog Preferences” dialog.
2. The “Export XML Catalog Settings” dialog will appear. See Figure 4. Select the Project “Catalog” as the location to store the XML Catalog settings file. Enter “.xmlcatalog” as the file name. Click “OK” to finish. The entries specified in the XML Catalog will now be saved in the file.

### Importing XML Catalog settings

1. Selecting the “Import…” button on the “Advanced XML Catalog Preferences” dialog.
2. The “Import XML Catalog Settings” dialog will appear. Select the file containing the XML Catalog settings (.xmlcatalog) and click “OK” to finish. The entries specified in the file will now be in the XML Catalog.