Using Catalogs with NIEM

It is sometimes necessary to specify an alternate schema file for a particular namespace. For example, when one of the NIEM subset schemas must be modified. Directly altering the NIEM subset schema is not a good idea because it may be regenerated during the development process. This would require the modifications to be reapplied each time a new NIEM subset is generated. When this is the case, a new version of the schema that must be modified should be stored outside of the NIEM subset directory.

One way to specify an alternate schema location, without modifying the existing schemas, is through an XML catalog. With a catalog, a different schema location can be assigned, for a particular namespace, that will overrule import statements for that namespace.

As an example, refer to the FarmersMarket IEPD. This IEPD has an alternate schema for the GML namespace that should be used whenever EXI is used to encode the FarmersMarket instances. FarmersMarket-IEPD/exi- xsd/gml.xsd is a subset of the GML schemas and has only the GML components needed for the FarmersMarket IEPD as well as modifications. FarmersMarket-IEPD/exi-xsd/exi-xml-catalog.xml is a simple XML catalog file that can be used point occurences of the GML namespace to gml.xsd. This is done by using the following element:

<uri name="http://www.opengis.net/gml/3.2" uri=</font>"./gml.xsd"/>

The name attribute is the namespace as it appears in the IEPD schemas. The uri attribute is the relative path of the schema file.


How to redifine a schema location using a catalog file

Step 1: Create, or determine, the alternate schema to be assgned to the namespace

  • The alternate schema used in this example is FarmersMarket-IEPD\exi-xsd\gml.xsd</li>
  • It is a subset of the GML schemas found in FarmersMarket-IEPD\base-xsd\niem\external\ogc\gml\

Step 2: Create a catalog XML instance

  1. Open a text editor and create the base catalog instance, the example below can be pasted directly into the text editor.
  2. <?xml version="1.0" encoding="US-ASCII"?>
    <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
    <catalog prefer="public" xmlns="urn:oasis:namestc:en:tity:xmlns:xml:catalog">
        
    </catalog>

  3. Add the uri element with the attribute name set to the namespace and the attribute uri set to the path of the alternate schema. This path should be relative to the location of the catalog file. In this example the catalog file and the alternate schema are in the same directory. The example below shows what the final catalog file should look like.
  4. <?xml version="1.0" encoding="US-ASCII"?>
    <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
    <catalog prefer="public" xmlns="urn:oasis:namestc:en:tity:xmlns:xml:catalog">
    
    	<uri name="http://www.opengis.net/gml/3.2" uri=</font>"./gml.xsd"/>
        
    </catalog>
    </p>

This catalog file can now be used to redirect any occurrence of the GML namespace (“http://www.opengis.net/gml/3.2”) to the alternate schema.


How to load a custom catalog file into XMLSpy</a>

Step 1: Locate CustomCatalogs.xml and open in a text editor

  • With XMLSpy 2015 this is located in MyDocuments\Altova\XMLSpy

Step 2: Add nextCatalog element to CustomCatalogs.xml, as shown in the example below.

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v5 beta 1 U (http://www.xmlspy.com) by Vladislav Gavrielov (Altova) -->
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:entity:xmlns:xml:catalog
Catalog.xsd">

<nextCatalog catalog="C:\GTRI\NIEM\FarmersMarket-IEPD\exi-xsd\exi-xml-catalog.xml"</u>/>
    
</catalog>

Step 3: Start XMLSpy

  • If it is already running, restart XMLSpy

Step 4: Import IEPD into XMLSpy

  1. Create a new project
  2. Import the IEPD: "Project->Add External Folder to Project..."

Step 5: Verify that the alternate schema is loaded

  1. Open "FarmersMarket-IEPD\base-xsd\niem\adapters\geospatial\3.0\geospatial.xsd"
  2. Click the browse tree button to the left of the PointType definition as shown in the image below.

  3. Browser Tree Button


  4. Right click the gml:Point node and select "Go To Definition" as shown in image below. The modified gml.xsd schema should open.

  5. Dropdown

  6. Hover the mouse cursor over the gml.xsd tab to show the full path. The displayed path should match the alternate schema path defined in exi-xml-catalog.

  7. Schema path defined </ol> Note: This process will redirect the namespace schema location for all schemas used in XMLSpy, not just those in this example.


    Related Links

    Altova Online Help: Catalogs in XMLSpy
    OASIS XML Catalogs Standard