Class StandardCollectionURIResolver
- All Implemented Interfaces:
CollectionURIResolver
This supports two implementations of collections. If the URI supplied uses the "file:/" scheme, and the file that is referenced is a directory, then the collection is the set of files in that directory. Query parameters may be included in the URI:
recurse=yes|no controls whether the directory is scanned recursively;
strip-space=yes|no determines whether whitespace text nodes are stripped from the selected documents;
validation=strict|lax|preserve|strip determines whether schema validation is applied;
select=pattern determines which files in the directory are selected.
on-error=fail|warn|ignore determines the action taken if processing of a file fails
parser=qualified.class.name selects the parser (XMLReader) to be used to read the files
Otherwise, the resolver attempts to dereference the URI to obtain a catalog file. This is an XML file containing a list of documents, in the format:
<collection> <doc href="doc1.xml"/> <doc href="doc2.xml"/> </collection>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classMapping function to process the files in a directory. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SequenceIterator<?>catalogContents(String href, String baseURI, String absURI, XPathContext context) Return a collection defined as a list of URIs in a catalog filestatic voidcheckFileExists(File file, URI resolvedURI, XPathContext context) protected SequenceIterator<?>directoryContents(File directory, URIQueryParameters params, XPathContext context) Return the contents of a collection that maps to a directory in filestoreprotected URImakeAbsoluteURI(String href, String base, XPathContext context, URI relativeURI) resolve(String href, String base, XPathContext context) Resolve a URI.
-
Constructor Details
-
StandardCollectionURIResolver
public StandardCollectionURIResolver()
-
-
Method Details
-
resolve
public SequenceIterator<?> resolve(String href, String base, XPathContext context) throws XPathException Resolve a URI.- Specified by:
resolvein interfaceCollectionURIResolver- Parameters:
href- The relative URI of the collection. This corresponds to the argument supplied to the collection() function. If the collection() function was called with no arguments (to get the "default collection") this argument will be null.base- The base URI that should be used. This is the base URI of the static context in which the call to collection() was made, typically the URI of the stylesheet or query modulecontext- The dynamic execution context- Returns:
- an Iterator over the documents in the collection. The items returned
by this iterator must be instances either of xs:anyURI, or of node() (specifically,
NodeInfo.). If xs:anyURI values are returned, the corresponding document will be retrieved as if by a call to the doc() function: this means that the system first checks to see if the document is already loaded, and if not, calls the registered URIResolver to dereference the URI. This is the recommended approach to ensure that the resulting collection is stable: however, it has the consequence that the documents will by default remain in memory for the duration of the query or transformation. - Throws:
XPathException- if any failure occurs
-
checkFileExists
public static void checkFileExists(File file, URI resolvedURI, XPathContext context) throws XPathException - Throws:
XPathException
-
makeAbsoluteURI
protected URI makeAbsoluteURI(String href, String base, XPathContext context, URI relativeURI) throws XPathException - Throws:
XPathException
-
directoryContents
protected SequenceIterator<?> directoryContents(File directory, URIQueryParameters params, XPathContext context) Return the contents of a collection that maps to a directory in filestore- Parameters:
directory- the directory to be processedparams- parameters indicating whether to process recursively, what to do on errors, and which files to selectcontext- the dynamic XPath evaluation context- Returns:
- an iterator over the documents in the collection
-
catalogContents
protected SequenceIterator<?> catalogContents(String href, String baseURI, String absURI, XPathContext context) throws XPathException Return a collection defined as a list of URIs in a catalog file- Parameters:
href- the relative URI as suppliedbaseURI- the base URIabsURI- the absolute URI of the catalog filecontext- the dynamic evaluation context- Returns:
- an iterator over the documents in the collection
- Throws:
XPathException- if any failures occur
-