Package org.codelibs.nekohtml.parsers
Class DOMFragmentParser
- java.lang.Object
-
- org.codelibs.nekohtml.parsers.DOMFragmentParser
-
- All Implemented Interfaces:
org.apache.xerces.xni.XMLDocumentHandler
public class DOMFragmentParser extends java.lang.Object implements org.apache.xerces.xni.XMLDocumentHandlerA 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
Fields Modifier and Type Field Description protected static java.lang.StringCURRENT_ELEMENT_NODECurrent element node.protected static java.lang.StringDOCUMENT_FRAGMENTDocument fragment balancing only.protected static java.lang.StringERROR_HANDLERProperty identifier: error handler.protected org.w3c.dom.NodefCurrentNodeCurrent node.protected org.w3c.dom.DocumentfDocumentDocument.protected org.w3c.dom.DocumentFragmentfDocumentFragmentDOM document fragment.protected org.apache.xerces.xni.parser.XMLDocumentSourcefDocumentSourceDocument source.protected booleanfInCDATASectionTrue if within a CDATA section.protected org.apache.xerces.xni.parser.XMLParserConfigurationfParserConfigurationParser configuration.protected static java.lang.String[]RECOGNIZED_FEATURESRecognized features.protected static java.lang.String[]RECOGNIZED_PROPERTIESRecognized properties.
-
Constructor Summary
Constructors Constructor Description DOMFragmentParser()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)Characters.voidcomment(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)Comment.voiddoctypeDecl(java.lang.String root, java.lang.String pubid, java.lang.String sysid, org.apache.xerces.xni.Augmentations augs)Document type declaration.voidemptyElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attrs, org.apache.xerces.xni.Augmentations augs)Empty element.voidendCDATA(org.apache.xerces.xni.Augmentations augs)End CDATA section.voidendDocument(org.apache.xerces.xni.Augmentations augs)End document.voidendElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs)End element.voidendGeneralEntity(java.lang.String name, org.apache.xerces.xni.Augmentations augs)End general entity.voidendPrefixMapping(java.lang.String prefix, org.apache.xerces.xni.Augmentations augs)End prefix mapping.org.apache.xerces.xni.parser.XMLDocumentSourcegetDocumentSource()Returns the document source.org.xml.sax.ErrorHandlergetErrorHandler()Return the current error handler.booleangetFeature(java.lang.String featureId)Query the state of a feature.java.lang.ObjectgetProperty(java.lang.String propertyId)Query the value of a property.voidignorableWhitespace(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)Ignorable whitespace.voidparse(java.lang.String systemId, org.w3c.dom.DocumentFragment fragment)Parses a document fragment.voidparse(org.xml.sax.InputSource source, org.w3c.dom.DocumentFragment fragment)Parses a document fragment.voidprocessingInstruction(java.lang.String target, org.apache.xerces.xni.XMLString data, org.apache.xerces.xni.Augmentations augs)Processing instruction.voidsetDocumentSource(org.apache.xerces.xni.parser.XMLDocumentSource source)Sets the document source.voidsetErrorHandler(org.xml.sax.ErrorHandler errorHandler)Allow an application to register an error event handler.voidsetFeature(java.lang.String featureId, boolean state)Set the state of any feature in a SAX2 parser.voidsetProperty(java.lang.String propertyId, java.lang.Object value)Set the value of any property in a SAX2 parser.voidstartCDATA(org.apache.xerces.xni.Augmentations augs)Start CDATA section.voidstartDocument(org.apache.xerces.xni.XMLLocator locator, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)Start document.voidstartDocument(org.apache.xerces.xni.XMLLocator locator, java.lang.String encoding, org.apache.xerces.xni.NamespaceContext nscontext, org.apache.xerces.xni.Augmentations augs)Start document.voidstartElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attrs, org.apache.xerces.xni.Augmentations augs)Start element.voidstartGeneralEntity(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier id, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)Start general entity.voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri, org.apache.xerces.xni.Augmentations augs)Start prefix mapping.voidtextDecl(java.lang.String version, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)Text declaration.voidxmlDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone, org.apache.xerces.xni.Augmentations augs)XML declaration.
-
-
-
Field Detail
-
DOCUMENT_FRAGMENT
protected static final java.lang.String DOCUMENT_FRAGMENT
Document fragment balancing only.- See Also:
- Constant Field Values
-
RECOGNIZED_FEATURES
protected static final java.lang.String[] RECOGNIZED_FEATURES
Recognized features.
-
ERROR_HANDLER
protected static final java.lang.String ERROR_HANDLER
Property identifier: error handler.- See Also:
- Constant Field Values
-
CURRENT_ELEMENT_NODE
protected static final java.lang.String CURRENT_ELEMENT_NODE
Current element node.- See Also:
- Constant Field Values
-
RECOGNIZED_PROPERTIES
protected static final java.lang.String[] RECOGNIZED_PROPERTIES
Recognized properties.
-
fParserConfiguration
protected org.apache.xerces.xni.parser.XMLParserConfiguration fParserConfiguration
Parser configuration.
-
fDocumentSource
protected org.apache.xerces.xni.parser.XMLDocumentSource fDocumentSource
Document source.
-
fDocumentFragment
protected org.w3c.dom.DocumentFragment fDocumentFragment
DOM document fragment.
-
fDocument
protected org.w3c.dom.Document fDocument
Document.
-
fCurrentNode
protected org.w3c.dom.Node fCurrentNode
Current node.
-
fInCDATASection
protected boolean fInCDATASection
True if within a CDATA section.
-
-
Method Detail
-
parse
public void parse(java.lang.String systemId, org.w3c.dom.DocumentFragment fragment) throws org.xml.sax.SAXException, java.io.IOExceptionParses a document fragment.- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
parse
public void parse(org.xml.sax.InputSource source, org.w3c.dom.DocumentFragment fragment) throws org.xml.sax.SAXException, java.io.IOExceptionParses a document fragment.- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
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:
java.lang.NullPointerException- If the handler argument is null.- See Also:
getErrorHandler()
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
Return the current error handler.- Returns:
- The current error handler, or null if none has been registered.
- See Also:
setErrorHandler(org.xml.sax.ErrorHandler)
-
setFeature
public void setFeature(java.lang.String featureId, boolean state) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSet 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:
org.xml.sax.SAXNotRecognizedException- If the requested feature is not known.org.xml.sax.SAXNotSupportedException- If the requested feature is known, but the requested state is not supported.
-
getFeature
public boolean getFeature(java.lang.String featureId) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionQuery 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:
org.xml.sax.SAXNotRecognizedException- If the requested feature is not known.org.xml.sax.SAXNotSupportedException- If the requested feature is known but not supported.
-
setProperty
public void setProperty(java.lang.String propertyId, java.lang.Object value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSet 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:
org.xml.sax.SAXNotRecognizedException- If the requested property is not known.org.xml.sax.SAXNotSupportedException- If the requested property is known, but the requested value is not supported.
-
getProperty
public java.lang.Object getProperty(java.lang.String propertyId) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionQuery 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:
org.xml.sax.SAXNotRecognizedException- If the requested property is not known.org.xml.sax.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:
setDocumentSourcein interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
getDocumentSource
public org.apache.xerces.xni.parser.XMLDocumentSource getDocumentSource()
Returns the document source.- Specified by:
getDocumentSourcein interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
startDocument
public void startDocument(org.apache.xerces.xni.XMLLocator locator, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)Start document.
-
startDocument
public void startDocument(org.apache.xerces.xni.XMLLocator locator, java.lang.String encoding, org.apache.xerces.xni.NamespaceContext nscontext, org.apache.xerces.xni.Augmentations augs)Start document.- Specified by:
startDocumentin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
xmlDecl
public void xmlDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone, org.apache.xerces.xni.Augmentations augs)XML declaration.- Specified by:
xmlDeclin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
doctypeDecl
public void doctypeDecl(java.lang.String root, java.lang.String pubid, java.lang.String sysid, org.apache.xerces.xni.Augmentations augs)Document type declaration.- Specified by:
doctypeDeclin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
processingInstruction
public void processingInstruction(java.lang.String target, org.apache.xerces.xni.XMLString data, org.apache.xerces.xni.Augmentations augs)Processing instruction.- Specified by:
processingInstructionin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
comment
public void comment(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)Comment.- Specified by:
commentin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri, org.apache.xerces.xni.Augmentations augs)Start prefix mapping. @deprecated Since Xerces 2.2.0.
-
endPrefixMapping
public void endPrefixMapping(java.lang.String prefix, org.apache.xerces.xni.Augmentations augs)End prefix mapping. @deprecated Since Xerces 2.2.0.
-
startElement
public void startElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attrs, org.apache.xerces.xni.Augmentations augs)Start element.- Specified by:
startElementin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
emptyElement
public void emptyElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attrs, org.apache.xerces.xni.Augmentations augs)Empty element.- Specified by:
emptyElementin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
characters
public void characters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)Characters.- Specified by:
charactersin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
ignorableWhitespace
public void ignorableWhitespace(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)Ignorable whitespace.- Specified by:
ignorableWhitespacein interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
startGeneralEntity
public void startGeneralEntity(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier id, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)Start general entity.- Specified by:
startGeneralEntityin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
textDecl
public void textDecl(java.lang.String version, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)Text declaration.- Specified by:
textDeclin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
endGeneralEntity
public void endGeneralEntity(java.lang.String name, org.apache.xerces.xni.Augmentations augs)End general entity.- Specified by:
endGeneralEntityin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
startCDATA
public void startCDATA(org.apache.xerces.xni.Augmentations augs)
Start CDATA section.- Specified by:
startCDATAin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
endCDATA
public void endCDATA(org.apache.xerces.xni.Augmentations augs)
End CDATA section.- Specified by:
endCDATAin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
endElement
public void endElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs)End element.- Specified by:
endElementin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
endDocument
public void endDocument(org.apache.xerces.xni.Augmentations augs)
End document.- Specified by:
endDocumentin interfaceorg.apache.xerces.xni.XMLDocumentHandler
-
-