Package net.sf.saxon.resource
Class StandardCollectionFinder
java.lang.Object
net.sf.saxon.resource.StandardCollectionFinder
- All Implemented Interfaces:
CollectionFinder
Default implementation of the CollectionFinder interface. The standard CollectionFinder recognizes four
types of collection:
- Any URI may be explicitly registered and associated with an instance of
ResourceCollection
- If the file: URI scheme is used, and the relevant file identifies a directory, the directory
is treated as a collection: it is returned as an instance of
DirectoryCollection
- If the URI ends with ".jar" or ".zip", or more generally, if the method
isJarFileURI(String)
returns true, the URI is treated as identifying a JAR or ZIP archive, whose contents form the resources in the collection: it is returned as an instance ofJarCollection
- In all other cases, the URI is treated as the URI of an XML document listing the URIs
of the resources in the collection, which are then retrieved using the
URIResolver
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkFileExists
(File file, URI resolvedURI, XPathContext context) findCollection
(XPathContext context, String collectionURI) Locate the collection of resources corresponding to a collection URI.protected boolean
isJarFileURI
(String collectionURI) Ask whether the collection URI should be interpreted as identifying a JAR (or ZIP) file.
-
Constructor Details
-
StandardCollectionFinder
public StandardCollectionFinder()
-
-
Method Details
-
findCollection
public ResourceCollection findCollection(XPathContext context, String collectionURI) throws XPathException Locate the collection of resources corresponding to a collection URI.- Specified by:
findCollection
in interfaceCollectionFinder
- Parameters:
context
- The XPath dynamic evaluation contextcollectionURI
- The collection URI: an absolute URI, formed by resolving the argument supplied to the fn:collection or fn:uri-collection against the static base URI- Returns:
- a ResourceCollection object representing the resources in the collection identified by this collection URI
- Throws:
XPathException
- if the collection URI cannot be resolved to a collection
-
isJarFileURI
Ask whether the collection URI should be interpreted as identifying a JAR (or ZIP) file. This method is provided so that it can be overridden in subclasses. The default implementation returns true if the collection URI ends with the extension ".jar", ".zip", or ".docx", or if it is a URI using the "jar" scheme.The set of URIs recognized as ZIP collections can also be extended by setting the configuration property
Feature.ZIP_URI_PATTERN
.- Parameters:
collectionURI
- the requested absolute collection URI- Returns:
- true if the collection URI should be interpreted as a JAR or ZIP file
-
checkFileExists
public static void checkFileExists(File file, URI resolvedURI, XPathContext context) throws XPathException - Throws:
XPathException
-