How the LexicalHandler Works
To be informed when the SAX parser sees lexical information, you configure the XmlReader
that underlies the parser with a LexicalHandler
. The LexicalHandler
interface defines these event-handling methods:
comment(String comment)
Passes comments to the application
startCDATA(), endCDATA()
Tells when a CDATA
section is starting and ending, which tells your application what kind of characters to expect the next time characters()
is called
startEntity(String name), endEntity(String name)
Gives the name of a parsed entity
startDTD(String name, String publicId, String systemId), endDTD()
Tells when a DTD is being processed, and identifies it
下面是具体的函数体
public void comment(char[] ch, int start, int length)
throws SAXException
{
}
public void startCDATA()
throws SAXException
{
}
pubic void endCDATA()
throws SAXException
{
}
public void startEntity(String name)
throws SAXException
{
}
public void endEntity(String name)
throws SAXException
{
}
public void startDTD(
String name, String publicId, String systemId)
throws SAXException
{
}
public void endDTD()
throws SAXException
{
}
当startEntity(String name)和endEntity(String name)遇到DTD声明中部分,打印出来的内容,是StartEntity:[dtd],对于多个entity声明也只生成这一个打印。不显示具体的entity定义的变量的名字,只显示[dtd].

