Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.xerces.readers
Class XCatalog  view XCatalog download XCatalog.java

java.lang.Object
  extended byorg.apache.xerces.readers.XMLCatalogHandler
      extended byorg.apache.xerces.readers.XCatalog
All Implemented Interfaces:
org.xml.sax.EntityResolver

public class XCatalog
extends XMLCatalogHandler

This catalog supports the XCatalog proposal draft 0.2 posted to the xml-dev mailing list by John Cowan. XCatalog is an XML representation of the SGML Open TR9401:1997 catalog format. The current proposal supports public identifier maps, system identifier aliases, and public identifier prefix delegates. Refer to the XCatalog DTD for the full specification of this catalog format at http://www.ccil.org/~cowan/XML/XCatalog.html.

In order to use XCatalogs, you must write the catalog files with the following restrictions:

To use this catalog in a parser, set an XCatalog instance as the parser's EntityResolver. For example:

   XMLParser parser  = new AnyParser();
   Catalog   catalog = new XCatalog();
   parser.getEntityHandler().setEntityResolver(catalog);
 

Once installed, catalog files that conform to the XCatalog grammar can be appended to the catalog by calling the loadCatalog method on the parser or the catalog instance. The following example loads the contents of two catalog files:

   parser.loadCatalog(new InputSource("catalogs/cat1.xml"));
   parser.loadCatalog(new InputSource("http://host/catalogs/cat2.xml"));
 

Limitations: The following are the current limitations of this XCatalog implementation:

Version:
$Id: XCatalog.java,v 1.3 2000/10/07 18:06:55 markd Exp $

Nested Class Summary
(package private)  class XCatalog.Parser
          Parser for XCatalog document instances.
 
Field Summary
(package private) static java.lang.String BASE
          Base element name ("Base").
private static boolean DEBUG
          Set to true and recompile to include debugging code in class.
private  java.util.Hashtable delegate
          Delegates.
(package private) static java.lang.String DELEGATE
          Delegate element name ("Delegate").
private  java.util.Vector delegateOrder
          Delegates ordering.
(package private) static java.lang.String DTD
          XCatalog DTD resource name ("xcatalog.dtd").
(package private) static java.lang.String EXTEND
          Extend element name ("Extend").
(package private) static java.lang.String HREF
          HRef attribute name ("HRef").
(package private) static java.lang.String MAP
          Map element name ("Map").
(package private) static java.lang.String PUBLICID
          PublicID attribute name ("PublicID").
(package private) static java.lang.String REMAP
          Remap element name ("Remap").
(package private) static java.lang.String SYSTEMID
          SystemID attribute name ("SystemID").
(package private) static java.lang.String XCATALOG
          XCatalog element name ("XCatalog").
static java.lang.String XCATALOG_DTD_PUBLICID
          XCatalog public identifier string ("-//DTD XCatalog//EN").
 
Fields inherited from class org.apache.xerces.readers.XMLCatalogHandler
 
Constructor Summary
XCatalog()
          Constructs an XCatalog instance.
 
Method Summary
 void addDelegateCatalog(java.lang.String prefix, XCatalog catalog)
          Adds a delegate mapping.
 XCatalog getDelegateCatalog(java.lang.String prefix)
          Returns the catalog for the given delegate prefix.
 java.util.Enumeration getDelegateCatalogKeys()
          Returns an enumeration of delegate prefixes.
(package private)  boolean isURL(java.lang.String str)
          Returns true if the string is a valid URL.
 void loadCatalog(org.xml.sax.InputSource source)
          Loads the catalog stream specified by the given input source and appends the contents to the catalog.
 void removeDelegateCatalog(java.lang.String prefix)
          Removes a delegate.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          Resolves external entities.
 
Methods inherited from class org.apache.xerces.readers.XMLCatalogHandler
addPublicMapping, addSystemMapping, getPublicMapping, getPublicMappingKeys, getSystemMapping, getSystemMappingKeys, removePublicMapping, removeSystemMapping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XCATALOG_DTD_PUBLICID

public static final java.lang.String XCATALOG_DTD_PUBLICID
XCatalog public identifier string ("-//DTD XCatalog//EN").

See Also:
Constant Field Values

DTD

static final java.lang.String DTD
XCatalog DTD resource name ("xcatalog.dtd").

See Also:
Constant Field Values

XCATALOG

static final java.lang.String XCATALOG
XCatalog element name ("XCatalog").

See Also:
Constant Field Values

MAP

static final java.lang.String MAP
Map element name ("Map").

See Also:
Constant Field Values

PUBLICID

static final java.lang.String PUBLICID
PublicID attribute name ("PublicID").

See Also:
Constant Field Values

HREF

static final java.lang.String HREF
HRef attribute name ("HRef").

See Also:
Constant Field Values

DELEGATE

static final java.lang.String DELEGATE
Delegate element name ("Delegate").

See Also:
Constant Field Values

EXTEND

static final java.lang.String EXTEND
Extend element name ("Extend").

See Also:
Constant Field Values

BASE

static final java.lang.String BASE
Base element name ("Base").

See Also:
Constant Field Values

REMAP

static final java.lang.String REMAP
Remap element name ("Remap").

See Also:
Constant Field Values

SYSTEMID

static final java.lang.String SYSTEMID
SystemID attribute name ("SystemID").

See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG
Set to true and recompile to include debugging code in class.

See Also:
Constant Field Values

delegate

private java.util.Hashtable delegate
Delegates.


delegateOrder

private java.util.Vector delegateOrder
Delegates ordering.

Constructor Detail

XCatalog

public XCatalog()
Constructs an XCatalog instance.

Method Detail

loadCatalog

public void loadCatalog(org.xml.sax.InputSource source)
                 throws org.xml.sax.SAXException,
                        java.io.IOException
Loads the catalog stream specified by the given input source and appends the contents to the catalog.

Specified by:
loadCatalog in class XMLCatalogHandler

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException,
                                             java.io.IOException
Resolves external entities.

Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class XMLCatalogHandler

addDelegateCatalog

public void addDelegateCatalog(java.lang.String prefix,
                               XCatalog catalog)
Adds a delegate mapping. If the prefix of a public identifier matches a delegate prefix, then the delegate catalog is searched in order to resolve the identifier.

This method makes sure that prefixes that match each other are inserted into the delegate list in order of longest prefix length first.


removeDelegateCatalog

public void removeDelegateCatalog(java.lang.String prefix)
Removes a delegate.


getDelegateCatalogKeys

public java.util.Enumeration getDelegateCatalogKeys()
Returns an enumeration of delegate prefixes.


getDelegateCatalog

public XCatalog getDelegateCatalog(java.lang.String prefix)
Returns the catalog for the given delegate prefix.


isURL

boolean isURL(java.lang.String str)
Returns true if the string is a valid URL.