public class XMLReaderAdapter
extends Object implements Parser, ContentHandler
| java.lang.Object | |
| org.xml.sax.helpers.XMLReaderAdapter | |
将SAX2 XMLReader调整为SAX1解析器。
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.
本课程包装SAX2 XMLReader并使其充当SAX1 Parser 。 XMLReader必须支持http://xml.org/sax/features/namespace-prefixes属性的真实值,否则解析将失败,并显示SAXException ; 如果XMLReader支持http://xml.org/sax/features/namespaces属性的假值,那么它也将用于提高效率。
Public constructors |
|
|---|---|
XMLReaderAdapter() 创建一个新的适配器。 |
|
XMLReaderAdapter(XMLReader xmlReader) 创建一个新的适配器。 |
|
公共方法(Public methods) |
|
|---|---|
void |
characters(char[] ch, int start, int length) 调整SAX2角色事件。 |
void |
endDocument() 结束文档事件。 |
void |
endElement(String uri, String localName, String qName) 调整SAX2结束元素事件。 |
void |
endPrefixMapping(String prefix) 调整SAX2结束前缀映射事件。 |
void |
ignorableWhitespace(char[] ch, int start, int length) 调整SAX2可忽略的空白事件。 |
void |
parse(InputSource input) 解析文档。 |
void |
parse(String systemId) 解析文档。 |
void |
processingInstruction(String target, String data) 调整SAX2处理指令事件。 |
void |
setDTDHandler(DTDHandler handler) 注册DTD事件处理程序。 |
void |
setDocumentHandler(DocumentHandler handler) 注册SAX1文档事件处理程序。 |
void |
setDocumentLocator(Locator locator) 设置文档定位器。 |
void |
setEntityResolver(EntityResolver resolver) 注册实体解析器。 |
void |
setErrorHandler(ErrorHandler handler) 注册错误事件处理程序。 |
void |
setLocale(Locale locale) 设置错误报告的区域设置。 |
void |
skippedEntity(String name) 调整SAX2跳过的实体事件。 |
void |
startDocument() 启动文档事件。 |
void |
startElement(String uri, String localName, String qName, Attributes atts) 调整SAX2开始元素事件。 |
void |
startPrefixMapping(String prefix, String uri) 调整SAX2开始前缀映射事件。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
org.xml.sax.Parser
|
|
org.xml.sax.ContentHandler
|
|
XMLReaderAdapter ()
创建一个新的适配器。
使用“org.xml.sax.driver”属性来定位要嵌入的SAX2驱动程序。
| 抛出异常(Throws) | |
|---|---|
SAXException |
If the embedded driver cannot be instantiated or if the org.xml.sax.driver property is not specified. |
XMLReaderAdapter (XMLReader xmlReader)
创建一个新的适配器。
创建一个新的适配器,包装在SAX2 XMLReader中。 该适配器将使XMLReader像SAX1解析器一样工作。
| 参数(Parameters) | |
|---|---|
xmlReader |
XMLReader: The SAX2 XMLReader to wrap. |
| 抛出异常(Throws) | |
|---|---|
NullPointerException |
If the argument is null. |
void characters (char[] ch,
int start,
int length)
调整SAX2角色事件。
| 参数(Parameters) | |
|---|---|
ch |
char: An array of characters. |
start |
int: The starting position in the array. |
length |
int: The number of characters to use. |
| 抛出异常(Throws) | |
|---|---|
SAXException |
The client may raise a processing exception. |
也可以看看:
void endDocument ()
结束文档事件。
| 抛出异常(Throws) | |
|---|---|
SAXException |
The client may raise a processing exception. |
也可以看看:
void endElement (String uri, String localName, String qName)
调整SAX2结束元素事件。
| 参数(Parameters) | |
|---|---|
uri |
String: The Namespace URI. |
localName |
String: The Namespace local name. |
qName |
String: The qualified (prefixed) name. |
| 抛出异常(Throws) | |
|---|---|
SAXException |
The client may raise a processing exception. |
void endPrefixMapping (String prefix)
调整SAX2结束前缀映射事件。
| 参数(Parameters) | |
|---|---|
prefix |
String: The prefix being mapped. |
也可以看看:
void ignorableWhitespace (char[] ch,
int start,
int length)
调整SAX2可忽略的空白事件。
| 参数(Parameters) | |
|---|---|
ch |
char: An array of characters. |
start |
int: The starting position in the array. |
length |
int: The number of characters to use. |
| 抛出异常(Throws) | |
|---|---|
SAXException |
The client may raise a processing exception. |
void parse (InputSource input)
解析文档。
如果嵌入式XMLReader不支持http://xml.org/sax/features/namespace-prefixes属性,则此方法将引发异常。
| 参数(Parameters) | |
|---|---|
input |
InputSource: An input source for the document. |
| 抛出异常(Throws) | |
|---|---|
IOException |
If there is a problem reading the raw content of the document. |
SAXException |
If there is a problem processing the document. |
void parse (String systemId)
解析文档。
如果嵌入式XMLReader不支持http://xml.org/sax/features/namespace-prefixes属性,则此方法将引发异常。
| 参数(Parameters) | |
|---|---|
systemId |
String: The absolute URL of the document. |
| 抛出异常(Throws) | |
|---|---|
IOException |
If there is a problem reading the raw content of the document. |
SAXException |
If there is a problem processing the document. |
void processingInstruction (String target, String data)
调整SAX2处理指令事件。
| 参数(Parameters) | |
|---|---|
target |
String: The processing instruction target. |
data |
String: The remainder of the processing instruction |
| 抛出异常(Throws) | |
|---|---|
SAXException |
The client may raise a processing exception. |
void setDTDHandler (DTDHandler handler)
注册DTD事件处理程序。
| 参数(Parameters) | |
|---|---|
handler |
DTDHandler: The new DTD event handler. |
也可以看看:
void setDocumentHandler (DocumentHandler handler)
注册SAX1文档事件处理程序。
请注意,SAX1文档处理程序没有名称空间支持。
| 参数(Parameters) | |
|---|---|
handler |
DocumentHandler: The new SAX1 document event handler. |
void setDocumentLocator (Locator locator)
设置文档定位器。
| 参数(Parameters) | |
|---|---|
locator |
Locator: The document locator. |
也可以看看:
void setEntityResolver (EntityResolver resolver)
注册实体解析器。
| 参数(Parameters) | |
|---|---|
resolver |
EntityResolver: The new resolver. |
void setErrorHandler (ErrorHandler handler)
注册错误事件处理程序。
| 参数(Parameters) | |
|---|---|
handler |
ErrorHandler: The new error event handler. |
void setLocale (Locale locale)
设置错误报告的区域设置。
这在SAX2中不受支持,并且会始终引发异常。
| 参数(Parameters) | |
|---|---|
locale |
Locale: the locale for error reporting. |
| 抛出异常(Throws) | |
|---|---|
SAXException |
Thrown unless overridden. |
也可以看看:
void skippedEntity (String name)
调整SAX2跳过的实体事件。
| 参数(Parameters) | |
|---|---|
name |
String: The name of the skipped entity. |
| 抛出异常(Throws) | |
|---|---|
SAXException |
Throwable by subclasses. |
也可以看看:
void startDocument ()
启动文档事件。
| 抛出异常(Throws) | |
|---|---|
SAXException |
The client may raise a processing exception. |
也可以看看:
void startElement (String uri, String localName, String qName, Attributes atts)
调整SAX2开始元素事件。
| 参数(Parameters) | |
|---|---|
uri |
String: The Namespace URI. |
localName |
String: The Namespace local name. |
qName |
String: The qualified (prefixed) name. |
atts |
Attributes: The SAX2 attributes. |
| 抛出异常(Throws) | |
|---|---|
SAXException |
The client may raise a processing exception. |
也可以看看:
void startPrefixMapping (String prefix, String uri)
调整SAX2开始前缀映射事件。
| 参数(Parameters) | |
|---|---|
prefix |
String: The prefix being mapped. |
uri |
String: The Namespace URI being mapped to. |