Java Reference
In-Depth Information
uri : The namespace URI for the element name. This is an empty string if there is no
URI or if namespace processing is not being done.
localName : The unqualified local name for the element. This is an empty string if
namespace processing is not being done. In this case the element name is reported via
the qName parameter.
qName : The qualified name for the element. This is just the name if the parser is not
namespace-aware. (A colon, if it appears, is then just an ordinary character.)
attr : Encapsulates the attributes for the element that have explicit values.
void endElement(String uri, String localName, String qName) : Called when the end of
an element is recognized. The parameters are as described for the startElement() method.
void characters(char[] ch, int start, int length) : Called for each segment of character
data that is recognized. Note that a contiguous segment of text within an element can be returned
as several chunks by the parser via several calls to this method. The characters that are available
are from ch[start] to ch[start+length-1] , and you must not try to access the array outside
these limits.
void ignorableWhitespace(char[] ch, int start, int length) : Called for each segment
of ignorable whitespace that is recognized within the content of an element. Note that a contiguous
segment of ignorable whitespace within an element can be returned as several chunks by the parser
via several calls to this method. The whitespace characters that are available are from ch[start]
to ch[start+length-1] , and you must not try to access the array outside these limits.
void startPrefixMapping(String prefix, String uri) : Called when the start of a prefix
URI namespace mapping is identified. Most of the time you can disregard this method, as a parser
automatically replaces prefixes for elements and attribute names by default.
void endPrefixMapping(String prefix) : Called when the end of a prefix URI namespace
mapping is identified. Most of the time you can disregard this method for the reason noted in the
preceding method.
void processingInstruction(String target, String data) : Called for each processing
instruction that is recognized.
void skippedEntity(String name) : Called for each entity that the parser skips.
void setDocumentLocator(Locator locator) : Called by the parser to pass a Locator object
to your code that you can use to determine the location in the document of any SAX document
event. The Locator object can provide the public identifier, the system ID, the line number, and
the column number in the document for any event. Just implement this method if you want to re-
ceive this information for each event.
Your implementations of these methods can throw an exception of type SAXException if an error occurs.
When the startElement() method is called, it receives a reference to an object of type
org.xml.sax.Attributes as the last argument. This object encapsulates information about all the attrib-
utes for the element. The Attributes interface declares methods you can call for the object to obtain details
of each attribute name, its type, and its value. These methods use either an index value to select a particular
attribute or an attribute name — either a prefix qualified name or a name qualified by a namespace name. I
just describe the methods relating to using an index because that's what the code examples use. Index values
start from 0. The methods that the Attributes interface declares for accessing attribute information using
an index are as follows:
Search WWH ::




Custom Search