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.
-
Create a new folder “Invoice2” in the project “XMLExamples”.
-
Move Invoice.dtd located in XMLExamples\Invoice\ to the new location XMLExamples\Invoice2.
-
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.
-
Select “Window -> Preferences” to launch the Preferences dialog.
-
Expand the “Web and XML” heading and select “XML Catalog”.
The dialog should appear as shown below.
Adding an XML Catalog Entry
-
From the Preferences XML Catalog dialog, select “New…”.
-
In the “New XML Catalog Entry” dialog, fill in the values as they
appear below.
-
Click “OK” to finish. Notice there is a new entry, InvoiceId, under
“User Specified Entries”.
-
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
-
Selecting the “Export…” button on the “Advanced XML Catalog Preferences”
dialog.
-
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
-
Selecting the “Import…” button on the “Advanced XML Catalog Preferences” dialog.
-
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.