org.apache.cocoon.core.xml.impl
Class JaxpSAXParser

java.lang.Object
  extended byorg.apache.cocoon.core.xml.impl.AbstractJaxpParser
      extended byorg.apache.cocoon.core.xml.impl.JaxpSAXParser
All Implemented Interfaces:
BeanFactoryAware, ErrorHandler, org.apache.cocoon.core.xml.SAXParser

public final class JaxpSAXParser
extends AbstractJaxpParser
implements org.apache.cocoon.core.xml.SAXParser, ErrorHandler

A SAX parser which uses a JAXP 1.1 compliant parsers.

Since:
2.2
Version:
$Id: JaxpSAXParser.html 1304280 2012-03-23 11:18:01Z ilgrosso $
See Also:
AbstractJaxpParser

Nested Class Summary
protected static class JaxpSAXParser.DtdCommentEater
          A LexicalHandler implementation that strips all comment events between startDTD and endDTD.
 
Field Summary
protected  boolean dropDtdComments
          Should comments appearing between start/endDTD events be dropped ?
protected  SAXParserFactory factory
          the SAX Parser factory
protected  boolean nsPrefixes
          do we want namespaces also as attributes ?
protected  String saxParserFactoryName
          The name of the sax parser factory.
protected  boolean stopOnRecoverableError
          do we stop on recoverable errors ?
protected  boolean stopOnWarning
          do we stop on warnings ?
 
Fields inherited from class org.apache.cocoon.core.xml.impl.AbstractJaxpParser
resolver, searchResolver, validate
 
Constructor Summary
JaxpSAXParser()
           
 
Method Summary
 void error(SAXParseException spe)
          Receive notification of a recoverable error.
 void fatalError(SAXParseException spe)
          Receive notification of a fatal error.
 String getSaxParserFactoryName()
          Return the name of the sax parser factory.
protected  void initSaxParserFactory()
          Initialize the sax parser factory.
 boolean isDropDtdComments()
           
 boolean isNsPrefixes()
           
 boolean isStopOnRecoverableError()
           
 boolean isStopOnWarning()
           
 void parse(InputSource in, ContentHandler consumer)
           
 void parse(InputSource in, ContentHandler contentHandler, LexicalHandler lexicalHandler)
           
 void setDropDtdComments(boolean dropDtdComments)
          Should comment() events from DTD's be dropped? (Default is false.) Since this implementation does not support the DeclHandler interface anyway, it is quite useless to only have the comments from DTD.
 void setNsPrefixes(boolean nsPrefixes)
          Do we want namespaces declarations also as 'xmlns:' attributes ? Default is false.
 void setSaxParserFactoryName(String saxParserFactoryName)
          Set the name of the SAXParserFactory implementation class to be used instead of using the standard JAXP mechanism (SAXParserFactory.newInstance()).
 void setStopOnRecoverableError(boolean stopOnRecoverableError)
          Should the parser stop parsing if a recoverable error occurs ? Default is true.
 void setStopOnWarning(boolean stopOnWarning)
          Should the parser stop parsing if a warning occurs ? Default is true.
protected  XMLReader setupXMLReader()
          Creates a new XMLReader if needed.
 void warning(SAXParseException spe)
          Receive notification of a warning.
 
Methods inherited from class org.apache.cocoon.core.xml.impl.AbstractJaxpParser
getEntityResolver, getLogger, isSearchResolver, isValidate, loadClass, setBeanFactory, setEntityResolver, setLogger, setSearchResolver, setValidate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected SAXParserFactory factory
the SAX Parser factory


nsPrefixes

protected boolean nsPrefixes
do we want namespaces also as attributes ?


stopOnWarning

protected boolean stopOnWarning
do we stop on warnings ?


stopOnRecoverableError

protected boolean stopOnRecoverableError
do we stop on recoverable errors ?


dropDtdComments

protected boolean dropDtdComments
Should comments appearing between start/endDTD events be dropped ?


saxParserFactoryName

protected String saxParserFactoryName
The name of the sax parser factory.

Constructor Detail

JaxpSAXParser

public JaxpSAXParser()
Method Detail

isDropDtdComments

public boolean isDropDtdComments()
See Also:
setDropDtdComments(boolean)

setDropDtdComments

public void setDropDtdComments(boolean dropDtdComments)
Should comment() events from DTD's be dropped? (Default is false.) Since this implementation does not support the DeclHandler interface anyway, it is quite useless to only have the comments from DTD. And the comment events from the internal DTD subset would appear in the serialized output again.


isNsPrefixes

public boolean isNsPrefixes()
See Also:
setNsPrefixes(boolean)

setNsPrefixes

public void setNsPrefixes(boolean nsPrefixes)
Do we want namespaces declarations also as 'xmlns:' attributes ? Default is false. Note : setting this to true confuses some XSL processors (e.g. Saxon).


isStopOnRecoverableError

public boolean isStopOnRecoverableError()
See Also:
setStopOnRecoverableError(boolean)

setStopOnRecoverableError

public void setStopOnRecoverableError(boolean stopOnRecoverableError)
Should the parser stop parsing if a recoverable error occurs ? Default is true.


isStopOnWarning

public boolean isStopOnWarning()
See Also:
setStopOnWarning(boolean)

setStopOnWarning

public void setStopOnWarning(boolean stopOnWarning)
Should the parser stop parsing if a warning occurs ? Default is true.


getSaxParserFactoryName

public String getSaxParserFactoryName()
Return the name of the sax parser factory.

Returns:
the name of the sax parser factory.
See Also:
setSaxParserFactoryName(String)

setSaxParserFactoryName

public void setSaxParserFactoryName(String saxParserFactoryName)
Set the name of the 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.


initSaxParserFactory

protected void initSaxParserFactory()
                             throws Exception
Initialize the sax parser factory.

Throws:
Exception

parse

public void parse(InputSource in,
                  ContentHandler contentHandler,
                  LexicalHandler lexicalHandler)
           throws SAXException,
                  IOException
Specified by:
parse in interface org.apache.cocoon.core.xml.SAXParser
Throws:
SAXException
IOException
See Also:
SAXParser.parse(org.xml.sax.InputSource, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler)

parse

public void parse(InputSource in,
                  ContentHandler consumer)
           throws SAXException,
                  IOException
Specified by:
parse in interface org.apache.cocoon.core.xml.SAXParser
Throws:
SAXException
IOException
See Also:
SAXParser.parse(org.xml.sax.InputSource, org.xml.sax.ContentHandler)

setupXMLReader

protected XMLReader setupXMLReader()
                            throws SAXException
Creates a new XMLReader if needed.

Throws:
SAXException

error

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

Specified by:
error in interface ErrorHandler
Throws:
SAXException

fatalError

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

Specified by:
fatalError in interface ErrorHandler
Throws:
SAXException

warning

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

Specified by:
warning in interface ErrorHandler
Throws:
SAXException


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.