public class DOMFragmentParser extends Object implements XMLDocumentHandler
| Modifier and Type | Field and Description |
|---|---|
protected static String |
DOCUMENT_FRAGMENT
Document fragment balancing only.
|
protected static String |
ERROR_HANDLER
Property identifier: error handler.
|
protected Node |
fCurrentNode
Current node.
|
protected Document |
fDocument
Document.
|
protected DocumentFragment |
fDocumentFragment
DOM document fragment.
|
protected XMLDocumentSource |
fDocumentSource
Document source.
|
protected boolean |
fInCDATASection
True if within a CDATA section.
|
protected XMLParserConfiguration |
fParserConfiguration
Parser configuration.
|
protected static String[] |
RECOGNIZED_FEATURES
Recognized features.
|
protected static String[] |
RECOGNIZED_PROPERTIES
Recognized properties.
|
| Constructor and Description |
|---|
DOMFragmentParser()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(XMLString text,
Augmentations augs)
Character content.
|
void |
comment(XMLString text,
Augmentations augs)
A comment.
|
void |
doctypeDecl(String root,
String pubid,
String sysid,
Augmentations augs)
Notifies of the presence of the DOCTYPE line in the document.
|
void |
emptyElement(QName element,
XMLAttributes attrs,
Augmentations augs)
An empty element.
|
void |
endCDATA(Augmentations augs)
End CDATA section.
|
void |
endDocument(Augmentations augs)
End document.
|
void |
endElement(QName element,
Augmentations augs)
End element.
|
void |
endGeneralEntity(String name,
Augmentations augs)
End general entity.
|
XMLDocumentSource |
getDocumentSource()
Returns the document source.
|
ErrorHandler |
getErrorHandler()
Return the current error handler.
|
boolean |
getFeature(String featureId)
Query the state of a feature.
|
void |
ignorableWhitespace(XMLString text,
Augmentations augs)
Ignorable whitespace.
|
void |
parse(InputSource source,
DocumentFragment fragment)
Parses a document fragment
|
void |
parse(String systemId,
DocumentFragment fragment)
Parses a document fragment
|
void |
processingInstruction(String target,
XMLString data,
Augmentations augs)
A processing instruction.
|
void |
setDocumentSource(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(Augmentations augs)
Start CDATA section.
|
void |
startDocument(XMLLocator locator,
String encoding,
NamespaceContext nscontext,
Augmentations augs)
The start of the document.
|
void |
startElement(QName element,
XMLAttributes attrs,
Augmentations augs)
The start of an element.
|
void |
startGeneralEntity(String name,
XMLResourceIdentifier id,
String encoding,
Augmentations augs)
Start general entity.
|
void |
textDecl(String version,
String encoding,
Augmentations augs)
Text declaration.
|
void |
xmlDecl(String version,
String encoding,
String standalone,
Augmentations augs)
Notifies of the presence of an XMLDecl line in the document.
|
protected static final String DOCUMENT_FRAGMENT
protected static final String[] RECOGNIZED_FEATURES
protected static final String ERROR_HANDLER
protected static final String[] RECOGNIZED_PROPERTIES
protected final XMLParserConfiguration fParserConfiguration
protected XMLDocumentSource fDocumentSource
protected DocumentFragment fDocumentFragment
protected Document fDocument
protected Node fCurrentNode
protected boolean fInCDATASection
public void parse(String systemId, DocumentFragment fragment) throws SAXException, IOException
systemId - systemIdfragment - fragmentSAXException - in case of sax errorIOException - in case of io problemspublic void parse(InputSource source, DocumentFragment fragment) throws SAXException, IOException
source - input sourcefragment - fragmentSAXException - in case of sax errorIOException - in case of io problemspublic 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 void setDocumentSource(XMLDocumentSource source)
setDocumentSource in interface XMLDocumentHandlersource - the new sourcepublic XMLDocumentSource getDocumentSource()
getDocumentSource in interface XMLDocumentHandlerpublic void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs) throws XNIException
XMLDocumentHandlerstartDocument in interface XMLDocumentHandlerlocator - The document locator, or null if the document
location cannot be reported during the parsing of
this document. However, it is strongly
recommended that a locator be supplied that can at
least report the system identifier of the document.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).nscontext - 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
XMLDocumentHandlerxmlDecl in interface XMLDocumentHandlerversion - 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 root, String pubid, String sysid, Augmentations augs) throws XNIException
XMLDocumentHandlerdoctypeDecl in interface XMLDocumentHandlerroot - The name of the root element.pubid - The public identifier if an external DTD or null if the
external DTD is specified using SYSTEM.sysid - 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 processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException
XMLDocumentHandlerTypically, 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 XMLDocumentHandlertarget - 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 comment(XMLString text, Augmentations augs) throws XNIException
XMLDocumentHandlercomment in interface XMLDocumentHandlertext - The text in the comment.augs - Additional information that may include infoset augmentationsXNIException - Thrown by application to signal an error.public void startElement(QName element, XMLAttributes attrs, Augmentations augs) throws XNIException
XMLDocumentHandlerstartElement in interface XMLDocumentHandlerelement - The name of the element.attrs - The element attributes.augs - Additional information that may include infoset
augmentationsXNIException - Thrown by handler to signal an error.public void emptyElement(QName element, XMLAttributes attrs, Augmentations augs) throws XNIException
XMLDocumentHandleremptyElement in interface XMLDocumentHandlerelement - The name of the element.attrs - 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
XMLDocumentHandlercharacters in interface XMLDocumentHandlertext - 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 XMLDocumentHandlertext - The ignorable whitespace.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs) throws XNIException
startGeneralEntity in interface XMLDocumentHandlername - The name of the general entity.id - 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
textDecl in interface XMLDocumentHandlerversion - 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 endGeneralEntity(String name, Augmentations augs) throws XNIException
endGeneralEntity in interface XMLDocumentHandlername - The name of the entity.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 XMLDocumentHandleraugs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void endCDATA(Augmentations augs) throws XNIException
endCDATA in interface XMLDocumentHandleraugs - 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 XMLDocumentHandlerelement - The name of the element.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void endDocument(Augmentations augs) throws XNIException
endDocument in interface XMLDocumentHandleraugs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.Copyright © 2023 Gargoyle Software Inc.. All rights reserved.