org.apache.excalibur.xml.impl
Class JaxpParser

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.excalibur.xml.impl.JaxpParser
All Implemented Interfaces:
org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.parameters.Parameterizable, org.apache.avalon.framework.service.Serviceable, DOMParser, SAXParser, org.xml.sax.ErrorHandler

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

An XMLParser that is only dependant on JAXP 1.1 compliant parsers. The configuration can contain the following parameters :

Version:
CVS $Revision: 1.7 $ $Date: 2004/03/28 18:56:45 $
Author:
Avalon Development Team

Nested Class Summary
private static class JaxpParser.DtdCommentEater
          A LexicalHandler implementation that strips all comment events between startDTD and endDTD.
 
Field Summary
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
           
 
Fields inherited from interface org.apache.excalibur.xml.sax.SAXParser
ROLE
 
Fields inherited from interface org.apache.excalibur.xml.dom.DOMParser
ROLE
 
Constructor Summary
JaxpParser()
           
 
Method Summary
 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.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

private static final org.xml.sax.ContentHandler NULL

m_factory

private javax.xml.parsers.SAXParserFactory m_factory
the SAX Parser factory


m_reader

private org.xml.sax.XMLReader m_reader
The SAX reader. It is created lazily by setupXMLReader() and cleared if a parsing error occurs.


m_resolver

private EntityResolver m_resolver
the Entity Resolver


m_nsPrefixes

private boolean m_nsPrefixes
do we want namespaces also as attributes ?


m_reuseParsers

private boolean m_reuseParsers
do we want to reuse parsers ?


m_stopOnWarning

private boolean m_stopOnWarning
do we stop on warnings ?


m_stopOnRecoverableError

private boolean m_stopOnRecoverableError
do we stop on recoverable errors ?


m_resolverHint

private java.lang.String m_resolverHint
the hint to the entity resolver


m_docFactory

private javax.xml.parsers.DocumentBuilderFactory m_docFactory
the Document Builder factory


m_docBuilder

private javax.xml.parsers.DocumentBuilder m_docBuilder
The DOM builder. It is created lazily by setupDocumentBuilder() and cleared if a parsing error occurs.


m_dropDtdComments

private boolean m_dropDtdComments
Should comments appearing between start/endDTD events be dropped ?


m_manager

private org.apache.avalon.framework.service.ServiceManager m_manager
The serviec manager

Constructor Detail

JaxpParser

public JaxpParser()
Method Detail

service

public void service(org.apache.avalon.framework.service.ServiceManager manager)
             throws org.apache.avalon.framework.service.ServiceException
Get the Entity Resolver from the component m_manager

Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Throws:
org.apache.avalon.framework.service.ServiceException

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

parameterize

public void parameterize(org.apache.avalon.framework.parameters.Parameters params)
                  throws org.apache.avalon.framework.parameters.ParameterException
Specified by:
parameterize in interface org.apache.avalon.framework.parameters.Parameterizable
Throws:
org.apache.avalon.framework.parameters.ParameterException

loadClass

private java.lang.Class loadClass(java.lang.String name)
                           throws java.lang.Exception
Load a class

Throws:
java.lang.Exception

parse

public 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
Parse the InputSource and send SAX events to the consumer. Attention: the consumer can implement the LexicalHandler as well. The parse should take care of this.

Specified by:
parse in interface SAXParser
Throws:
org.xml.sax.SAXException
java.io.IOException

parse

public void parse(org.xml.sax.InputSource in,
                  org.xml.sax.ContentHandler consumer)
           throws org.xml.sax.SAXException,
                  java.io.IOException
Parse the InputSource and send SAX events to the consumer. Attention: the consumer can implement the LexicalHandler as well. The parse should take care of this.

Specified by:
parse in interface SAXParser
Throws:
org.xml.sax.SAXException
java.io.IOException

setupXMLReader

private void setupXMLReader()
                     throws org.xml.sax.SAXException
Creates a new XMLReader if needed.

Throws:
org.xml.sax.SAXException

parseDocument

public org.w3c.dom.Document parseDocument(org.xml.sax.InputSource input)
                                   throws org.xml.sax.SAXException,
                                          java.io.IOException
Parses a new Document object from the given InputSource.

Specified by:
parseDocument in interface DOMParser
Throws:
org.xml.sax.SAXException
java.io.IOException

setupDocumentBuilder

private void setupDocumentBuilder()
                           throws org.xml.sax.SAXException
Creates a new DocumentBuilder if needed.

Throws:
org.xml.sax.SAXException

createDocument

public org.w3c.dom.Document createDocument()
                                    throws org.xml.sax.SAXException
Return a new Document.

Specified by:
createDocument in interface DOMParser
Throws:
org.xml.sax.SAXException

error

public void error(org.xml.sax.SAXParseException spe)
           throws org.xml.sax.SAXException
Receive notification of a recoverable error.

Specified by:
error in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException spe)
                throws org.xml.sax.SAXException
Receive notification of a fatal error.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

warning

public void warning(org.xml.sax.SAXParseException spe)
             throws org.xml.sax.SAXException
Receive notification of a warning.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException