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 Detail

      • CatalogCollection

        public CatalogCollection​(Configuration config,
                                 java.lang.String collectionURI)
        Create a catalog collection
        Parameters:
        config - the Saxon Configuration
        collectionURI - the collection URI, which represents the location of the catalog file
    • Method Detail

      • getResourceURIs

        public java.util.Iterator<java.lang.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

        public java.util.Iterator<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)
      • makeStringBuilderFromStream

        public static java.lang.StringBuilder makeStringBuilderFromStream​(java.io.InputStream in,
                                                                          java.lang.String encoding)
                                                                   throws java.io.IOException
        Return a StringBuilder initialized to the contents of an InputStream
        Parameters:
        in - the input stream (which is consumed by this method)
        Returns:
        the StringBuilder, initialized to the contents of this InputStream
        Throws:
        java.io.IOException - if an error occurs reading the resource
      • catalogContents

        protected java.util.Iterator<java.lang.String> catalogContents​(java.lang.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