DocumentHandler
接口。它已被DefaultHandler
SAX2类替换。
public class HandlerBase extends Object implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.
实施四SAX1接口默认的行为:这类entityresolver,DTDHandler,documenthandler,和ErrorHandler。它已经过时了,但包括在SAX2支持遗留SAX1应用。SAX2应用程序应该使用DefaultHandler
类代替。
作者可以将这类应用时,只需实现一个接口的一部分;解析器的作家可以实例化这个类提供默认处理程序,当应用程序没有提供其自己的。
请注意,这个类的使用是可选的。
EntityResolver
,
DTDHandler
,
DocumentHandler
,
ErrorHandler
Constructor and Description |
---|
HandlerBase()
过时的。
|
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch, int start, int length)
过时的。
在一个元素中接收字符数据的通知。
|
void |
endDocument()
过时的。
接收文档的结尾的通知。
|
void |
endElement(String name)
过时的。
接收一个元素的结束的通知。
|
void |
error(SAXParseException e)
过时的。
接收可恢复分析器错误的通知。
|
void |
fatalError(SAXParseException e)
过时的。
报告一个致命的XML分析错误。
|
void |
ignorableWhitespace(char[] ch, int start, int length)
过时的。
收到可忽略空白元素内容的通知。
|
void |
notationDecl(String name, String publicId, String systemId)
过时的。
接收符号声明的通知。
|
void |
processingInstruction(String target, String data)
过时的。
接收处理指令的通知。
|
InputSource |
resolveEntity(String publicId, String systemId)
过时的。
解析外部实体。
|
void |
setDocumentLocator(Locator locator)
过时的。
接收文档事件的定位对象。
|
void |
startDocument()
过时的。
接收文档开始的通知。
|
void |
startElement(String name, AttributeList attributes)
过时的。
接收元素开始的通知。
|
void |
unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
过时的。
收到未分析实体声明通知。
|
void |
warning(SAXParseException e)
过时的。
接收语法分析器警告的通知。
|
public InputSource resolveEntity(String publicId, String systemId) throws SAXException
总是返回null,以便解析器将使用在XML文档中提供的系统标识符。此方法实现SAX应用默认的行为:作家可以重写它的子类来做特殊的翻译如目录查找或URI重定向。
resolveEntity
接口
EntityResolver
publicId
-公共标识符,或null,如果没有可用的。
systemId
- XML文档中提供的标识系统。
SAXException
-萨克斯例外,可能是包装的另一个例外。
EntityResolver.resolveEntity(java.lang.String, java.lang.String)
public void notationDecl(String name, String publicId, String systemId)
默认情况下,什么都不做。应用程序编写者可以在子类中重写此方法,如果他们希望记录在文档中声明的符号。
notationDecl
接口
DTDHandler
name
-符号名称。
publicId
-符号的公共标识符,或空如果不可用。
systemId
-符号系统标识符。
DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
默认情况下,什么都不做。应用作者可以在子类中记录的未分析实体重写此方法在一个文件中声明。
unparsedEntityDecl
接口
DTDHandler
name
-实体名称。
publicId
公共标识符的实体,或空如果不可用。
systemId
-实体系统标识符。
notationName
-相关的符号名称。
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void setDocumentLocator(Locator locator)
默认情况下,什么都不做。应用程序编写者可以在子类中重写此方法,如果他们希望存储与其他文档事件一起使用的定位器。
setDocumentLocator
接口
DocumentHandler
locator
-所有SAX文档事件定位。
DocumentHandler.setDocumentLocator(org.xml.sax.Locator)
,
Locator
public void startDocument() throws SAXException
默认情况下,什么都不做。应用程序编写者可以在子类中重写此方法,以在文档开始时采取特定的操作(如分配树的根节点或创建输出文件)。
startDocument
接口
DocumentHandler
SAXException
-萨克斯例外,可能是包装的另一个例外。
DocumentHandler.startDocument()
public void endDocument() throws SAXException
默认情况下,什么都不做。应用作家可能在子类在文件最后采取具体行动,重写此方法(如完成一棵树或关闭输出文件)。
endDocument
接口
DocumentHandler
SAXException
-萨克斯例外,可能是包装的另一个例外。
DocumentHandler.endDocument()
public void startElement(String name, AttributeList attributes) throws SAXException
默认情况下,什么都不做。应用程序编写者可以在子类中重写此方法,在每个元素的开始处采取特定的动作(例如,分配一个新的树节点或将输出写入到文件)。
startElement
接口
DocumentHandler
name
-元素类型的名称。
attributes
-指定或默认的属性。
SAXException
-萨克斯例外,可能是包装的另一个例外。
DocumentHandler.startElement(java.lang.String, org.xml.sax.AttributeList)
public void endElement(String name) throws SAXException
默认情况下,什么都不做。应用作家可能在子类中的每个元素在年底采取具体行动,重写此方法(如完成一个树节点或写作输出到文件)。
endElement
接口
DocumentHandler
name
-元素名称
SAXException
-萨克斯例外,可能是包装的另一个例外。
DocumentHandler.endElement(java.lang.String)
public void characters(char[] ch, int start, int length) throws SAXException
默认情况下,什么都不做。应用程序编写者可以重写此方法以对每个字符数据(如将数据添加到一个节点或缓冲区中,或将其打印到文件)采取特定的操作。
characters
接口
DocumentHandler
ch
-特点。
start
-字符数组中的起始位置。
length
-字符数使用字符数组。
SAXException
-萨克斯例外,可能是包装的另一个例外。
DocumentHandler.characters(char[], int, int)
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
默认情况下,什么都不做。应用作家可以重写此方法以每一块可忽略空白采取具体行动(如添加数据节点或缓冲,或打印到文件)。
ignorableWhitespace
接口
DocumentHandler
ch
的空白字符。
start
-字符数组中的起始位置。
length
-字符数使用字符数组。
SAXException
-萨克斯例外,可能是包装的另一个例外。
DocumentHandler.ignorableWhitespace(char[], int, int)
public void processingInstruction(String target, String data) throws SAXException
默认情况下,什么都不做。应用程序编写者可以在子类中重写此方法,以对每个处理指令采取特定的操作,如设置状态变量或调用其他方法。
processingInstruction
接口
DocumentHandler
target
-处理指令的目标。
data
-处理指令数据,或null,如果没有提供。
SAXException
-萨克斯例外,可能是包装的另一个例外。
DocumentHandler.processingInstruction(java.lang.String, java.lang.String)
public void warning(SAXParseException e) throws SAXException
默认实现不做任何事。应用程序编写者可以在子类中重写此方法,以对每个警告采取特定的操作,例如将消息插入到日志文件中或将其打印到控制台上。
warning
接口
ErrorHandler
e
编码为例外的警告信息。
SAXException
-萨克斯例外,可能是包装的另一个例外。
ErrorHandler.warning(org.xml.sax.SAXParseException)
,
SAXParseException
public void error(SAXParseException e) throws SAXException
默认实现不做任何事。应用程序编写者可以在子类中重写此方法,以对每个错误采取特定的操作,例如将消息插入到日志文件中或将其打印到控制台上。
error
接口
ErrorHandler
e
编码为例外的警告信息。
SAXException
-萨克斯例外,可能是包装的另一个例外。
ErrorHandler.warning(org.xml.sax.SAXParseException)
,
SAXParseException
public void fatalError(SAXParseException e) throws SAXException
默认实现抛出一个saxparseexception。应用程序编写者可以在子类中重写此方法,如果他们需要为每个致命错误采取特定的操作(例如将所有的错误收集到一个报告):在任何情况下,应用程序必须停止所有的常规处理,当这种方法被调用,因为文档不再可靠,和解析器可能不再报告分析事件。
fatalError
接口
ErrorHandler
e
编码作为一种异常的错误信息。
SAXException
-萨克斯例外,可能是包装的另一个例外。
ErrorHandler.fatalError(org.xml.sax.SAXParseException)
,
SAXParseException
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.