Skip to Content
Java in a Nutshell, 5th Edition
book

Java in a Nutshell, 5th Edition

by David Flanagan
March 2005
Intermediate to advanced
1254 pages
104h 21m
English
O'Reilly Media, Inc.
Content preview from Java in a Nutshell, 5th Edition

Name

LexicalHandler

Synopsis

This extension interface defines methods that a SAX parser can call to notify an application about the lexical structure of an XML document. If your application requires this kind of information (for example if it wants to create a new document that has a similar structure to the one it reads), then pass an object that implements this interface to the setProperty( ) method of an XMLReader, using the property name “http://www.xml.org/sax/properties/lexical-handler”. Because this is an extension handler, SAX parsers are not required to support it, and may throw a SAXNotRecognizedException or a SAXNotSupportedException when you attempt to register a DeclHandler.

If a LexicalHandler is successfully registered on an XMLReader, then the parser will call startDTD( ) and endDTD( ) to report the beginning and end of the document’s DTD. It will call startCDATA( ) and endCDATA( ) to report the start and end of a CDATA section. The content of the CDATA section will be reported through the characters( ) method of the ContentHandler interface. When the parser expands an entity, it first calls startEntity( ) to specify the name of the entity it is about to expand, and then calls endEntity( ) when the entity expansion is complete. Finally, whenever the parser encounters an XML comment, it calls the comment( ) method.

public interface LexicalHandler {
// Public Instance Methods
     void comment(char[ ] ch, int start, int length) 
        throws org.xml.sax.SAXException;  
     void endCDATA ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java in a Nutshell, 8th Edition

Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Learning Java, 4th Edition

Learning Java, 4th Edition

Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 0596007736Supplemental ContentErrata Page