Resolving URIs in JOMDoc
The code that handles the resolving of URI references can be found in the org.omdoc.jomdoc.util.resolver package.
JOMDocURIResolver
The JOMDocURIResolver interface is used in JOMDoc for resolving URI references. A (possibly incomplete) list of classes in which resolvers are used:
- ImportsAware
- ContentDictionary
- RenderingSorter
- VariantSorter
- Tag
- RefContractor
- NtnUtil
- RelaxNGValidator
- XSLTUtil
DefaultJOMDocURIResolver
By default JOMDoc uses DefaultJOMDocURIResolver. This is a default implementaion of JOMDocURIResolver which resolves local filesystem and http resources.
AbstractJOMDocURIResolver
Systems using JOMDoc might require that URIs are resolved differently then in the DefaultJOMDocURIResolver. Normally they would extend AbstractJOMDocURIResolver and implement these methods according to their requirements:
/** * @return a pair (A, B) where A is InputStream to location <code>href</code> * with respect to <code>base</code>, and B is the absolute URI to A. */ Pair<InputStream, URI> resolveInputStream(String href, String base) throws ResolveException; /** * @return the content at location <code>href</code> with respect to <code>base</code> * as XOM Document. */ Document resolveDocument(String href, String base) throws ResolveException;
Then the custom JOMDocURIResolver should be set wherever needed in JOMDoc.
JOMDocURIResolvers
JOMDocURIResolvers can be used to set several resolvers that will be used in turn until one of them successfully resolves the resource. The resolvers are executed in the order in which they are added to the JOMDocURIResolvers. So usually external users could add first their custom resolver, and then also DefaultJOMDocURIResolver as a fallback.
