- All Implemented Interfaces:
XMLDocumentHandler,XMLReader
- Direct Known Subclasses:
SAXParser
- Author:
- Arnaud Le Hors, IBM, Andy Clark, IBM, Ronald Brill
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanLexical handler parameter entities.protected NamespaceContextNamespace context.protected booleanNamespace prefixes.protected booleanNamespaces.protected booleanStandalone document declaration.protected Stringprotected static final StringProperty id: lexical handler.protected static final StringFeature identifier: namespaces.Fields inherited from class org.htmlunit.cyberneko.xerces.parsers.AbstractXMLDocumentParser
ERROR_HANDLER, parserConfiguration_ -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an abstract SAX parser with the specified configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(XMLString text, Augmentations augs) Character content.voidcomment(XMLString text, Augmentations augs) A comment.voiddoctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) Notifies of the presence of the DOCTYPE line in the document.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.protected final voidSends endPrefixMapping events.Returns the current content handler.Returns the current DTD handler.Returns the current entity resolver.Returns the current error handler.booleangetFeature(String featureId) Queries the state of a feature.protected LexicalHandlerReturns the lexical event handler.getProperty(String propertyId) Queries the value of a property.voidParses the input source specified by the given system identifier.voidparse(InputSource inputSource) voidprocessingInstruction(String target, XMLString data, Augmentations augs) A processing instruction.voidreset()Resets all components before parsing.voidsetContentHandler(ContentHandler contentHandler) Allows an application to register a content event handler.voidsetDTDHandler(DTDHandler dtdHandler) Allows an application to register a DTD event handler.voidsetEntityResolver(EntityResolver resolver) 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.protected voidsetLexicalHandler(LexicalHandler handler) Sets the lexical event handler.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.protected final voidSends startPrefixMapping events.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
emptyElement, getDocumentSource, parse, setDocumentSource
-
Field Details
-
NAMESPACES
Feature identifier: namespaces.- See Also:
-
LEXICAL_HANDLER
Property id: lexical handler.- See Also:
-
fNamespaces
protected boolean fNamespacesNamespaces. -
fNamespacePrefixes
protected boolean fNamespacePrefixesNamespace prefixes. -
fLexicalHandlerParameterEntities
protected boolean fLexicalHandlerParameterEntitiesLexical handler parameter entities. -
fStandalone
protected boolean fStandaloneStandalone document declaration. -
fNamespaceContext
Namespace context. -
fVersion
-
-
Constructor Details
-
AbstractSAXParser
Constructs an abstract SAX parser with the specified configuration.- Parameters:
config- the parser configuration
-
-
Method Details
-
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 document locator, ornullif location cannot be reported. 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, 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 is 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
-
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
-
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 contains 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
-
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
-
parse
Parses the input source specified by the given system identifier.This method is equivalent to the following:
parse(new InputSource(systemId));
- Specified by:
parsein interfaceXMLReader- Parameters:
systemId- the system identifier (URI)- Throws:
SAXException- thrown on SAX errorIOException- thrown on I/O error
-
parse
- Specified by:
parsein interfaceXMLReader- Throws:
SAXExceptionIOException
-
setEntityResolver
- Specified by:
setEntityResolverin interfaceXMLReader
-
getEntityResolver
Returns the current entity resolver.- Specified by:
getEntityResolverin interfaceXMLReader- Returns:
- the current entity resolver, or
nullif none has been registered - See Also:
-
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 are 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.
- Specified by:
setErrorHandlerin interfaceXMLReader- Parameters:
errorHandler- the error handler- See Also:
-
getErrorHandler
Returns the current error handler.- Specified by:
getErrorHandlerin interfaceXMLReader- Returns:
- the current error handler, or
nullif none has been registered - See Also:
-
setDTDHandler
Allows an application to register a DTD event handler.If the application does not register a DTD handler, all DTD events reported by the SAX parser are silently ignored.
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.
- Specified by:
setDTDHandlerin interfaceXMLReader- Parameters:
dtdHandler- the DTD handler- See Also:
-
setContentHandler
Allows an application to register a content event handler.If the application does not register a content handler, all content events reported by the SAX parser are silently ignored.
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.
- Specified by:
setContentHandlerin interfaceXMLReader- Parameters:
contentHandler- the content handler- See Also:
-
getContentHandler
Returns the current content handler.- Specified by:
getContentHandlerin interfaceXMLReader- Returns:
- the current content handler, or
nullif none has been registered - See Also:
-
getDTDHandler
Returns the current DTD handler.- Specified by:
getDTDHandlerin interfaceXMLReader- Returns:
- the current DTD 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.- Specified by:
setFeaturein interfaceXMLReader- 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.
- Specified by:
getFeaturein interfaceXMLReader- 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.- Specified by:
setPropertyin interfaceXMLReader- 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
-
getProperty
public Object getProperty(String propertyId) throws SAXNotRecognizedException, SAXNotSupportedException Queries the value of a property.Returns the current value of a property in a SAX2 parser. The parser might not recognize the property.
- Specified by:
getPropertyin interfaceXMLReader- Parameters:
propertyId- the unique identifier (URI) of the property being queried- Returns:
- the current value of the property
- Throws:
SAXNotRecognizedException- if the requested property is not knownSAXNotSupportedException- if the requested property is known but not supported
-
setLexicalHandler
Sets the lexical event handler.This method is the equivalent to the property:
http://xml.org/sax/properties/lexical-handler
- Parameters:
handler- the lexical event handler- Throws:
SAXNotSupportedException- on error- See Also:
-
getLexicalHandler
Returns the lexical event handler.- Returns:
- the lexical handler, or
nullif none is set - See Also:
-
startNamespaceMapping
Sends startPrefixMapping events.- Throws:
SAXException- on error
-
endNamespaceMapping
Sends endPrefixMapping events.- Throws:
SAXException- on error
-
reset
Resets all components before parsing.- Overrides:
resetin classAbstractXMLDocumentParser- Throws:
XNIException- thrown if an error occurs during initialization
-