Chapter 5Configuring an XML Resolver

The XML Resolver is available for both Java and .NET. By and large, it works the same way in both environments and has similar features. One area where differences are unavoidable is in configuration because Java and .NET expose different mechanisms.

The Java XML Resolver classes use either Java system properties or a standard Java properties file to establish an initial environment.

On .NET, environment variables are used instead of system properties and the properties file is a standard .NET configuration file.

1Configuring XML Resolver on Java

On Java, the resolver searches for a property file by looking in the following places, in this order:

  • The location identified by the xmlresolver.properties system property.

  • The location identified by the XMLRESOLVER_PROPERTIES environment variable.

  • A file named xmlresolver.properties on your classpath.

1.1Example xmlresolver.properties file

An xmlresolver.properties file might look like this:

 1 |## XML Resolver properties
   | 
   |## Specify protocol(s) allowed for URI access
   |#access-external-document=all
 5 | 
   |## Specify protocol(s) allowed for entity access
   |#access-external-entity=all
   | 
   |## Obey oasis-xml-catalog processing instruction?
10 |#allow-oasis-xml-catalog-pi=true
   | 
   |## Always resolve resources?
   |#always-resolve=true
   | 
15 |## Support catalog files in ZIP archives?
   |#archived-catalogs=true
   | 
   |## List of additional catalog files; defaults to none
   |#catalog-additions=
20 | 
   |## Catalog loader class
   |#catalog-loader-class=org.xmlresolver.loaders.XmlLoader
   | 
   |## The initial list of catalog files; defaults to none
25 |#catalogs=
   | 
   |## Load catalogs from the classpath?
   |#classpath-catalogs=true
   | 
30 |## Fix system identifiers on Windows?
   |#fix-windows-system-identifiers=false
   | 
   |## The logging level
   |#logger-log-level=warn
35 | 
   |## Mask jar URIs?
   |#mask-jar-uris=true
   | 
   |## Merge http: and https: URI schemes?
40 |#merge-https=true
   | 
   |## Parse RDDL documents?
   |#parse-rddl=false
   | 
45 |## Prefer property file values
   |#prefer-property-file=false
   | 
   |## Preference for public or system identifiers
   |#prefer=public
50 | 
   |## Support relative catalog paths
   |#relative-catalogs=true
   | 
   |## The logger class
55 |#resolver-logger-class=org.xmlresolver.logging.DefaultLogger
   | 
   |## The SAX parser factory class; defaults to null
   |#saxparserfactory-class=
   | 
60 |## Throw URI exceptions?
   |#throw-uri-exceptions=false
   | 
   |## Use URI entries for system resolution?
   |#uri-for-system=true

The properites are shown with their default values.

2Configuring XML Resolver on .NET

On .NET, the resolver uses the enviornment variable XMLRESOLVER_APPSETTINGS to locate .NET properties file. The properties file can be either XML (in an XmlResolver section) or JSON (in an XmlResolver object).

2.1Example xmlresolver.config file

An xmlresolver.config file might look like this:

1 |<configuration>
  |  <xmlResolver relativeCatalogs="no"
  |               catalogs="./catalog.xml;/Users/userid/Documents/catalog.xml"
  |               prefer="public"
5 |               allowOasisXmlCatalogPi="yes"
  |               preferPropertyFile="no"/>
  |</configuration>

If JSON is more convenient, it might look like this:

 1 |{
   |  "XmlResolver": {
   |    "preferPublic": true,
   |    "relativeCatalogs": "false",
 5 |    "catalogs": "./catalog.xml;/Users/userid/Documents/catalog.xml",
   |    "prefer": "public",
   |    "allowOasisXmlCatalogPi": "yes",
   |    "preferPropertyFile": "no"
   |  }
10 |}