org.apache.xml.resolver.tools

Class ResolvingParser

Implemented Interfaces:
DocumentHandler, DTDHandler, EntityResolver, Parser

public class ResolvingParser
extends Object
implements Parser, DTDHandler, DocumentHandler, EntityResolver

A SAX Parser that performs catalog-based entity resolution.

This class implements a SAX Parser that performs entity resolution using the CatalogResolver. The actual, underlying parser is obtained from a SAXParserFactory.

Version:
1.0
Author:
Norman Walsh Norman.Walsh@Sun.COM
See Also:
CatalogResolver, Parser

Field Summary

static boolean
namespaceAware
Make the parser Namespace aware?
static boolean
suppressExplanation
Suppress explanatory message?
static boolean
validating
Make the parser validating?

Constructor Summary

ResolvingParser()
Constructor

Method Summary

void
characters(char[] ch, int start, int length)
SAX DocumentHandler API
void
endDocument()
SAX DocumentHandler API
void
endElement(String name)
SAX DocumentHandler API
Catalog
getCatalog()
Return the Catalog being used
void
ignorableWhitespace(char[] ch, int start, int length)
SAX DocumentHandler API
void
notationDecl(String name, String publicId, String systemId)
SAX DTDHandler API
void
parse(InputSource input)
SAX Parser API

Note that the JAXP 1.1ea2 parser crashes with an InternalError if it encounters a system identifier that appears to be a relative URI that begins with a slash.

void
parse(String systemId)
SAX Parser API
void
processingInstruction(String target, String pidata)
SAX DocumentHandler API
InputSource
resolveEntity(String publicId, String systemId)
Implements the resolveEntity method for the SAX interface, using an underlying CatalogResolver to do the real work.
void
setDTDHandler(DTDHandler handler)
SAX Parser API
void
setDocumentHandler(DocumentHandler handler)
SAX Parser API
void
setDocumentLocator(Locator locator)
SAX DocumentHandler API
void
setEntityResolver(EntityResolver resolver)
SAX Parser API

The purpose of this class is to implement an entity resolver.

void
setErrorHandler(ErrorHandler handler)
SAX Parser API
void
setLocale(Locale locale)
SAX Parser API
void
startDocument()
SAX DocumentHandler API
void
startElement(String name, AttributeList atts)
SAX DocumentHandler API
void
unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
SAX DTDHandler API

Field Details

namespaceAware

public static boolean namespaceAware
Make the parser Namespace aware?

suppressExplanation

public static boolean suppressExplanation
Suppress explanatory message?

validating

public static boolean validating
Make the parser validating?

Constructor Details

ResolvingParser

public ResolvingParser()
Constructor

Method Details

characters

public void characters(char[] ch,
                       int start,
                       int length)
            throws SAXException
SAX DocumentHandler API

endDocument

public void endDocument()
            throws SAXException
SAX DocumentHandler API

endElement

public void endElement(String name)
            throws SAXException
SAX DocumentHandler API

getCatalog

public Catalog getCatalog()
Return the Catalog being used

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
            throws SAXException
SAX DocumentHandler API

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String systemId)
            throws SAXException
SAX DTDHandler API

parse

public void parse(InputSource input)
            throws IOException,
                   SAXException
SAX Parser API

Note that the JAXP 1.1ea2 parser crashes with an InternalError if it encounters a system identifier that appears to be a relative URI that begins with a slash. For example, the declaration:

 <!DOCTYPE book SYSTEM "/path/to/dtd/on/my/system/docbookx.dtd">
 

would cause such an error. As a convenience, this method catches that error and prints an explanation. (Unfortunately, it's not possible to identify the particular system identifier that causes the problem.)

The underlying error is forwarded after printing the explanatory message. The message is only every printed once and if suppressExplanation is set to false before parsing, it will never be printed.


parse

public void parse(String systemId)
            throws IOException,
                   SAXException
SAX Parser API

processingInstruction

public void processingInstruction(String target,
                                  String pidata)
            throws SAXException
SAX DocumentHandler API

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
Implements the resolveEntity method for the SAX interface, using an underlying CatalogResolver to do the real work.

setDTDHandler

public void setDTDHandler(DTDHandler handler)
SAX Parser API

setDocumentHandler

public void setDocumentHandler(DocumentHandler handler)
SAX Parser API

setDocumentLocator

public void setDocumentLocator(Locator locator)
SAX DocumentHandler API

setEntityResolver

public void setEntityResolver(EntityResolver resolver)
SAX Parser API

The purpose of this class is to implement an entity resolver. Attempting to set a different one is pointless (and ignored).


setErrorHandler

public void setErrorHandler(ErrorHandler handler)
SAX Parser API

setLocale

public void setLocale(Locale locale)
            throws SAXException
SAX Parser API

startDocument

public void startDocument()
            throws SAXException
SAX DocumentHandler API

startElement

public void startElement(String name,
                         AttributeList atts)
            throws SAXException
SAX DocumentHandler API

unparsedEntityDecl

public void unparsedEntityDecl(String name,
                               String publicId,
                               String systemId,
                               String notationName)
            throws SAXException
SAX DTDHandler API

Copyright B) 2001 Apache. All Rights Reserved.