Java Reference
In-Depth Information
•
void characters(char[] ch, int start, int length)
reports an element's character data via the
ch
array. The arguments that are
passedto
start
and
length
identifythatportionofthearraythat'srelevant
to this method call. Characters are passed via a
char[]
array instead of via
a
String
instance as a performance optimization. Parsers commonly store a
largeamountofthedocumentinanarrayandrepeatedlypassareferencetothis
array along with updated
start
and
length
values to
characters()
.
•
void endDocument()
reports that the end of the document has been
reached.Anapplicationmightusethismethodtocloseanoutputfileorperform
some other cleanup.
•
void endElement(String uri, String localName, String
qName)
reports that the end of an element has been reached.
uri
identifies
the element's namespace URI, or is empty when there is no namespace URI
ornamespaceprocessinghasnotbeenenabled.
localName
identifiestheele-
ment's local name, which is the name without a prefix (the
html
in
html
or
h:html
,forexample).
qName
referencesthequalifiedname;forexample,
h:html
or
html
whenthereisnoprefix.
endElement()
isinvokedwhen
anendtagisdetected,orimmediatelyfollowing
startElement()
whenan
empty-element tag is detected.
•
void endPrefixMapping(String prefix)
reports that the end of
a namespace prefix mapping (
xmlns:h
, for example) has been reached, and
prefix
reports this prefix (
h
, for example).
•
void ignorableWhitespace(char[] ch, int start, int
length)
reports
ignorable whitespace
(whitespace located between tags
wheretheDTDdoesn'tallowmixedcontent).Thiswhitespaceisoftenusedto
indent tags. The parameters serve the same purpose as those in the
charac-
ters()
method.
•
void processingInstruction(String target, String
data)
reports a processing instruction, where
target
identifies the applic-
ation to which the instruction is directed and
data
provides the instruction's
data (the null reference when there is no data).
•
void setDocumentLocator(Locator locator)
reports an
org.xml.sax.Locator
object (an instance of a class implementing the
Locator
interface) whose
int getColumnNumber()
,
int
getLineNumber()
,
String getPublicId()
, and
String
getSystemId()
methodscanbecalledtoobtainlocationinformationatthe