Java Reference
In-Depth Information
namespace-prefixes decides whether a namespace declaration's xmlns and
xmlns: prefix attributes are included in the Attributes list passed to
startElement() ,andalsodecideswhetherqualifiednamesarepassedasthemeth-
od's third argument—a qualified name is a prefix plus a local name. It defaults to
false ,meaningthat xmlns and xmlns: prefix arenotincluded,andthatparsers
don'thavetopassqualifiednames.Nopropertiesaremandatory.TheJDKdocument-
ation's org.xml.sax package page lists standard SAX 2 features and properties.
The setProperty() call assigns an instance of a class that implements the
org.xml.sax.ext.LexicalHandler interface to the lexical-handler
property so that interface methods can be called to report on comments, CDATA sec-
tions,andsoon.Propertynamesareprefixedwith http://xml.org/sax/prop-
erties/ .
Note Unlike ContentHandler , DTDHandler , EntityResolver , and Er-
rorHandler , LexicalHandler is an extension (it is not part of the core SAX
API), which is why XMLReader does not declare a void setLexicalHand-
ler(LexicalHandler handler) method.Ifyouwanttoinstallalexicalhand-
ler, you must use XMLReader 's setProperty() method to install the handler
asthevalueofthe http://xml.org/sax/properties/lexical-handler
property.
Featuresandpropertiescanberead-onlyorread-write.(Insomerarecases,afeature
orpropertymightbewrite-only.)Whensettingorreadingafeatureorproperty,eithera
SAXNotSupportedException ora SAXNotRecognizedException instance
mightbethrown.Forexample,ifyoutrytomodifyaread-onlyfeature/property,anin-
stanceofthe SAXNotSupportedException classisthrown.Thisexceptioncould
alsobethrownifyoucall setFeature() or setProperty() duringparsing.Try-
ingtosetthevalidationfeatureforaparserthatdoesn'tperformvalidationisascenario
where an instance of the SAXNotRecognizedException class is thrown.
The handlers installed by setContentHandler() , setDTDHandler() , and
setErrorHandler() , the entity resolver installed by setEntityResolver() ,
and the handler installed by the lexical-handler property/ LexicalHandler
interfaceprovidevariouscallbackmethodsthatyouneedtounderstandbeforeyoucan
codifythemtorespondeffectivelytoparsingevents. ContentHandler declaresthe
following content-oriented informational callback methods:
Search WWH ::




Custom Search