Class DocTypes

java.lang.Object
eu.bandm.tools.doctypes.DocTypes
All Implemented Interfaces:
URIResolver, EntityResolver

public class DocTypes extends Object implements URIResolver, EntityResolver
Used as the carrying class for the java "resource" mechanism, and as an uri and resource resolver. In detail it implements both, URIResolver.resolve(String,String) and EntityResolver.resolveEntity(String,String) A public id (iff present) is matched against this FPI, If not successful, the system id is matched against the URL as given in URI_BANDM_DOCTYPES and URI_HTTP_BANDM_DOCTYPES.

The text which follows these prefices is interpreted as a file position relative to this class file's containing directory, using the JAVA built-in "Resource" mechanism.

  • Field Details

  • Constructor Details

    • DocTypes

      public DocTypes()
  • Method Details

    • resolve

      @Opt public @Opt Source resolve(String href, String base)
      Resolve a request for a resource by matching it against the bandm resource URLs. Defined in javax.xml.transform.URIResolver. Only absolute URIs given as href are resolved. The base is ignored.
      Specified by:
      resolve in interface URIResolver
    • resolve_to_stream

      @Opt public @Opt InputStream resolve_to_stream(URI href)
      FIXME DOC FIXME RAUS use resolve(null,href).getCharacterStream() instead!
    • test_uri

      @Opt protected @Opt InputStream test_uri(String href, String prefix)
      Iff the href begins with the prefix, then return an input stream, else null. The input stream is from the resource with the name of the rest of the href, relative to this class.
    • resolveEntity

      @Opt public @Opt InputSource resolveEntity(@Opt @Opt String publicId, String systemId)
      Matches something like
       PUBLIC "+//IDN bandm.eu//DTD a/b/c/d.dtd//en//1.0" ""
       or 
       PUBLIC "+//IDN bandm.eu//DTD a/b/c/d.dtd//en" ""
       or 
       SYSTEM "http://bandm.eu/doctypes/a/b/c/d.dtd"
        
      and maps it to the resource
           [classtree]/tools/doctypes/Doctypes.getResource(a/b/c/d.dtd)
        
      Defined in org.xml.sax.EntityResolver Please note that only TEXT documents can be retrieved, and their encoding is fixed to "JAVA UTF_8", which is indeed "CESU-8".
      Specified by:
      resolveEntity in interface EntityResolver
      Parameters:
      publicId - if != null it will be decoded as described, and the result must match a resource in the class tree
      systemId - is only considered if publicId==null, and the result must match a resource in the class tree
      Returns:
      null if no bandm-owned resource is meant. In this case the built-in resolver of the parser/caller will make its usual resolution.
      Throws:
      IllegalArgumentException - if the identifier have the prefix of bandm-owned resource ids, but the file ("descriptor") part does not correspond to a reachable resource.
    • xtest_uri

      @Opt protected @Opt InputSource xtest_uri(String href, String prefix)
    • test_fpi

      @Opt protected @Opt InputSource test_fpi(@Opt @Opt String publicId)
    • local2www

      public static XMLDocumentIdentifier local2www(XMLDocumentIdentifier doc)
      currently only the "system" part is analysed and replaced by the www access. (could be stored in the "public" part ?)
    • local2www

      currently only the "system" part is analysed and replaced by the www access. (could be stored in the "public" part ?)
    • emptyDtds

      public static EntityResolver emptyDtds(@Opt @Opt EntityResolver base)
      Suppresses the loading of any DTD by supplying an empty document for any request with the file extension "dtd".
      Parameters:
      base - the Entity resolver to use for all other requests.