public class AbstractDOMParser extends AbstractXMLDocumentParser
getDocument method. The actual pipeline is defined in
parser configuration.| Modifier and Type | Field and Description |
|---|---|
protected static String |
CREATE_CDATA_NODES_FEATURE
Feature id: create cdata nodes.
|
protected static String |
CREATE_ENTITY_REF_NODES
Feature id: create entity ref nodes.
|
protected Stack<String> |
fBaseURIStack
Base uri stack
|
protected boolean |
fCreateCDATANodes
Create cdata nodes.
|
protected boolean |
fCreateEntityRefNodes
Create entity reference nodes.
|
protected CDATASection |
fCurrentCDATASection |
protected EntityImpl |
fCurrentEntityDecl |
protected Node |
fCurrentNode
Current node.
|
protected Document |
fDocument
The document.
|
protected Class<? extends DocumentImpl> |
fDocumentClass
The document class to use.
|
protected CoreDocumentImpl |
fDocumentImpl
The default Xerces document implementation, if used.
|
protected DocumentType |
fDocumentType
The document type node.
|
protected boolean |
fFilterReject
LSParserFilter: specifies that element with given QNAME and all its children
must be rejected
|
protected boolean |
fFirstChunk
True if saw the first chunk of characters
|
protected boolean |
fInCDATASection
True if inside CDATA section.
|
protected boolean |
fIncludeComments
Include Comments.
|
protected boolean |
fIncludeIgnorableWhitespace
Include ignorable whitespace.
|
protected boolean |
fNamespaceAware |
protected int |
fRejectedElementDepth
LSParserFilter: tracks the element depth within a rejected subtree.
|
protected StringBuffer |
fStringBuffer
Character buffer
|
protected static String |
INCLUDE_COMMENTS_FEATURE
Feature id: include comments.
|
protected static String |
INCLUDE_IGNORABLE_WHITESPACE
Feature id: include ignorable whitespace.
|
protected static String |
NAMESPACES
Feature id: namespace.
|
fDocumentSourceERROR_HANDLER, fConfiguration| Modifier | Constructor and Description |
|---|---|
protected |
AbstractDOMParser(XMLParserConfiguration config,
Class<? extends DocumentImpl> documentClass) |
| Modifier and Type | Method and Description |
|---|---|
void |
characters(XMLString text,
Augmentations augs)
Character content.
|
void |
comment(XMLString text,
Augmentations augs)
A comment.
|
protected Attr |
createAttrNode(QName attrQName) |
protected Element |
createElementNode(QName element) |
void |
doctypeDecl(String rootElement,
String publicId,
String systemId,
Augmentations augs)
Notifies of the presence of the DOCTYPE line in the document.
|
void |
emptyElement(QName element,
XMLAttributes attributes,
Augmentations augs)
An empty element.
|
void |
endCDATA(Augmentations augs)
The end of a CDATA section.
|
void |
endDocument(Augmentations augs)
The end of the document.
|
void |
endElement(QName element,
Augmentations augs)
The end of an element.
|
void |
endGeneralEntity(String name,
Augmentations augs)
This method notifies the end of a general entity.
|
Document |
getDocument() |
ErrorHandler |
getErrorHandler()
Return the current error handler.
|
boolean |
getFeature(String featureId)
Query the state of a feature.
|
XMLParserConfiguration |
getXMLParserConfiguration() |
protected void |
handleBaseURI(Node node)
Record baseURI information for the Element (by adding xml:base attribute)
or for the ProcessingInstruction (by setting a baseURI field)
Non deferred DOM.
|
void |
ignorableWhitespace(XMLString text,
Augmentations augs)
Ignorable whitespace.
|
void |
parse(InputSource inputSource)
Parse.
|
void |
parse(String systemId)
Parses the input source specified by the given system identifier.
|
void |
processingInstruction(String target,
XMLString data,
Augmentations augs)
A processing instruction.
|
void |
reset()
Resets the parser state.
|
protected void |
setCharacterData(boolean sawChars) |
protected void |
setDocumentClass(Class<? extends DocumentImpl> documentClass)
This method allows the programmer to decide which document
factory to use when constructing the DOM tree.
|
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(Augmentations augs)
The start of a CDATA section.
|
void |
startDocument(XMLLocator locator,
String encoding,
NamespaceContext namespaceContext,
Augmentations augs)
The start of the document.
|
void |
startElement(QName element,
XMLAttributes attributes,
Augmentations augs)
The start of an element.
|
void |
startGeneralEntity(String name,
XMLResourceIdentifier identifier,
String encoding,
Augmentations augs)
This method notifies the start of a general entity.
|
void |
textDecl(String version,
String encoding,
Augmentations augs)
Notifies of the presence of a TextDecl line in an entity.
|
void |
xmlDecl(String version,
String encoding,
String standalone,
Augmentations augs)
Notifies of the presence of an XMLDecl line in the document.
|
getDocumentSource, setDocumentSourceprotected static final String NAMESPACES
protected static final String CREATE_ENTITY_REF_NODES
protected static final String INCLUDE_COMMENTS_FEATURE
protected static final String CREATE_CDATA_NODES_FEATURE
protected static final String INCLUDE_IGNORABLE_WHITESPACE
protected boolean fCreateEntityRefNodes
protected boolean fIncludeIgnorableWhitespace
protected boolean fIncludeComments
protected boolean fCreateCDATANodes
protected Document fDocument
protected CoreDocumentImpl fDocumentImpl
protected Class<? extends DocumentImpl> fDocumentClass
protected DocumentType fDocumentType
protected Node fCurrentNode
protected CDATASection fCurrentCDATASection
protected EntityImpl fCurrentEntityDecl
protected final StringBuffer fStringBuffer
protected boolean fNamespaceAware
protected boolean fInCDATASection
protected boolean fFirstChunk
protected final boolean fFilterReject
protected int fRejectedElementDepth
protected AbstractDOMParser(XMLParserConfiguration config, Class<? extends DocumentImpl> documentClass)
protected void setDocumentClass(Class<? extends DocumentImpl> documentClass)
documentClass - The document factory to use when constructing
the DOM tree.public Document getDocument()
public void reset()
throws XNIException
reset in class AbstractXMLDocumentParserXNIException - Thrown on initialization error.public void startGeneralEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) throws XNIException
Note: This method is not called for entity references appearing as part of attribute values.
startGeneralEntity in interface XMLDocumentHandlerstartGeneralEntity in class AbstractXMLDocumentParsername - The name of the general entity.identifier - The resource identifier.encoding - The auto-detected IANA encoding name of the entity
stream. This value will be null in those situations
where the entity encoding is not auto-detected (e.g.
internal entities or a document entity that is
parsed from a java.io.Reader).augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void textDecl(String version, String encoding, Augmentations augs) throws XNIException
Note: This method will never be called for the document entity; it is only called for external general entities referenced in document content.
Note: This method is not called for entity references appearing as part of attribute values.
textDecl in interface XMLDocumentHandlertextDecl in class AbstractXMLDocumentParserversion - The XML version, or null if not specified.encoding - The IANA encoding name of the entity.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void comment(XMLString text, Augmentations augs) throws XNIException
comment in interface XMLDocumentHandlercomment in class AbstractXMLDocumentParsertext - The text in the comment.augs - Additional information that may include infoset augmentationsXNIException - Thrown by application to signal an error.public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException
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.
processingInstruction in interface XMLDocumentHandlerprocessingInstruction in class AbstractXMLDocumentParsertarget - The target.data - The data or null if none specified.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException
startDocument in interface XMLDocumentHandlerstartDocument in class AbstractXMLDocumentParserlocator - The system identifier of the entity if the entity
is external, null otherwise.encoding - The auto-detected IANA encoding name of the entity
stream. This value will be null in those situations
where the entity encoding is not auto-detected (e.g.
internal entities or a document entity that is
parsed from a java.io.Reader).namespaceContext - The namespace context in effect at the
start of this document.
This object represents the current context.
Implementors of this class are responsible
for copying the namespace bindings from the
the current context (and its parent contexts)
if that information is important.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException
xmlDecl in interface XMLDocumentHandlerxmlDecl in class AbstractXMLDocumentParserversion - The XML version.encoding - The IANA encoding name of the document, or null if
not specified.standalone - The standalone value, or null if not specified.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) throws XNIException
doctypeDecl in interface XMLDocumentHandlerdoctypeDecl in class AbstractXMLDocumentParserrootElement - The name of the root element.publicId - The public identifier if an external DTD or null
if the external DTD is specified using SYSTEM.systemId - The system identifier if an external DTD, null
otherwise.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException
startElement in interface XMLDocumentHandlerstartElement in class AbstractXMLDocumentParserelement - The name of the element.attributes - The element attributes.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException
emptyElement in interface XMLDocumentHandleremptyElement in class AbstractXMLDocumentParserelement - The name of the element.attributes - The element attributes.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void characters(XMLString text, Augmentations augs) throws XNIException
characters in interface XMLDocumentHandlercharacters in class AbstractXMLDocumentParsertext - The content.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException
ignorableWhitespace in interface XMLDocumentHandlerignorableWhitespace in class AbstractXMLDocumentParsertext - The ignorable whitespace.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void endElement(QName element, Augmentations augs) throws XNIException
endElement in interface XMLDocumentHandlerendElement in class AbstractXMLDocumentParserelement - The name of the element.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void startCDATA(Augmentations augs) throws XNIException
startCDATA in interface XMLDocumentHandlerstartCDATA in class AbstractXMLDocumentParseraugs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void endCDATA(Augmentations augs) throws XNIException
endCDATA in interface XMLDocumentHandlerendCDATA in class AbstractXMLDocumentParseraugs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void endDocument(Augmentations augs) throws XNIException
endDocument in interface XMLDocumentHandlerendDocument in class AbstractXMLDocumentParseraugs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void endGeneralEntity(String name, Augmentations augs) throws XNIException
Note: This method is not called for entity references appearing as part of attribute values.
endGeneralEntity in interface XMLDocumentHandlerendGeneralEntity in class AbstractXMLDocumentParsername - The name of the entity.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.protected final void handleBaseURI(Node node)
node - the nodeprotected void setCharacterData(boolean sawChars)
public void parse(String systemId) throws SAXException, IOException
This method is equivalent to the following:
parse(new InputSource(systemId));
systemId - The system identifier (URI).SAXException - Throws exception on SAX error.IOException - Throws exception on i/o error.public void parse(InputSource inputSource) throws SAXException, IOException
inputSource - the input sourceSAXException - on errorIOException - on errorpublic void setErrorHandler(ErrorHandler errorHandler)
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.
errorHandler - The error handler.NullPointerException - If the handler
argument is null.getErrorHandler()public ErrorHandler getErrorHandler()
setErrorHandler(org.xml.sax.ErrorHandler)public void setFeature(String featureId, boolean state) throws SAXNotRecognizedException, SAXNotSupportedException
featureId - The unique identifier (URI) of the feature.state - The requested state of the feature (true or false).SAXNotRecognizedException - If the
requested feature is not known.SAXNotSupportedException - If the
requested feature is known, but the requested
state is not supported.public boolean getFeature(String featureId) throws SAXNotRecognizedException, SAXNotSupportedException
Query the current state of any feature in a SAX2 parser. The parser might not recognize the feature.
featureId - The unique identifier (URI) of the feature
being set.SAXNotRecognizedException - If the
requested feature is not known.SAXNotSupportedException - If the
requested feature is known but not supported.public void setProperty(String propertyId, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
propertyId - The unique identifier (URI) of the property
being set.value - The value to which the property is being set.SAXNotRecognizedException - If the
requested property is not known.SAXNotSupportedException - If the
requested property is known, but the requested
value is not supported.public XMLParserConfiguration getXMLParserConfiguration()
Copyright © 2023 Gargoyle Software Inc.. All rights reserved.