The DeclHandler Interface
DeclHandler
is a callback interface that provides information about
the ELEMENT
, ATTLIST
, and parsed ENTITY
declarations in the document's
DTD. To configure an XMLReader
with a DeclHandler
, pass the
name http://xml.org/sax/properties/DeclHandler
and an instance of the handler to the reader's setProperty( )
method:
try { parser.setProperty( "http://xml.org/sax/properties/DeclHandler", new YourDeclHandlerImplementationClass( )); } catch(SAXException ex) { System.out.println("This parser does not provide declarations."); }
If the parser does not provide declaration events, it throws
a SAXNotRecognizedException
. If the parser
cannot install a DeclHandler
at
this moment (generally because it's in the middle of parsing a
document), then it throws a SAXNotSupportedException
. If it doesn't
throw one of these exceptions, it will call back to the methods in
your DeclHandler
as it parses
the DTD:
package org.xml.sax.ext; public interfaceDeclHandler
{ public voidelementDecl
(Stringname
, Stringmodel
) throws SAXException; public voidattributeDecl
(StringelementName
, StringattributeName
, Stringtype
, StringdefaultValue
, Stringvalue
) throws SAXException; public voidinternalEntityDecl
(Stringname
, Stringvalue
) throws SAXException; public voidexternalEntityDecl
(Stringname
, StringpublicID
, StringsystemID
) throws SAXException; }