|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.apache.xerces.readers.XMLCatalogHandler | +--org.enhydra.apache.xerces.readers.XCatalog
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:
<!DOCTYPE XCatalog PUBLIC "-//DTD XCatalog//EN" "org.enhydra.apache.xerces/readers/xcatalog.dtd">
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:
Inner Class Summary | |
(package private) class |
XCatalog.Parser
Parser for XCatalog document instances. |
Field Summary | |
(package private) static String |
BASE
Base element name ("Base"). |
(package private) static String |
DELEGATE
Delegate element name ("Delegate"). |
(package private) static String |
DTD
XCatalog DTD resource name ("xcatalog.dtd"). |
(package private) static String |
EXTEND
Extend element name ("Extend"). |
(package private) static String |
HREF
HRef attribute name ("HRef"). |
(package private) static String |
MAP
Map element name ("Map"). |
(package private) static String |
PUBLICID
PublicID attribute name ("PublicID"). |
(package private) static String |
REMAP
Remap element name ("Remap"). |
(package private) static String |
SYSTEMID
SystemID attribute name ("SystemID"). |
(package private) static String |
XCATALOG
XCatalog element name ("XCatalog"). |
static String |
XCATALOG_DTD_PUBLICID
XCatalog public identifier string ("-//DTD XCatalog//EN"). |
Constructor Summary | |
XCatalog()
Constructs an XCatalog instance. |
Method Summary | |
void |
addDelegateCatalog(String prefix,
XCatalog catalog)
Adds a delegate mapping. |
XCatalog |
getDelegateCatalog(String prefix)
Returns the catalog for the given delegate prefix. |
Enumeration |
getDelegateCatalogKeys()
Returns an enumeration of delegate prefixes. |
(package private) boolean |
isURL(String str)
Returns true if the string is a valid URL. |
void |
loadCatalog(InputSource source)
Loads the catalog stream specified by the given input source and appends the contents to the catalog. |
void |
removeDelegateCatalog(String prefix)
Removes a delegate. |
InputSource |
resolveEntity(String publicId,
String systemId)
Resolves external entities. |
Methods inherited from class org.enhydra.apache.xerces.readers.XMLCatalogHandler |
addPublicMapping, addSystemMapping, getPublicMapping, getPublicMappingKeys, getSystemMapping, getSystemMappingKeys, removePublicMapping, removeSystemMapping |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final String XCATALOG_DTD_PUBLICID
static final String DTD
static final String XCATALOG
static final String MAP
static final String PUBLICID
static final String HREF
static final String DELEGATE
static final String EXTEND
static final String BASE
static final String REMAP
static final String SYSTEMID
Constructor Detail |
public XCatalog()
Method Detail |
public void loadCatalog(InputSource source) throws SAXException, IOException
loadCatalog
in class XMLCatalogHandler
source
- The catalog source.SAXException
- Throws exception on SAX error.IOException
- Throws exception on i/o error.public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
resolveEntity
in class XMLCatalogHandler
publicId
- The public identifier used for entity resolution.systemId
- If the publicId is not null, this systemId is
to be considered the default system identifier;
else a system identifier alias mapping is
requested.SAXException
- Exception thrown on SAX error.IOException
- Exception thrown on i/o error.public void addDelegateCatalog(String prefix, XCatalog catalog)
This method makes sure that prefixes that match each other are inserted into the delegate list in order of longest prefix length first.
prefix
- The delegate prefix.catalog
- The delegate catalog.public void removeDelegateCatalog(String prefix)
prefix
- The delegate prefix to remove.public Enumeration getDelegateCatalogKeys()
public XCatalog getDelegateCatalog(String prefix)
boolean isURL(String str)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |