| java.lang.Object com.sun.org.apache.xml.internal.resolver.readers.DOMCatalogReader
DOMCatalogReader | public class DOMCatalogReader implements CatalogReader(Code) | | A DOM-based CatalogReader.
This class is used to read XML Catalogs using the DOM. This reader
has an advantage over the SAX-based reader that it can analyze the
DOM tree rather than simply a series of SAX events. It has the disadvantage
that it requires all of the code necessary to build and walk a DOM
tree.
Since the choice of CatalogReaders (in the InputStream case) can only
be made on the basis of MIME type, the following problem occurs: only
one CatalogReader can exist for all XML mime types. In order to get
around this problem, the DOMCatalogReader relies on a set of external
CatalogParsers to actually build the catalog.
The selection of CatalogParsers is made on the basis of the QName
of the root element of the document.
This class requires the Java API for XML Parsing.
See Also: Catalog See Also: CatalogReader See Also: SAXCatalogReader See Also: TextCatalogReader See Also: DOMCatalogParser author: Norman Walsh author: Norman.Walsh@Sun.COM version: 1.0 |
Field Summary | |
protected Hashtable | namespaceMap Mapping table from QNames to CatalogParser classes.
Each key in this hash table has the form "elementname"
or "{namespaceuri}elementname". |
Constructor Summary | |
public | DOMCatalogReader() Null constructor; something for subclasses to call. |
Method Summary | |
public String | getCatalogParser(String namespaceURI, String rootElement) Get the name of the parser class for a given catalog type.
This method returns the parserClass associated with the
namespaceURI/rootElement names specified.
Parameters: namespaceURI - The namespace URI. | public void | readCatalog(Catalog catalog, InputStream is) Read a catalog from an input stream.
This class reads a catalog from an input stream:
- Based on the QName of the root element, it determines which
parser to instantiate for this catalog.
- It constructs a DOM Document from the catalog and
- For each child of the root node, it calls the parser's
parseCatalogEntry method.
| public void | readCatalog(Catalog catalog, String fileUrl) Read the catalog behind the specified URL. | public void | setCatalogParser(String namespaceURI, String rootElement, String parserClass) Add a new parser to the reader.
This method associates the specified parserClass with the
namespaceURI/rootElement names specified.
Parameters: namespaceURI - The namespace URI. |
namespaceMap | protected Hashtable namespaceMap(Code) | | Mapping table from QNames to CatalogParser classes.
Each key in this hash table has the form "elementname"
or "{namespaceuri}elementname". The former is used if the
namespace URI is null.
|
DOMCatalogReader | public DOMCatalogReader()(Code) | | Null constructor; something for subclasses to call.
|
getCatalogParser | public String getCatalogParser(String namespaceURI, String rootElement)(Code) | | Get the name of the parser class for a given catalog type.
This method returns the parserClass associated with the
namespaceURI/rootElement names specified.
Parameters: namespaceURI - The namespace URI. Not the prefix. Parameters: rootElement - The name of the root element. The parser class. |
readCatalog | public void readCatalog(Catalog catalog, InputStream is) throws IOException, CatalogException(Code) | | Read a catalog from an input stream.
This class reads a catalog from an input stream:
- Based on the QName of the root element, it determines which
parser to instantiate for this catalog.
- It constructs a DOM Document from the catalog and
- For each child of the root node, it calls the parser's
parseCatalogEntry method. This method is expected to make
appropriate calls back into the catalog to add entries for the
entries in the catalog. It is free to do this in whatever manner
is appropriate (perhaps using just the node passed in, perhaps
wandering arbitrarily throughout the tree).
Parameters: catalog - The catalog for which this reader is called. Parameters: is - The input stream that is to be read. throws: IOException - if the URL cannot be read. throws: UnknownCatalogFormatException - if the catalog format isnot recognized. throws: UnparseableCatalogException - if the catalog cannot be parsed.(For example, if it is supposed to be XML and isn't well-formed orif the parser class cannot be instantiated.) |
setCatalogParser | public void setCatalogParser(String namespaceURI, String rootElement, String parserClass)(Code) | | Add a new parser to the reader.
This method associates the specified parserClass with the
namespaceURI/rootElement names specified.
Parameters: namespaceURI - The namespace URI. Not the prefix. Parameters: rootElement - The name of the root element. Parameters: parserClass - The name of the parserClass to instantiatefor this kind of catalog. |
|
|