Chapter 5. Configuring 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.
1. Configuring 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.propertiessystem property.The location identified by the
XMLRESOLVER_PROPERTIESenvironment variable.A file named
xmlresolver.propertieson your classpath.
1.1. Example xmlresolver.properties file
An xmlresolver.properties file
might look like this:
1 |# xmlresolver.properties||relative-catalogs=yes|5 |# Always use semicolons in this list|catalogs=./catalog.xml;/Users/ndw/Documents/catalog.xml||prefer=public|allow-oasis-xml-catalog-pi=no10 |prefer-property-file=false
2. Configuring 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.1. Example 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 |}