Class CatalogCollection

All Implemented Interfaces:
ResourceCollection

public class CatalogCollection extends AbstractResourceCollection
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>
 
 
  • Constructor Details Link icon

    • CatalogCollection Link icon

      public CatalogCollection(Configuration config, String collectionURI)
      Create a catalog collection
      Parameters:
      config - the Saxon Configuration
      collectionURI - the collection URI, which represents the location of the catalog file
  • Method Details Link icon

    • getResourceURIs Link icon

      public Iterator<String> getResourceURIs(XPathContext context) throws XPathException
      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 the UnparsedTextURIResolver (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 Link icon

      public Iterator<? extends Resource> getResources(XPathContext context) throws XPathException
      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 Link icon

      public boolean isStable(XPathContext context)
      Description copied from class: AbstractResourceCollection
      Ask whether the collection is stable. This method should only be called after calling ResourceCollection.getResources(XPathContext) or ResourceCollection.getResourceURIs(XPathContext)
      Specified by:
      isStable in interface ResourceCollection
      Overrides:
      isStable in class AbstractResourceCollection
      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 Link icon

      public static String makeStringFromStream(InputStream input, String encoding) throws IOException
      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 Link icon

      protected Iterator<String> catalogContents(String href, XPathContext context) throws XPathException
      Return a collection defined as a list of URIs in a catalog file
      Parameters:
      href - the absolute URI of the catalog file
      context - the dynamic evaluation context
      Returns:
      an iterator over the documents in the collection
      Throws:
      XPathException - if any failures occur