# Adding entries to the XML Catalog

XML Catalog entries are used to map external entity references to locally defined resources. You can provide rules specify how these entities are resolved

For details on the standard for XML Catalogs, see: http://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html.

For example: you are working on an XML file on a computer and point its `schemaLocation` towards a schema called `c:\MySchema.xsd`. If you do not use an XML catalog, then when you finish editing the XML file and are ready to publish it on the Web, you will need to edit `schemaLocation` so that it points to a resource that is accessible on the Web.

To avoid making frequent changes to your XML document, you can use the XML Catalog: you could specify a rule that redirects an Internet resource reference (for example, `"http://www.ibm.com/published-schemas/MySchema.xsd"`) so that it points to a resource on the local machine (for example, `"file:///C:/MySchema.xsd"`). Now, instead of frequently editing XML documents to update the URIs or locations (especially when there are many documents in your project), you only need to update a single rule in your XML Catalog.

The following instructions were written for the Resource perspective, but they will also work in many other perspectives.

To add an entry to the XML Catalog, follow these steps:

1. Open the XML file that you want to associate with a DTD or XML schema.
2. Click Window > Preferences and select XML > XML Catalog. The XML Catalog Entries section contains a list of any user-defined and plug-in defined catalog entries. Select any entry to see information about it in the Details section.
3. Click Add to create a new catalog entry.
4. In the left-hand column, click the type of catalog entry that you want to add:

   Option | Description
   --- | ---

   Catalog Entry

   Used by an XML processor when resolving entity references. You can provide rules to the catalog to specify how entities should be resolved.
   An XML Catalog entry contains two parts:
   - A key (which represents a DTD or XML schema)
   - A location (similar to a URI, which contains information about a DTD or XML schema's location).
   You can place the Key in an XML file. When the XML processor encounters it, it will use the XML Catalog entry to find the location of the DTD or XML schema associated with the Key

   Rewrite Entry | Used to redirect a set of entities.
   Suffix Entry | Used to match the suffix of a URI or systemID.
   Next Catalog | Used to refer to another catalog without importing it into the workbench.
   Delegate Catalog | Used to associate an alternate catalog with an identifier.

5. Complete the fields for the catalog entry that you selected:

   Table 1. Catalog entry types and associated fields
   Catalog type | Fields
   --- | ---

   Catalog Entry

   - In the Location field, enter or browse for the location or URI of the DTD or XML schema file. This uses your computer's path style to describe the location of the file.
   - Select a Key Type:
     - If you specified a DTD: select Public ID, System ID, or URI from the Key Type field. If you select Public ID, the value you enter in the Key field should be the same as the Public ID in the XML file's DOCTYPE declaration. If you select System ID, the value you enter should correspond to the System ID in an XML file's DOCTYPE declaration. If you select URI, the value you enter must be a fully qualified URI.
     - If you specified an XML schema: select either Namespace Name or Schema Location from the Key Type field. If the schema defines a target namespace, it will automatically appear in the Key field. Otherwise, you can enter the schema location in the Key field.
   - Select the Specify alternative Web address check box if you want to be able to specify an alternate Web address for the resource.
     This Web address is used when an XML instance is generated from this catalog entry.
     Note: This option is only available if you select Public ID (for a DTD) or Namespace Name (for a schema) in the Key type field.

   Rewrite Entry

   - Select a Key type to match, either URI or systemID.
   - Matching start string: The matching prefix to be removed from the supplied identifier.
   - Rewrite prefix: The prefix is be used instead of the prefix that is removed.

   Suffix Entry

   - In the Location field, enter or browse for the location or URI of the DTD or XML schema file. This uses your computer's path style to describe the location of the file.
   - Select a Key Type (URI or systemID) to match.
   - Type the Suffix of the identifier to match.

   Next Catalog | In the Location of another XML Catalog file field, type or browse for the XML catalog you want to refer to.

   Delegate Catalog

   - Select a Key type to match, either URI or systemID.
   - Matching start string: The prefix of the supplied identifier to match.
   - Delegate to this XML file: The alternate catalog to associate.

6. When you are done creating catalog entries, click OK to close the Add XML Catalog Entry dialog. Click OK again to save your settings.
7. Make sure the XML file is in focus and click the Reload dependencies toolbar button.

The XML file is now associated with the latest version of the XML schema or DTD.

You can also export and import XML Catalog information:

To export, click File > Export and select XML > XML Catalog. You will be prompted to select a project and provide a file name to store your catalog entries in an .xmlcatalog file, which can be opened from the Navigator view. Since your catalog entries are stored in an .xmlcatalog file, you can check them in and out and share them like any other project resource.

To import, click File > Import and select XML > XML Catalog . Then specify the file that will be used to load the XML Catalog settings. When you import a .xmlcatalog file, any entries in it will be loaded into the XML Catalog (and any existing entries will be overwritten).

Related concepts
XML file associations with DTDs and XML schemas
Related tasks
Editing with DTD or XML schema constraints
Editing DOCTYPE declarations
Updating XML files with changes made to DTDs and schemas
Editing namespace information