Package net.sf.saxon.resource
Class CatalogCollection
java.lang.Object
net.sf.saxon.resource.AbstractResourceCollection
net.sf.saxon.resource.CatalogCollection
- All Implemented Interfaces:
ResourceCollection
A resource collection implemented by means of a catalog file.
An example catalog file would be:
<collection stable="true">
<doc href="dir/contents.json"/>
<doc href="dir/chap1.xml"/>
<doc href="dir/chap2.xml"/>
<doc href="dir/chap3.xml"/>
<doc href="dir/chap4.xml"/>
<doc href="dir/index.json"/>
</collection>
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.saxon.resource.AbstractResourceCollection
AbstractResourceCollection.InputDetails
-
Field Summary
Fields inherited from class net.sf.saxon.resource.AbstractResourceCollection
collectionURI, config, noExceptions, params
-
Constructor Summary
ConstructorsConstructorDescriptionCatalogCollection
(Configuration config, String collectionURI) Create a catalog collection -
Method Summary
Modifier and TypeMethodDescriptioncatalogContents
(String href, XPathContext context) Return a collection defined as a list of URIs in a catalog filegetResources
(XPathContext context) Get the resources in the collection.getResourceURIs
(XPathContext context) Get the URIs of the resources in the collection.boolean
isStable
(XPathContext context) Ask whether the collection is stable.static String
makeStringFromStream
(InputStream input, String encoding) Return a String initialized to the contents of an InputStreamMethods inherited from class net.sf.saxon.resource.AbstractResourceCollection
checkNotNull, getCollectionURI, getInputDetails, guessContentTypeFromContent, guessContentTypeFromName, makeResource, makeResource, makeTypedResource, optionsFromQueryParameters, registerContentType, setupErrorHandlingForCollection, stripWhitespace
-
Constructor Details
-
Method Details
-
getResourceURIs
Description copied from interface:ResourceCollection
Get the URIs of the resources in the collection. This supports the fn:uri-collection() function. It is not required that all collections expose a list of URIs in this way, or that the URIs bear any particular relationship to the resources returned by the getResources() method for the same collection URI. The URIs that are returned should be suitable for passing to the registered URIResolver (in the case of XML resources), or theUnparsedTextURIResolver
(in the case of unparsed text and JSON resources), etc.- Parameters:
context
- the XPath evaluation context- Returns:
- an iterator over the URIs of the resources in the collection. The URIs are represented as Strings. They should preferably be absolute URIs.
- Throws:
XPathException
- in the event of any error (for example, if the collection URI is not recognized)
-
getResources
Description copied from interface:ResourceCollection
Get the resources in the collection. This supports the fn:collection() function. It is not required that all collections expose a set of resources in this way, or that the resources returned bear any particular relationship to the URIs returned by the getResourceURIs() method for the same collection URI.- Parameters:
context
- the XPath evaluation context- Returns:
- an iterator over the resources in the collection. This returns objects of class
Resource
. - Throws:
XPathException
- in the event of any error (for example, if the collection URI is not recognized)
-
isStable
Description copied from class:AbstractResourceCollection
Ask whether the collection is stable. This method should only be called after callingResourceCollection.getResources(XPathContext)
orResourceCollection.getResourceURIs(XPathContext)
- Specified by:
isStable
in interfaceResourceCollection
- Overrides:
isStable
in classAbstractResourceCollection
- Parameters:
context
- the XPath evaluation context.- Returns:
- true if the collection is defined to be stable, that is, if a subsequent call
on collection() with the same URI is guaranteed to return the same result. The method returns
true if the query parameter stable=yes is present in the URI, or if the configuration property
FeatureKeys.STABLE_COLLECTION_URI
is set.
-
makeStringFromStream
Return a String initialized to the contents of an InputStream- Parameters:
input
- the input stream (which is consumed by this method)encoding
- the character encoding of the input stream- Returns:
- the String, initialized to the contents of this InputStream
- Throws:
IOException
- if an error occurs reading the resource
-
catalogContents
Return a collection defined as a list of URIs in a catalog file- Parameters:
href
- 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
-