Package org.cyberneko.html.parsers
Class DOMFragmentParser
java.lang.Object
org.cyberneko.html.parsers.DOMFragmentParser
- All Implemented Interfaces:
org.apache.xerces.xni.XMLDocumentHandler
A DOM parser for HTML fragments.
- Version:
- $Id: DOMFragmentParser.java,v 1.8 2005/02/14 03:56:54 andyc Exp $
- Author:
- Andy Clark
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
Current element node.protected static final String
Document fragment balancing only.protected static final String
Property identifier: error handler.protected Node
Current node.protected Document
Document.protected DocumentFragment
DOM document fragment.protected org.apache.xerces.xni.parser.XMLDocumentSource
Document source.protected boolean
True if within a CDATA section.protected org.apache.xerces.xni.parser.XMLParserConfiguration
Parser configuration.protected static final String[]
Recognized features.protected static final String[]
Recognized properties. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) Characters.void
comment
(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) Comment.void
doctypeDecl
(String root, String pubid, String sysid, org.apache.xerces.xni.Augmentations augs) Document type declaration.void
emptyElement
(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attrs, org.apache.xerces.xni.Augmentations augs) Empty element.void
endCDATA
(org.apache.xerces.xni.Augmentations augs) End CDATA section.void
endDocument
(org.apache.xerces.xni.Augmentations augs) End document.void
endElement
(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs) End element.void
endGeneralEntity
(String name, org.apache.xerces.xni.Augmentations augs) End general entity.void
endPrefixMapping
(String prefix, org.apache.xerces.xni.Augmentations augs) End prefix mapping.org.apache.xerces.xni.parser.XMLDocumentSource
Returns the document source.Return the current error handler.boolean
getFeature
(String featureId) Query the state of a feature.getProperty
(String propertyId) Query the value of a property.void
ignorableWhitespace
(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) Ignorable whitespace.void
parse
(String systemId, DocumentFragment fragment) Parses a document fragment.void
parse
(InputSource source, DocumentFragment fragment) Parses a document fragment.void
processingInstruction
(String target, org.apache.xerces.xni.XMLString data, org.apache.xerces.xni.Augmentations augs) Processing instruction.void
setDocumentSource
(org.apache.xerces.xni.parser.XMLDocumentSource source) Sets the document source.void
setErrorHandler
(ErrorHandler errorHandler) Allow an application to register an error event handler.void
setFeature
(String featureId, boolean state) Set the state of any feature in a SAX2 parser.void
setProperty
(String propertyId, Object value) Set the value of any property in a SAX2 parser.void
startCDATA
(org.apache.xerces.xni.Augmentations augs) Start CDATA section.void
startDocument
(org.apache.xerces.xni.XMLLocator locator, String encoding, org.apache.xerces.xni.Augmentations augs) Start document.void
startDocument
(org.apache.xerces.xni.XMLLocator locator, String encoding, org.apache.xerces.xni.NamespaceContext nscontext, org.apache.xerces.xni.Augmentations augs) Start document.void
startElement
(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attrs, org.apache.xerces.xni.Augmentations augs) Start element.void
startGeneralEntity
(String name, org.apache.xerces.xni.XMLResourceIdentifier id, String encoding, org.apache.xerces.xni.Augmentations augs) Start general entity.void
startPrefixMapping
(String prefix, String uri, org.apache.xerces.xni.Augmentations augs) Start prefix mapping.void
Text declaration.void
xmlDecl
(String version, String encoding, String standalone, org.apache.xerces.xni.Augmentations augs) XML declaration.
-
Field Details
-
DOCUMENT_FRAGMENT
Document fragment balancing only.- See Also:
-
RECOGNIZED_FEATURES
Recognized features. -
ERROR_HANDLER
Property identifier: error handler.- See Also:
-
CURRENT_ELEMENT_NODE
Current element node.- See Also:
-
RECOGNIZED_PROPERTIES
Recognized properties. -
fParserConfiguration
protected org.apache.xerces.xni.parser.XMLParserConfiguration fParserConfigurationParser configuration. -
fDocumentSource
protected org.apache.xerces.xni.parser.XMLDocumentSource fDocumentSourceDocument source. -
fDocumentFragment
DOM document fragment. -
fDocument
Document. -
fCurrentNode
Current node. -
fInCDATASection
protected boolean fInCDATASectionTrue if within a CDATA section.
-
-
Constructor Details
-
DOMFragmentParser
public DOMFragmentParser()Default constructor.
-
-
Method Details
-
parse
Parses a document fragment.- Throws:
SAXException
IOException
-
parse
Parses a document fragment.- Throws:
SAXException
IOException
-
setErrorHandler
Allow an application to register an error event handler.If the application does not register an error handler, all error events reported by the SAX parser will be silently ignored; however, normal processing may not continue. It is highly recommended that all SAX applications implement an error handler to avoid unexpected bugs.
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Parameters:
errorHandler
- The error handler.- Throws:
NullPointerException
- If the handler argument is null.- See Also:
-
getErrorHandler
Return the current error handler.- Returns:
- The current error handler, or null if none has been registered.
- See Also:
-
setFeature
public void setFeature(String featureId, boolean state) throws SAXNotRecognizedException, SAXNotSupportedException Set the state of any feature in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.- Parameters:
featureId
- The unique identifier (URI) of the feature.state
- The requested state of the feature (true or false).- Throws:
SAXNotRecognizedException
- If the requested feature is not known.SAXNotSupportedException
- If the requested feature is known, but the requested state is not supported.
-
getFeature
public boolean getFeature(String featureId) throws SAXNotRecognizedException, SAXNotSupportedException Query the state of a feature. Query the current state of any feature in a SAX2 parser. The parser might not recognize the feature.- Parameters:
featureId
- The unique identifier (URI) of the feature being set.- Returns:
- The current state of the feature.
- Throws:
SAXNotRecognizedException
- If the requested feature is not known.SAXNotSupportedException
- If the requested feature is known but not supported.
-
setProperty
public void setProperty(String propertyId, Object value) throws SAXNotRecognizedException, SAXNotSupportedException Set the value of any property in a SAX2 parser. The parser might not recognize the property, and if it does recognize it, it might not support the requested value.- Parameters:
propertyId
- The unique identifier (URI) of the property being set.value
- The value to which the property is being set.- Throws:
SAXNotRecognizedException
- If the requested property is not known.SAXNotSupportedException
- If the requested property is known, but the requested value is not supported.
-
getProperty
public Object getProperty(String propertyId) throws SAXNotRecognizedException, SAXNotSupportedException Query the value of a property. Return the current value of a property in a SAX2 parser. The parser might not recognize the property.- Parameters:
propertyId
- The unique identifier (URI) of the property being set.- Returns:
- The current value of the property.
- Throws:
SAXNotRecognizedException
- If the requested property is not known.SAXNotSupportedException
- If the requested property is known but not supported.
-
setDocumentSource
public void setDocumentSource(org.apache.xerces.xni.parser.XMLDocumentSource source) Sets the document source.- Specified by:
setDocumentSource
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
getDocumentSource
public org.apache.xerces.xni.parser.XMLDocumentSource getDocumentSource()Returns the document source.- Specified by:
getDocumentSource
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
startDocument
public void startDocument(org.apache.xerces.xni.XMLLocator locator, String encoding, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Start document.- Throws:
org.apache.xerces.xni.XNIException
-
startDocument
public void startDocument(org.apache.xerces.xni.XMLLocator locator, String encoding, org.apache.xerces.xni.NamespaceContext nscontext, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Start document.- Specified by:
startDocument
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
xmlDecl
public void xmlDecl(String version, String encoding, String standalone, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException XML declaration.- Specified by:
xmlDecl
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
doctypeDecl
public void doctypeDecl(String root, String pubid, String sysid, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Document type declaration.- Specified by:
doctypeDecl
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
processingInstruction
public void processingInstruction(String target, org.apache.xerces.xni.XMLString data, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Processing instruction.- Specified by:
processingInstruction
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
comment
public void comment(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Comment.- Specified by:
comment
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Start prefix mapping. @deprecated Since Xerces 2.2.0.- Throws:
org.apache.xerces.xni.XNIException
-
endPrefixMapping
public void endPrefixMapping(String prefix, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException End prefix mapping. @deprecated Since Xerces 2.2.0.- Throws:
org.apache.xerces.xni.XNIException
-
startElement
public void startElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attrs, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Start element.- Specified by:
startElement
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
emptyElement
public void emptyElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attrs, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Empty element.- Specified by:
emptyElement
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
characters
public void characters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Characters.- Specified by:
characters
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
ignorableWhitespace
public void ignorableWhitespace(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Ignorable whitespace.- Specified by:
ignorableWhitespace
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
startGeneralEntity
public void startGeneralEntity(String name, org.apache.xerces.xni.XMLResourceIdentifier id, String encoding, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Start general entity.- Specified by:
startGeneralEntity
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
textDecl
public void textDecl(String version, String encoding, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Text declaration.- Specified by:
textDecl
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
endGeneralEntity
public void endGeneralEntity(String name, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException End general entity.- Specified by:
endGeneralEntity
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
startCDATA
public void startCDATA(org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Start CDATA section.- Specified by:
startCDATA
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
endCDATA
public void endCDATA(org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException End CDATA section.- Specified by:
endCDATA
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
endElement
public void endElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException End element.- Specified by:
endElement
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-
endDocument
public void endDocument(org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException End document.- Specified by:
endDocument
in interfaceorg.apache.xerces.xni.XMLDocumentHandler
- Throws:
org.apache.xerces.xni.XNIException
-