net.sf.saxon.functions

Class StandardCollectionURIResolver

public class StandardCollectionURIResolver extends Object implements CollectionURIResolver, MappingFunction

This class implements the default collection URI Resolver.

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:

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>
 
Method Summary
Objectmap(Item item, XPathContext context)
Map from doc elements in the catalogue document to nodes returned in the result
SequenceIteratorresolve(String href, String base, XPathContext context)
Resolve a URI.

Method Detail

map

public Object map(Item item, XPathContext context)
Map from doc elements in the catalogue document to nodes returned in the result

Parameters: item A doc element in the catalogue document context The dynamic evaluation context

Returns: the document or element referenced by the @href attribute of the doc element in the catalogue

Throws: net.sf.saxon.trans.XPathException if the document cannot be retrieved or parsed, unless error recovery has been chosen.

resolve

public SequenceIterator resolve(String href, String base, XPathContext context)
Resolve a URI.

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 module

Returns: an Iterator over the documents in the collection. The items returned by this iterator must implement the NodeInfo interface.

If the URI is not recognized, the method may either return an empty iterator, in which case no error is reported, or it may throw an exception, in which case the query or transformation fails. Returning null has the same effect as returning an empty iterator.