public final class JaxpParser extends org.apache.avalon.framework.logger.AbstractLogEnabled implements SAXParser, DOMParser, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.framework.parameters.Parameterizable, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.activity.Disposable, org.xml.sax.ErrorHandler, org.apache.avalon.framework.component.Component
false) : should the parser
validate parsed documents ?
false) : do we want
namespaces declarations also as 'xmlns:' attributes ?true confuses some XSL
processors (e.g. Saxon).
true) : should the parser
stop parsing if a warning occurs ?
true) : should the parser
stop parsing if a recoverable error occurs ?
true) : do we want to reuse
parsers or create a new parser for each parse ?true, parsers are not
recycled in case of parsing errors : some parsers (e.g. Xerces) don't like
to be reused after failure.
SAXParserFactory
implementation class to be used instead of using the standard JAXP mechanism
(SAXParserFactory.newInstance()). This allows to choose
unambiguously the JAXP implementation to be used when several of them are
available in the classpath.
| Modifier and Type | Class and Description |
|---|---|
private static class |
JaxpParser.DtdCommentEater
A LexicalHandler implementation that strips all comment events between
startDTD and endDTD.
|
| Modifier and Type | Field and Description |
|---|---|
private javax.xml.parsers.DocumentBuilder |
m_docBuilder
The DOM builder.
|
private javax.xml.parsers.DocumentBuilderFactory |
m_docFactory
the Document Builder factory
|
private boolean |
m_dropDtdComments
Should comments appearing between start/endDTD events be dropped ?
|
private javax.xml.parsers.SAXParserFactory |
m_factory
the SAX Parser factory
|
private org.apache.avalon.framework.service.ServiceManager |
m_manager
The serviec manager
|
private boolean |
m_nsPrefixes
do we want namespaces also as attributes ?
|
private org.xml.sax.XMLReader |
m_reader
The SAX reader.
|
private EntityResolver |
m_resolver
the Entity Resolver
|
private java.lang.String |
m_resolverHint
the hint to the entity resolver
|
private boolean |
m_reuseParsers
do we want to reuse parsers ?
|
private boolean |
m_stopOnRecoverableError
do we stop on recoverable errors ?
|
private boolean |
m_stopOnWarning
do we stop on warnings ?
|
private static org.xml.sax.ContentHandler |
NULL |
| Constructor and Description |
|---|
JaxpParser() |
| Modifier and Type | Method and Description |
|---|---|
org.w3c.dom.Document |
createDocument()
Return a new
Document. |
void |
dispose() |
void |
error(org.xml.sax.SAXParseException spe)
Receive notification of a recoverable error.
|
void |
fatalError(org.xml.sax.SAXParseException spe)
Receive notification of a fatal error.
|
private java.lang.Class |
loadClass(java.lang.String name)
Load a class
|
void |
parameterize(org.apache.avalon.framework.parameters.Parameters params) |
void |
parse(org.xml.sax.InputSource in,
org.xml.sax.ContentHandler consumer)
Parse the
InputSource and send
SAX events to the consumer. |
void |
parse(org.xml.sax.InputSource in,
org.xml.sax.ContentHandler contentHandler,
org.xml.sax.ext.LexicalHandler lexicalHandler)
Parse the
InputSource and send
SAX events to the consumer. |
org.w3c.dom.Document |
parseDocument(org.xml.sax.InputSource input)
Parses a new Document object from the given InputSource.
|
void |
service(org.apache.avalon.framework.service.ServiceManager manager)
Get the Entity Resolver from the component m_manager
|
private void |
setupDocumentBuilder()
Creates a new
DocumentBuilder if needed. |
private void |
setupXMLReader()
Creates a new
XMLReader if needed. |
void |
warning(org.xml.sax.SAXParseException spe)
Receive notification of a warning.
|
private static final org.xml.sax.ContentHandler NULL
private javax.xml.parsers.SAXParserFactory m_factory
private org.xml.sax.XMLReader m_reader
setupXMLReader()
and cleared if a parsing error occurs.private EntityResolver m_resolver
private boolean m_nsPrefixes
private boolean m_reuseParsers
private boolean m_stopOnWarning
private boolean m_stopOnRecoverableError
private java.lang.String m_resolverHint
private javax.xml.parsers.DocumentBuilderFactory m_docFactory
private javax.xml.parsers.DocumentBuilder m_docBuilder
setupDocumentBuilder()
and cleared if a parsing error occurs.private boolean m_dropDtdComments
private org.apache.avalon.framework.service.ServiceManager m_manager
public void service(org.apache.avalon.framework.service.ServiceManager manager)
throws org.apache.avalon.framework.service.ServiceException
service in interface org.apache.avalon.framework.service.Serviceableorg.apache.avalon.framework.service.ServiceExceptionpublic void dispose()
dispose in interface org.apache.avalon.framework.activity.Disposablepublic void parameterize(org.apache.avalon.framework.parameters.Parameters params)
throws org.apache.avalon.framework.parameters.ParameterException
parameterize in interface org.apache.avalon.framework.parameters.Parameterizableorg.apache.avalon.framework.parameters.ParameterExceptionprivate java.lang.Class loadClass(java.lang.String name)
throws java.lang.Exception
java.lang.Exceptionpublic void parse(org.xml.sax.InputSource in,
org.xml.sax.ContentHandler contentHandler,
org.xml.sax.ext.LexicalHandler lexicalHandler)
throws org.xml.sax.SAXException,
java.io.IOException
InputSource and send
SAX events to the consumer.
Attention: the consumer can implement the
LexicalHandler as well.
The parse should take care of this.public void parse(org.xml.sax.InputSource in,
org.xml.sax.ContentHandler consumer)
throws org.xml.sax.SAXException,
java.io.IOException
InputSource and send
SAX events to the consumer.
Attention: the consumer can implement the
LexicalHandler as well.
The parse should take care of this.private void setupXMLReader()
throws org.xml.sax.SAXException
XMLReader if needed.org.xml.sax.SAXExceptionpublic org.w3c.dom.Document parseDocument(org.xml.sax.InputSource input)
throws org.xml.sax.SAXException,
java.io.IOException
parseDocument in interface DOMParserorg.xml.sax.SAXExceptionjava.io.IOExceptionprivate void setupDocumentBuilder()
throws org.xml.sax.SAXException
DocumentBuilder if needed.org.xml.sax.SAXExceptionpublic org.w3c.dom.Document createDocument()
throws org.xml.sax.SAXException
Document.createDocument in interface DOMParserorg.xml.sax.SAXExceptionpublic void error(org.xml.sax.SAXParseException spe)
throws org.xml.sax.SAXException
error in interface org.xml.sax.ErrorHandlerorg.xml.sax.SAXExceptionpublic void fatalError(org.xml.sax.SAXParseException spe)
throws org.xml.sax.SAXException
fatalError in interface org.xml.sax.ErrorHandlerorg.xml.sax.SAXExceptionpublic void warning(org.xml.sax.SAXParseException spe)
throws org.xml.sax.SAXException
warning in interface org.xml.sax.ErrorHandlerorg.xml.sax.SAXException