DefaultHandler2
open class DefaultHandler2 : DefaultHandler, LexicalHandler, DeclHandler, EntityResolver2
This class extends the SAX2 base handler class to support the SAX2 LexicalHandler
, DeclHandler
, and EntityResolver2
extensions. Except for overriding the original SAX1 resolveEntity()
method the added handler methods just return. Subclassers may override everything on a method-by-method basis. This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.
Note: this class might yet learn that the ContentHandler.setDocumentLocator() call might be passed a Locator2
object, and that the ContentHandler.startElement() call might be passed a Attributes2
object.
Summary
Public constructors |
Constructs a handler which ignores all parsing events.
|
Public methods |
open Unit |
|
open Unit |
|
open Unit |
|
open Unit |
|
open Unit |
|
open Unit |
|
open Unit |
|
open InputSource! |
Tells the parser that if no external subset has been declared in the document text, none should be used.
|
open Unit |
|
open InputSource! |
Tells the parser to resolve the systemId against the baseURI and read the entity text from that resulting absolute URI.
|
open InputSource! |
Invokes org.
|
open Unit |
|
open Unit |
|
open Unit |
|
Inherited functions |
From class DefaultHandler
Unit |
characters(ch: CharArray!, start: Int, length: Int)
Receive notification of character data inside an element.
By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).
|
Unit |
endDocument()
Receive notification of the end of the document.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of a document (such as finalising a tree or closing an output file).
|
Unit |
endElement(uri: String!, localName: String!, qName: String!)
Receive notification of the end of an element.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).
|
Unit |
endPrefixMapping(prefix: String!)
Receive notification of the end of a Namespace mapping.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each prefix mapping.
|
Unit |
error(e: SAXParseException!)
Receive notification of a recoverable parser error.
The default implementation does nothing. Application writers may override this method in a subclass to take specific actions for each error, such as inserting the message in a log file or printing it to the console.
|
Unit |
fatalError(e: SAXParseException!)
Report a fatal XML parsing error.
The default implementation throws a SAXParseException. Application writers may override this method in a subclass if they need to take specific actions for each fatal error (such as collecting all of the errors into a single report): in any case, the application must stop all regular processing when this method is invoked, since the document is no longer reliable, and the parser may no longer report parsing events.
|
Unit |
ignorableWhitespace(ch: CharArray!, start: Int, length: Int)
Receive notification of ignorable whitespace in element content.
By default, do nothing. Application writers may override this method to take specific actions for each chunk of ignorable whitespace (such as adding data to a node or buffer, or printing it to a file).
|
Unit |
notationDecl(name: String!, publicId: String!, systemId: String!)
Receive notification of a notation declaration.
By default, do nothing. Application writers may override this method in a subclass if they wish to keep track of the notations declared in a document.
|
Unit |
processingInstruction(target: String!, data: String!)
Receive notification of a processing instruction.
By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.
|
Unit |
setDocumentLocator(locator: Locator!)
Receive a Locator object for document events.
By default, do nothing. Application writers may override this method in a subclass if they wish to store the locator for use with other document events.
|
Unit |
skippedEntity(name: String!)
Receive notification of a skipped entity.
By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.
|
Unit |
startDocument()
Receive notification of the beginning of the document.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the beginning of a document (such as allocating the root node of a tree or creating an output file).
|
Unit |
startElement(uri: String!, localName: String!, qName: String!, attributes: Attributes!)
Receive notification of the start of an element.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
|
Unit |
startPrefixMapping(prefix: String!, uri: String!)
Receive notification of the start of a Namespace mapping.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each Namespace prefix scope (such as storing the prefix mapping).
|
Unit |
unparsedEntityDecl(name: String!, publicId: String!, systemId: String!, notationName: String!)
Receive notification of an unparsed entity declaration.
By default, do nothing. Application writers may override this method in a subclass to keep track of the unparsed entities declared in a document.
|
Unit |
warning(e: SAXParseException!)
Receive notification of a parser warning.
The default implementation does nothing. Application writers may override this method in a subclass to take specific actions for each warning, such as inserting the message in a log file or printing it to the console.
|
|
Public constructors
DefaultHandler2
DefaultHandler2()
Constructs a handler which ignores all parsing events.
Public methods
attributeDecl
open fun attributeDecl(
eName: String!,
aName: String!,
type: String!,
mode: String!,
value: String!
): Unit
Parameters |
eName |
String!: The name of the associated element. |
aName |
String!: The name of the attribute. |
type |
String!: A string representing the attribute type. |
mode |
String!: A string representing the attribute defaulting mode ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies. |
value |
String!: A string representing the attribute's default value, or null if there is none. |
open fun comment(
ch: CharArray!,
start: Int,
length: Int
): Unit
Parameters |
ch |
CharArray!: An array holding the characters in the comment. |
start |
Int: The starting position in the array. |
length |
Int: The number of characters to use from the array. |
elementDecl
open fun elementDecl(
name: String!,
model: String!
): Unit
Parameters |
name |
String!: The element type name. |
model |
String!: The content model as a normalized string. |
endCDATA
open fun endCDATA(): Unit
endDTD
open fun endDTD(): Unit
endEntity
open fun endEntity(name: String!): Unit
Parameters |
name |
String!: The name of the entity that is ending. |
externalEntityDecl
open fun externalEntityDecl(
name: String!,
publicId: String!,
systemId: String!
): Unit
Parameters |
name |
String!: The name of the entity. If it is a parameter entity, the name will begin with '%'. |
publicId |
String!: The entity's public identifier, or null if none was given. |
systemId |
String!: The entity's system identifier. |
getExternalSubset
open fun getExternalSubset(
name: String!,
baseURI: String!
): InputSource!
Tells the parser that if no external subset has been declared in the document text, none should be used.
Parameters |
name |
String!: Identifies the document root element. This name comes from a DOCTYPE declaration (where available) or from the actual root element. The parameter is ignored. |
baseURI |
String!: The document's base URI, serving as an additional hint for selecting the external subset. This is always an absolute URI, unless it is null because the XMLReader was given an InputSource without one. The parameter is ignored. |
Exceptions |
org.xml.sax.SAXException |
Any SAX exception, possibly wrapping another exception. |
java.io.IOException |
Probably indicating a failure to create a new InputStream or Reader, or an illegal URL. |
internalEntityDecl
open fun internalEntityDecl(
name: String!,
value: String!
): Unit
Parameters |
name |
String!: The name of the entity. If it is a parameter entity, the name will begin with '%'. |
value |
String!: The replacement text of the entity. |
resolveEntity
open fun resolveEntity(
name: String!,
publicId: String!,
baseURI: String!,
systemId: String!
): InputSource!
Tells the parser to resolve the systemId against the baseURI and read the entity text from that resulting absolute URI. Note that because the older DefaultHandler.resolveEntity()
, method is overridden to call this one, this method may sometimes be invoked with null name and baseURI, and with the systemId already absolutized.
Parameters |
name |
String!: Identifies the external entity being resolved. Either "[dtd]" for the external subset, or a name starting with "%" to indicate a parameter entity, or else the name of a general entity. This is never null when invoked by a SAX2 parser. |
publicId |
String!: The public identifier of the external entity being referenced (normalized as required by the XML specification), or null if none was supplied. |
baseURI |
String!: The URI with respect to which relative systemIDs are interpreted. This is always an absolute URI, unless it is null (likely because the XMLReader was given an InputSource without one). This URI is defined by the XML specification to be the one associated with the "<" starting the relevant declaration. |
systemId |
String!: The system identifier of the external entity being referenced; either a relative or absolute URI. This is never null when invoked by a SAX2 parser; only declared entities, and any external subset, are resolved by such parsers. |
Return |
InputSource! |
An InputSource object describing the new input source. |
Exceptions |
org.xml.sax.SAXException |
Any SAX exception, possibly wrapping another exception. |
java.io.IOException |
Probably indicating a failure to create a new InputStream or Reader, or an illegal URL. |
resolveEntity
open fun resolveEntity(
publicId: String!,
systemId: String!
): InputSource!
Invokes org.xml.sax.ext.EntityResolver2#resolveEntity with null entity name and base URI. You only need to override that method to use this class.
Parameters |
publicId |
String!: The public identifier of the external entity being referenced (normalized as required by the XML specification), or null if none was supplied. |
systemId |
String!: The system identifier of the external entity being referenced; either a relative or absolute URI. This is never null when invoked by a SAX2 parser; only declared entities, and any external subset, are resolved by such parsers. |
Return |
InputSource! |
An InputSource object describing the new input source. |
Exceptions |
org.xml.sax.SAXException |
Any SAX exception, possibly wrapping another exception. |
java.io.IOException |
Probably indicating a failure to create a new InputStream or Reader, or an illegal URL. |
startCDATA
open fun startCDATA(): Unit
startDTD
open fun startDTD(
name: String!,
publicId: String!,
systemId: String!
): Unit
Parameters |
name |
String!: The document type name. |
publicId |
String!: The declared public identifier for the external DTD subset, or null if none was declared. |
systemId |
String!: The declared system identifier for the external DTD subset, or null if none was declared. (Note that this is not resolved against the document base URI.) |
startEntity
open fun startEntity(name: String!): Unit
Parameters |
name |
String!: The name of the entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be "[dtd]". |