Class AbstractResourceCollection

  • All Implemented Interfaces:
    ResourceCollection
    Direct Known Subclasses:
    CatalogCollection, DirectoryCollection, JarCollection

    public abstract class AbstractResourceCollection
    extends Object
    implements ResourceCollection
    AbstractCollection is an abstract superclass for the various implementations of ResourceCollection within Saxon. It provides common services such as mapping of file extensions to MIME types, and mapping of MIME types to resource factories.
    • Constructor Detail

      • AbstractResourceCollection

        public AbstractResourceCollection​(Configuration config)
    • Method Detail

      • getCollectionURI

        public String getCollectionURI()
        Description copied from interface: ResourceCollection
        Get the URI of the collection
        Specified by:
        getCollectionURI in interface ResourceCollection
        Returns:
        The URI as passed to the fn:collection() or fn:uri-collection() function, resolved if it is relative against the static base URI. If the collection() or uri-collection() function was called with no arguments (to get the "default collection") this will be the URI of the default collection registered with the Configuration.
      • registerContentType

        public void registerContentType​(String contentType,
                                        ResourceFactory factory)
        Associate a media type with a resource factory. Since 9.7.0.6 this registers the content type with the configuration, making the register of content types more accessible to applications.
        Parameters:
        contentType - a media type or MIME type, for example application/xsd+xml
        factory - a ResourceFactory used to parse (or otherwise process) resources of that type
      • guessContentTypeFromName

        protected String guessContentTypeFromName​(String resourceURI)
      • guessContentTypeFromContent

        protected String guessContentTypeFromContent​(InputStream stream)
      • makeResource

        public Resource makeResource​(Configuration config,
                                     AbstractResourceCollection.InputDetails details)
                              throws XPathException
        Internal method to make a resource for a single entry in the ZIP or JAR file. This involves making decisions about the type of resource. This method can be overridden in a user-defined subclass.
        Parameters:
        config - The Saxon configuration
        details - Details of the input.
        Returns:
        a newly created Resource representing the content of this entry in the ZIP or JAR file
        Throws:
        XPathException
      • stripWhitespace

        public boolean stripWhitespace​(SpaceStrippingRule rules)
        Supply information about the whitespace stripping rules that apply to this collection. This method will only be called when the collection() function is invoked from XSLT.
        Specified by:
        stripWhitespace in interface ResourceCollection
        Parameters:
        rules - the space-stripping rules that apply to this collection, derived from the xsl:strip-space and xsl:preserve-space declarations in the stylesheet package containing the call to the collection() function.
        Returns:
        true if the collection finder intends to take responsibility for whitespace stripping according to these rules; false if it wishes Saxon itself to post-process any returned XML documents to strip whitespace. Returning true may either indicate that the collection finder will strip whitespace before returning a document, or it may indicate that it does not wish the space stripping rules to be applied. The default (returned by this method if not overridden) is false.