- All Implemented Interfaces:
XMLDocumentHandler
- Direct Known Subclasses:
DOMParser
getDocument()
method. The actual pipeline is defined in parser configuration.- Author:
- Arnaud Le Hors, IBM, Andy Clark, IBM, Elena Litani, IBM, Ronald Brill
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringFeature id: create cdata nodes.Base uri stack.protected booleanCreate cdata nodes.protected CDATASectionprotected NodeCurrent node.protected DocumentThe document.protected Class<? extends DocumentImpl>The document class to use.protected CoreDocumentImplThe default Xerces document implementation, if used.protected DocumentTypeThe document type node.protected booleanTrue if saw the first chunk of characters.protected booleanTrue if inside CDATA section.protected booleanInclude Comments.protected booleanprotected final XMLStringCharacter buffer.protected static final StringFeature id: include comments.protected static final StringFeature id: namespace.Fields inherited from class org.htmlunit.cyberneko.xerces.parsers.AbstractXMLDocumentParser
ERROR_HANDLER, parserConfiguration_ -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDOMParser(XMLParserConfiguration config, Class<? extends DocumentImpl> documentClass) Constructs an abstract DOM parser with the specified configuration and document class. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(XMLString text, Augmentations augs) Character content.voidcomment(XMLString text, Augmentations augs) A comment.protected AttrcreateAttrNode(QName attrQName) Creates an attribute node.protected ElementcreateElementNode(QName element) Creates an element node.voiddoctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) Notifies of the presence of the DOCTYPE line in the document.voidemptyElement(QName element, XMLAttributes attributes, Augmentations augs) An empty element.voidendCDATA(Augmentations augs) The end of a CDATA section.voidendDocument(Augmentations augs) The end of the document.voidendElement(QName element, Augmentations augs) The end of an element.Returns the DOM document object.Returns the current error handler.booleangetFeature(String featureId) Queries the state of a feature.Returns this parser'sXMLParserConfiguration.protected final voidhandleBaseURI(Node node) Records baseURI information for the Element (by adding xml:base attribute) or for the ProcessingInstruction (by setting a baseURI field) Non deferred DOM.voidParses the input source specified by the given system identifier.voidparse(InputSource inputSource) Parses the document using the specified SAXInputSource.voidprocessingInstruction(String target, XMLString data, Augmentations augs) A processing instruction.voidreset()Resets the parser state.protected voidsetCharacterData(boolean sawChars) Appends character data from the string buffer to the current node.protected voidsetDocumentClass(Class<? extends DocumentImpl> documentClass) Allows the programmer to decide which document factory to use when constructing the DOM tree.voidsetErrorHandler(ErrorHandler errorHandler) Allows an application to register an error event handler.voidsetFeature(String featureId, boolean state) Sets the state of any feature in a SAX2 parser.voidsetProperty(String propertyId, Object value) Sets the value of any property in a SAX2 parser.voidstartCDATA(Augmentations augs) The start of a CDATA section.voidstartDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) The start of the document.voidstartElement(QName element, XMLAttributes attributes, Augmentations augs) The start of an element.voidxmlDecl(String version, String encoding, String standalone, Augmentations augs) Notifies of the presence of an XMLDecl line in the document.Methods inherited from class org.htmlunit.cyberneko.xerces.parsers.AbstractXMLDocumentParser
getDocumentSource, parse, setDocumentSource
-
Field Details
-
NAMESPACES
Feature id: namespace.- See Also:
-
INCLUDE_COMMENTS_FEATURE
Feature id: include comments.- See Also:
-
CREATE_CDATA_NODES_FEATURE
Feature id: create cdata nodes.- See Also:
-
fIncludeComments
protected boolean fIncludeCommentsInclude Comments. -
fCreateCDATANodes
protected boolean fCreateCDATANodesCreate cdata nodes. -
fDocument
The document. -
fDocumentImpl
The default Xerces document implementation, if used. -
fDocumentClass
The document class to use. -
fDocumentType
The document type node. -
fCurrentNode
Current node. -
fCurrentCDATASection
-
fStringBuffer
Character buffer. -
fNamespaceAware
protected boolean fNamespaceAware -
fInCDATASection
protected boolean fInCDATASectionTrue if inside CDATA section. -
fFirstChunk
protected boolean fFirstChunkTrue if saw the first chunk of characters. -
fBaseURIStack
Base uri stack.
-
-
Constructor Details
-
AbstractDOMParser
protected AbstractDOMParser(XMLParserConfiguration config, Class<? extends DocumentImpl> documentClass) Constructs an abstract DOM parser with the specified configuration and document class.- Parameters:
config- the parser configurationdocumentClass- the document class to use
-
-
Method Details
-
setDocumentClass
Allows the programmer to decide which document factory to use when constructing the DOM tree. However, doing so will lose the functionality of the default factory. Also, a document class other than the default will lose the ability to defer node expansion on the DOM tree produced.- Parameters:
documentClass- the document factory to use when constructing the DOM tree
-
getDocument
Returns the DOM document object.- Returns:
- the DOM document object
-
reset
Resets the parser state.- Overrides:
resetin classAbstractXMLDocumentParser- Throws:
XNIException- thrown on initialization error
-
comment
A comment.- Specified by:
commentin interfaceXMLDocumentHandler- Overrides:
commentin classAbstractXMLDocumentParser- Parameters:
text- the text in the commentaugs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by application to signal an error
-
processingInstruction
public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException A processing instruction. Processing instructions consist of a target name and, optionally, text data. The data is only meaningful to the application.Typically, a processing instruction's data will contain a series of pseudo-attributes. These pseudo-attributes follow the form of element attributes but are not parsed or presented to the application as anything other than text. The application is responsible for parsing the data.
- Specified by:
processingInstructionin interfaceXMLDocumentHandler- Overrides:
processingInstructionin classAbstractXMLDocumentParser- Parameters:
target- the targetdata- the data, ornullif none specifiedaugs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
startDocument
public void startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException The start of the document.- Specified by:
startDocumentin interfaceXMLDocumentHandler- Overrides:
startDocumentin classAbstractXMLDocumentParser- Parameters:
locator- the system identifier of the entity if external,nullotherwiseencoding- the auto-detected IANA encoding name of the entity stream, ornullif not auto-detectednamespaceContext- the namespace context in effect at the start of this documentaugs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
xmlDecl
public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException Notifies of the presence of an XMLDecl line in the document. If present, this method will be called immediately following the startDocument call.- Specified by:
xmlDeclin interfaceXMLDocumentHandler- Overrides:
xmlDeclin classAbstractXMLDocumentParser- Parameters:
version- the XML versionencoding- the IANA encoding name of the document, ornullif not specifiedstandalone- the standalone value, ornullif not specifiedaugs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
doctypeDecl
public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) throws XNIException Notifies of the presence of the DOCTYPE line in the document.- Specified by:
doctypeDeclin interfaceXMLDocumentHandler- Overrides:
doctypeDeclin classAbstractXMLDocumentParser- Parameters:
rootElement- the name of the root elementpublicId- the public identifier if an external DTD, ornullif specified using SYSTEMsystemId- the system identifier if an external DTD, ornullotherwiseaugs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
startElement
public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException The start of an element. If the document specifies the start element by using an empty tag, the startElement method is immediately followed by the endElement method, with no intervening methods.- Specified by:
startElementin interfaceXMLDocumentHandler- Overrides:
startElementin classAbstractXMLDocumentParser- Parameters:
element- the name of the elementattributes- the element attributesaugs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
emptyElement
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException An empty element.- Specified by:
emptyElementin interfaceXMLDocumentHandler- Overrides:
emptyElementin classAbstractXMLDocumentParser- Parameters:
element- the name of the elementattributes- the element attributesaugs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
characters
Character content.- Specified by:
charactersin interfaceXMLDocumentHandler- Overrides:
charactersin classAbstractXMLDocumentParser- Parameters:
text- the contentaugs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
endElement
The end of an element.- Specified by:
endElementin interfaceXMLDocumentHandler- Overrides:
endElementin classAbstractXMLDocumentParser- Parameters:
element- the name of the elementaugs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
startCDATA
The start of a CDATA section.- Specified by:
startCDATAin interfaceXMLDocumentHandler- Overrides:
startCDATAin classAbstractXMLDocumentParser- Parameters:
augs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
endCDATA
The end of a CDATA section.- Specified by:
endCDATAin interfaceXMLDocumentHandler- Overrides:
endCDATAin classAbstractXMLDocumentParser- Parameters:
augs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
endDocument
The end of the document.- Specified by:
endDocumentin interfaceXMLDocumentHandler- Overrides:
endDocumentin classAbstractXMLDocumentParser- Parameters:
augs- additional information that may include infoset augmentations- Throws:
XNIException- thrown by handler to signal an error
-
handleBaseURI
Records baseURI information for the Element (by adding xml:base attribute) or for the ProcessingInstruction (by setting a baseURI field) Non deferred DOM.- Parameters:
node- the node
-
createElementNode
Creates an element node. Subclasses can override this method to create element nodes in other ways.- Parameters:
element- the qualified name of the element- Returns:
- the created element node
-
createAttrNode
Creates an attribute node. Subclasses can override this method to create attribute nodes in other ways.- Parameters:
attrQName- the qualified name of the attribute- Returns:
- the created attribute node
-
setCharacterData
protected void setCharacterData(boolean sawChars) Appends character data from the string buffer to the current node.- Parameters:
sawChars-trueif characters were seen
-
parse
Parses the input source specified by the given system identifier.This method is equivalent to the following:
parse(new InputSource(systemId));
0* @param systemId the system identifier (URI)- Throws:
SAXException- thrown on SAX errorIOException- thrown on I/O error
-
parse
Parses the document using the specified SAXInputSource.- Parameters:
inputSource- the input source- Throws:
SAXException- thrown on SAX errorIOException- thrown on I/O error
-
setErrorHandler
Allows 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- See Also:
-
getErrorHandler
Returns the current error handler.- Returns:
- the current error handler, or
nullif none has been registered - See Also:
-
setFeature
public void setFeature(String featureId, boolean state) throws SAXNotRecognizedException, SAXNotSupportedException Sets the state of any feature in a SAX2 parser. The parser might not recognize the feature, and if recognized, might not be able to fulfill the request.- Parameters:
featureId- the unique identifier (URI) of the featurestate- the requested state of the feature (trueorfalse)- Throws:
SAXNotRecognizedException- if the requested feature is not knownSAXNotSupportedException- if the requested feature is known, but the requested state is not supported
-
getFeature
public boolean getFeature(String featureId) throws SAXNotRecognizedException, SAXNotSupportedException Queries the state of a feature.Queries 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 queried- Returns:
- the current state of the feature
- Throws:
SAXNotRecognizedException- if the requested feature is not knownSAXNotSupportedException- if the requested feature is known but not supported
-
setProperty
public void setProperty(String propertyId, Object value) throws SAXNotRecognizedException, SAXNotSupportedException Sets the value of any property in a SAX2 parser. The parser might not recognize the property, and if recognized, might not support the requested value.- Parameters:
propertyId- the unique identifier (URI) of the property being setvalue- the value to which the property is being set- Throws:
SAXNotRecognizedException- if the requested property is not knownSAXNotSupportedException- if the requested property is known, but the requested value is not supported
-
getXMLParserConfiguration
Returns this parser'sXMLParserConfiguration.- Returns:
- the parser's configuration
-