Nux 1.6

nux.xom.pool
Interface DocumentURIResolver


public interface DocumentURIResolver

Called by the XQuery processor to turn a URI passed to the XQuery doc() function into a XOM Document object.

This interface allows to intercept and customize URI resolution. For example here one can plugin XML schema validation, constraint checking, XIncluder, streaming path filters such as StreamingPathFilter, other preprocessing steps, and/or document caching (e.g. using BinaryXMLCodec with DocumentPool, EHCache, OSCache or similar products).

Via a ResourceResolver one might also read a document from the web, a classpath, a jar file, a war file, a JDBC database, a JNDI context/data source, or similar.

This callback interface is just like the URIResolverinterface, except that it returns a Document instead of a Source object.

For example, a simple implementation could look like this:

     String systemID = new net.sf.saxon.StandardURIResolver().resolve(href, baseURI).getSystemId();
     return BuilderPool.GLOBAL_POOL.getBuilder(false).build(systemID);
     //return BuilderPool.GLOBAL_POOL.getW3CBuilder(...).build(systemID);
 
     // a variant using a document pool:
     String systemID = new net.sf.saxon.StandardURIResolver().resolve(href, baseURI).getSystemId();
     return DocumentPool.GLOBAL_POOL.getDocument(new URI(systemID));
 

Author:
whoschek.AT.lbl.DOT.gov, $Author: hoschek3 $

Method Summary
 Document resolve(String href, String baseURI)
          Called by the XQuery processor when it encounters a doc() function.
 

Method Detail

resolve

Document resolve(String href,
                 String baseURI)
                 throws ParsingException,
                        IOException,
                        TransformerException
Called by the XQuery processor when it encounters a doc() function.

Parameters:
href - An href attribute, which may be relative or absolute.
baseURI - The (absolute) base URI in effect when the href attribute was encountered.
Returns:
A Document object, or null if the href cannot be resolved and the processor should try to resolve the URI itself.
Throws:
ParsingException - if an error occurs when trying to resolve the URI.
IOException - if an error occurs when trying to resolve the URI.
TransformerException - if an error occurs when trying to resolve the URI.

Nux 1.6