- java.lang.Object
-
- org.apache.xerces.util.ParserConfigurationSettings
-
- org.codelibs.nekohtml.HTMLConfiguration
-
- All Implemented Interfaces:
org.apache.xerces.xni.parser.XMLComponentManager,org.apache.xerces.xni.parser.XMLParserConfiguration,org.apache.xerces.xni.parser.XMLPullParserConfiguration
public class HTMLConfiguration extends org.apache.xerces.util.ParserConfigurationSettings implements org.apache.xerces.xni.parser.XMLPullParserConfigurationAn XNI-based parser configuration that can be used to parse HTML documents. This configuration can be used directly in order to parse HTML documents or can be used in conjunction with any XNI based tools, such as the Xerces2 implementation.This configuration recognizes the following features:
- http://cyberneko.org/html/features/augmentations
- http://cyberneko.org/html/features/report-errors
- http://cyberneko.org/html/features/report-errors/simple
- http://cyberneko.org/html/features/balance-tags
- and
- the features supported by the scanner and tag balancer components.
This configuration recognizes the following properties:
- http://cyberneko.org/html/properties/names/elems
- http://cyberneko.org/html/properties/names/attrs
- http://cyberneko.org/html/properties/filters
- http://cyberneko.org/html/properties/error-reporter
- and
- the properties supported by the scanner and tag balancer.
For complete usage information, refer to the documentation.
- Version:
- $Id: HTMLConfiguration.java,v 1.9 2005/02/14 03:56:54 andyc Exp $
- Author:
- Andy Clark
- See Also:
HTMLScanner,HTMLTagBalancer,HTMLErrorReporter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classHTMLConfiguration.ErrorReporterDefines an error reporter for reporting HTML errors.
-
Field Summary
Fields Modifier and Type Field Description protected static StringAUGMENTATIONSInclude infoset augmentations.protected static StringBALANCE_TAGSBalance tags.protected static StringERROR_DOMAINError domain.protected static StringERROR_REPORTERError reporter.protected booleanfCloseStreamStream opened by parser.protected org.apache.xerces.xni.XMLDocumentHandlerfDocumentHandlerDocument handler.protected HTMLScannerfDocumentScannerDocument scanner.protected org.apache.xerces.xni.XMLDTDContentModelHandlerfDTDContentModelHandlerDTD content model handler.protected org.apache.xerces.xni.XMLDTDHandlerfDTDHandlerDTD handler.protected org.apache.xerces.xni.parser.XMLEntityResolverfEntityResolverEntity resolver.protected org.apache.xerces.xni.parser.XMLErrorHandlerfErrorHandlerError handler.protected HTMLErrorReporterfErrorReporterError reporter.protected Vector<HTMLComponent>fHTMLComponentsComponents.protected static StringFILTERSPipeline filters.protected LocalefLocaleLocale.protected NamespaceBinderfNamespaceBinderNamespace binder.protected HTMLTagBalancerfTagBalancerHTML tag balancer.protected static StringNAMES_ATTRSModify HTML attribute names: { "upper", "lower", "default" }.protected static StringNAMES_ELEMSModify HTML element names: { "upper", "lower", "default" }.protected static StringNAMESPACESNamespaces.protected static StringREPORT_ERRORSReport errors.protected static StringSIMPLE_ERROR_FORMATSimple report format.
-
Constructor Summary
Constructors Constructor Description HTMLConfiguration()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddComponent(HTMLComponent component)Adds a component.voidcleanup()If the application decides to terminate parsing before the xml document is fully parsed, the application should call this method to free any resource allocated during parsing.protected HTMLScannercreateDocumentScanner()voidevaluateInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)Immediately evaluates an input source and add the new content (e.g.org.apache.xerces.xni.XMLDocumentHandlergetDocumentHandler()Returns the document handler.org.apache.xerces.xni.XMLDTDContentModelHandlergetDTDContentModelHandler()Returns the DTD content model handler.org.apache.xerces.xni.XMLDTDHandlergetDTDHandler()Returns the DTD handler.org.apache.xerces.xni.parser.XMLEntityResolvergetEntityResolver()Returns the entity resolver.org.apache.xerces.xni.parser.XMLErrorHandlergetErrorHandler()Returns the error handler.LocalegetLocale()Returns the locale.booleanparse(boolean complete)Parses the document in a pull parsing fashion.voidparse(org.apache.xerces.xni.parser.XMLInputSource source)Parses a document.voidpushInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)Pushes an input source onto the current entity stack.protected voidreset()Resets the parser configuration.voidsetDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler handler)Sets the document handler.voidsetDTDContentModelHandler(org.apache.xerces.xni.XMLDTDContentModelHandler handler)Sets the DTD content model handler.voidsetDTDHandler(org.apache.xerces.xni.XMLDTDHandler handler)Sets the DTD handler.voidsetEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver resolver)Sets the entity resolver.voidsetErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler handler)Sets the error handler.voidsetFeature(String featureId, boolean state)Sets a feature.voidsetInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)Sets the input source for the document to parse.voidsetLocale(Locale locale)Sets the locale.voidsetProperty(String propertyId, Object value)Sets a property.-
Methods inherited from class org.apache.xerces.util.ParserConfigurationSettings
addRecognizedFeatures, addRecognizedProperties, checkFeature, checkProperty, getFeature, getProperty
-
-
-
-
Field Detail
-
NAMESPACES
protected static final String NAMESPACES
Namespaces.- See Also:
- Constant Field Values
-
AUGMENTATIONS
protected static final String AUGMENTATIONS
Include infoset augmentations.- See Also:
- Constant Field Values
-
REPORT_ERRORS
protected static final String REPORT_ERRORS
Report errors.- See Also:
- Constant Field Values
-
SIMPLE_ERROR_FORMAT
protected static final String SIMPLE_ERROR_FORMAT
Simple report format.- See Also:
- Constant Field Values
-
BALANCE_TAGS
protected static final String BALANCE_TAGS
Balance tags.- See Also:
- Constant Field Values
-
NAMES_ELEMS
protected static final String NAMES_ELEMS
Modify HTML element names: { "upper", "lower", "default" }.- See Also:
- Constant Field Values
-
NAMES_ATTRS
protected static final String NAMES_ATTRS
Modify HTML attribute names: { "upper", "lower", "default" }.- See Also:
- Constant Field Values
-
FILTERS
protected static final String FILTERS
Pipeline filters.- See Also:
- Constant Field Values
-
ERROR_REPORTER
protected static final String ERROR_REPORTER
Error reporter.- See Also:
- Constant Field Values
-
ERROR_DOMAIN
protected static final String ERROR_DOMAIN
Error domain.- See Also:
- Constant Field Values
-
fDocumentHandler
protected org.apache.xerces.xni.XMLDocumentHandler fDocumentHandler
Document handler.
-
fDTDHandler
protected org.apache.xerces.xni.XMLDTDHandler fDTDHandler
DTD handler.
-
fDTDContentModelHandler
protected org.apache.xerces.xni.XMLDTDContentModelHandler fDTDContentModelHandler
DTD content model handler.
-
fErrorHandler
protected org.apache.xerces.xni.parser.XMLErrorHandler fErrorHandler
Error handler.
-
fEntityResolver
protected org.apache.xerces.xni.parser.XMLEntityResolver fEntityResolver
Entity resolver.
-
fLocale
protected Locale fLocale
Locale.
-
fCloseStream
protected boolean fCloseStream
Stream opened by parser. Therefore, must close stream manually upon termination of parsing.
-
fHTMLComponents
protected final Vector<HTMLComponent> fHTMLComponents
Components.
-
fDocumentScanner
protected final HTMLScanner fDocumentScanner
Document scanner.
-
fTagBalancer
protected final HTMLTagBalancer fTagBalancer
HTML tag balancer.
-
fNamespaceBinder
protected final NamespaceBinder fNamespaceBinder
Namespace binder.
-
fErrorReporter
protected final HTMLErrorReporter fErrorReporter
Error reporter.
-
-
Method Detail
-
createDocumentScanner
protected HTMLScanner createDocumentScanner()
-
pushInputSource
public void pushInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
Pushes an input source onto the current entity stack. This enables the scanner to transparently scan new content (e.g. the output written by an embedded script). At the end of the current entity, the scanner returns where it left off at the time this entity source was pushed.Hint: To use this feature to insert the output of <SCRIPT> tags, remember to buffer the entire output of the processed instructions before pushing a new input source. Otherwise, events may appear out of sequence.
- Parameters:
inputSource- The new input source to start scanning.- See Also:
evaluateInputSource(XMLInputSource)
-
evaluateInputSource
public void evaluateInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
Immediately evaluates an input source and add the new content (e.g. the output written by an embedded script).- Parameters:
inputSource- The new input source to start scanning.- See Also:
pushInputSource(XMLInputSource)
-
setFeature
public void setFeature(String featureId, boolean state)
Sets a feature.- Specified by:
setFeaturein interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration- Overrides:
setFeaturein classorg.apache.xerces.util.ParserConfigurationSettings
-
setProperty
public void setProperty(String propertyId, Object value)
Sets a property.- Specified by:
setPropertyin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration- Overrides:
setPropertyin classorg.apache.xerces.util.ParserConfigurationSettings
-
setDocumentHandler
public void setDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler handler)
Sets the document handler.- Specified by:
setDocumentHandlerin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
getDocumentHandler
public org.apache.xerces.xni.XMLDocumentHandler getDocumentHandler()
Returns the document handler.- Specified by:
getDocumentHandlerin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
setDTDHandler
public void setDTDHandler(org.apache.xerces.xni.XMLDTDHandler handler)
Sets the DTD handler.- Specified by:
setDTDHandlerin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
getDTDHandler
public org.apache.xerces.xni.XMLDTDHandler getDTDHandler()
Returns the DTD handler.- Specified by:
getDTDHandlerin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
setDTDContentModelHandler
public void setDTDContentModelHandler(org.apache.xerces.xni.XMLDTDContentModelHandler handler)
Sets the DTD content model handler.- Specified by:
setDTDContentModelHandlerin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
getDTDContentModelHandler
public org.apache.xerces.xni.XMLDTDContentModelHandler getDTDContentModelHandler()
Returns the DTD content model handler.- Specified by:
getDTDContentModelHandlerin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
setErrorHandler
public void setErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler handler)
Sets the error handler.- Specified by:
setErrorHandlerin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
getErrorHandler
public org.apache.xerces.xni.parser.XMLErrorHandler getErrorHandler()
Returns the error handler.- Specified by:
getErrorHandlerin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
setEntityResolver
public void setEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver resolver)
Sets the entity resolver.- Specified by:
setEntityResolverin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
getEntityResolver
public org.apache.xerces.xni.parser.XMLEntityResolver getEntityResolver()
Returns the entity resolver.- Specified by:
getEntityResolverin interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
setLocale
public void setLocale(Locale locale)
Sets the locale.- Specified by:
setLocalein interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
getLocale
public Locale getLocale()
Returns the locale.- Specified by:
getLocalein interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration
-
parse
public void parse(org.apache.xerces.xni.parser.XMLInputSource source) throws IOExceptionParses a document.- Specified by:
parsein interfaceorg.apache.xerces.xni.parser.XMLParserConfiguration- Throws:
IOException
-
setInputSource
public void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource) throws IOExceptionSets the input source for the document to parse.- Specified by:
setInputSourcein interfaceorg.apache.xerces.xni.parser.XMLPullParserConfiguration- Parameters:
inputSource- The document's input source.- Throws:
org.apache.xerces.xni.parser.XMLConfigurationException- Thrown if there is a configuration error when initializing the parser.IOException- Thrown on I/O error.- See Also:
parse(boolean)
-
parse
public boolean parse(boolean complete) throws IOExceptionParses the document in a pull parsing fashion.- Specified by:
parsein interfaceorg.apache.xerces.xni.parser.XMLPullParserConfiguration- Parameters:
complete- True if the pull parser should parse the remaining document completely.- Returns:
- True if there is more document to parse.
- Throws:
org.apache.xerces.xni.XNIException- Any XNI exception, possibly wrapping another exception.IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the parser.- See Also:
setInputSource(org.apache.xerces.xni.parser.XMLInputSource)
-
cleanup
public void cleanup()
If the application decides to terminate parsing before the xml document is fully parsed, the application should call this method to free any resource allocated during parsing. For example, close all opened streams.- Specified by:
cleanupin interfaceorg.apache.xerces.xni.parser.XMLPullParserConfiguration
-
addComponent
protected void addComponent(HTMLComponent component)
Adds a component.
-
reset
protected void reset()
Resets the parser configuration.
-
-