Class FSCatalog
- java.lang.Object
-
- com.openhtmltopdf.resource.FSCatalog
-
public class FSCatalog extends java.lang.Object
FSCatalog loads an XML catalog file to read mappings of public IDs for XML schemas/dtds, to resolve those mappings to a local store for the schemas. The catalog file allows one to have a single mapping of schema IDs to local files, and is useful when there are many schemas, or when schemas are broken into many smaller files. Currently FSCatalog only supports the very simple mapping of public id to local URI using the public element in the catalog XML.
FSCatalog is not an EntityResolver; it only parses a catalog file. See
FSEntityResolver
for entity resolution.To use, instantiate the class, and call
parseCatalog(InputSource)
to retrieve aMap
keyed by public ids. The class uses an XMLReader instance retrieved viaXMLResource.newXMLReader()
, so XMLReader configuration (and specification) follows that of the standard XML parsing in Flying Saucer.This class is not safe for multi-threaded access.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
FSCatalog.CatalogContentHandler
A SAX ContentHandler that reads an XML catalog file and builds a Map of public IDs to local URIs.
-
Constructor Summary
Constructors Constructor Description FSCatalog()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addHandlers(org.xml.sax.XMLReader xmlReader, org.xml.sax.ContentHandler ch)
Adds the default EntityResolved and ErrorHandler for the SAX parser.java.util.Map<java.lang.String,java.lang.String>
parseCatalog(java.lang.String catalogURI)
Parses an XML catalog file and returns a Map of public ids to local URIs read from the catalog.java.util.Map<java.lang.String,java.lang.String>
parseCatalog(org.xml.sax.InputSource inputSource)
Parses an XML catalog file and returns a Map of public ids to local URIs read from the catalog.private void
setFeature(org.xml.sax.XMLReader xmlReader, java.lang.String featureUri, boolean value)
Attempts to set requested feature on the parser; logs exception if not supported or not recognized.
-
-
-
Method Detail
-
parseCatalog
public java.util.Map<java.lang.String,java.lang.String> parseCatalog(java.lang.String catalogURI)
Parses an XML catalog file and returns a Map of public ids to local URIs read from the catalog. Only the catalog public elements are parsed.- Parameters:
catalogURI
- A String URI to a catalog XML file on the classpath.
-
parseCatalog
public java.util.Map<java.lang.String,java.lang.String> parseCatalog(org.xml.sax.InputSource inputSource)
Parses an XML catalog file and returns a Map of public ids to local URIs read from the catalog. Only the catalog public elements are parsed.- Parameters:
inputSource
- A SAX InputSource to a catalog XML file on the classpath.
-
addHandlers
private void addHandlers(org.xml.sax.XMLReader xmlReader, org.xml.sax.ContentHandler ch)
Adds the default EntityResolved and ErrorHandler for the SAX parser.
-
setFeature
private void setFeature(org.xml.sax.XMLReader xmlReader, java.lang.String featureUri, boolean value)
Attempts to set requested feature on the parser; logs exception if not supported or not recognized.
-
-