public abstract class DocumentBuilder
extends Object
| java.lang.Object | |
| javax.xml.parsers.DocumentBuilder | |
定义API以从XML文档获取DOM Document实例。 使用这个类,应用程序员可以从XML获得Document 。
这个类的一个实例可以从newDocumentBuilder()方法中获得。 一旦获得此类的实例,就可以从各种输入源分析XML。 这些输入源是InputStreams,Files,URLs和SAX InputSources。
请注意,这个类重用了SAX API中的几个类。 这并不要求底层DOM实现的实现者使用SAX解析器将XML文档解析为Document 。 它只需要实现与使用这些现有API的应用程序进行通信。
Protected constructors |
|
|---|---|
DocumentBuilder() 受保护的构造函数 |
|
公共方法(Public methods) |
|
|---|---|
abstract DOMImplementation |
getDOMImplementation() 获取一个 |
Schema |
getSchema() 获取XML处理器正在使用的 |
abstract boolean |
isNamespaceAware() 指示此分析器是否配置为了解命名空间。 |
abstract boolean |
isValidating() 指示此分析器是否配置为验证XML文档。 |
boolean |
isXIncludeAware() 获取此解析器的XInclude处理模式。 |
abstract Document |
newDocument() 获取DOM |
abstract Document |
parse(InputSource is) 将给定输入源的内容解析为XML文档并返回一个新的DOM |
Document |
parse(String uri) 将给定URI的内容解析为一个XML文档并返回一个新的DOM对象 |
Document |
parse(InputStream is) 将给定的 |
Document |
parse(InputStream is, String systemId) 将给定的 |
Document |
parse(File f) 将给定文件的内容解析为XML文档并返回一个新的DOM |
void |
reset() 将此 |
abstract void |
setEntityResolver(EntityResolver er) 指定要用于解析要解析的XML文档中存在的实体的 |
abstract void |
setErrorHandler(ErrorHandler eh) 指定解析器使用的 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
DOMImplementation getDOMImplementation ()
获取一个 DOMImplementation对象的实例。
| 返回(Returns) | |
|---|---|
DOMImplementation |
A new instance of a DOMImplementation. |
Schema getSchema ()
获取对XML处理器正在使用的 Schema的引用。
如果没有使用模式,则返回 null 。
| 返回(Returns) | |
|---|---|
Schema |
Schema being used or null if none in use |
| 抛出异常(Throws) | |
|---|---|
UnsupportedOperationException |
For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown. |
boolean isNamespaceAware ()
指示此分析器是否配置为了解命名空间。
| 返回(Returns) | |
|---|---|
boolean |
true if this parser is configured to understand namespaces; false otherwise. |
boolean isValidating ()
指示此分析器是否配置为验证XML文档。
| 返回(Returns) | |
|---|---|
boolean |
true if this parser is configured to validate XML documents; false otherwise. |
boolean isXIncludeAware ()
获取此解析器的XInclude处理模式。
| 返回(Returns) | |
|---|---|
boolean |
the return value of the isXIncludeAware() when this parser was created from factory. |
| 抛出异常(Throws) | |
|---|---|
UnsupportedOperationException |
For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown. |
也可以看看:
Document newDocument ()
获取DOM Document对象的新实例以构建DOM树。
| 返回(Returns) | |
|---|---|
Document |
A new instance of a DOM Document object. |
Document parse (InputSource is)
将给定输入源的内容解析为XML文档并返回一个新的DOM Document对象。 一个IllegalArgumentException如果抛出InputSource为null空。
| 参数(Parameters) | |
|---|---|
is |
InputSource: InputSource containing the content to be parsed. |
| 返回(Returns) | |
|---|---|
Document |
A new DOM Document object. |
| 抛出异常(Throws) | |
|---|---|
IOException |
If any IO errors occur. |
SAXException |
If any parse errors occur. |
也可以看看:
Document parse (String uri)
将给定URI的内容解析为XML文档并返回一个新的DOM Document对象。 一个IllegalArgumentException如果URI是被抛出null空。
| 参数(Parameters) | |
|---|---|
uri |
String: The location of the content to be parsed. |
| 返回(Returns) | |
|---|---|
Document |
A new DOM Document object. |
| 抛出异常(Throws) | |
|---|---|
IOException |
If any IO errors occur. |
SAXException |
If any parse errors occur. |
也可以看看:
Document parse (InputStream is)
将给定的InputStream的内容解析为XML文档并返回一个新的DOM Document对象。 一个IllegalArgumentException如果抛出InputStream为空。
| 参数(Parameters) | |
|---|---|
is |
InputStream: InputStream containing the content to be parsed. |
| 返回(Returns) | |
|---|---|
Document |
Document result of parsing the InputStream |
| 抛出异常(Throws) | |
|---|---|
IOException |
If any IO errors occur. |
SAXException |
If any parse errors occur. |
也可以看看:
Document parse (InputStream is, String systemId)
将给定的InputStream的内容解析为XML文档并返回一个新的DOM Document对象。 一个IllegalArgumentException如果抛出InputStream为空。
| 参数(Parameters) | |
|---|---|
is |
InputStream: InputStream containing the content to be parsed. |
systemId |
String: Provide a base for resolving relative URIs. |
| 返回(Returns) | |
|---|---|
Document |
A new DOM Document object. |
| 抛出异常(Throws) | |
|---|---|
IOException |
If any IO errors occur. |
SAXException |
If any parse errors occur. |
也可以看看:
Document parse (File f)
将给定文件的内容解析为XML文档并返回一个新的DOM Document对象。 一个IllegalArgumentException如果抛出File为null空。
| 参数(Parameters) | |
|---|---|
f |
File: The file containing the XML to parse. |
| 返回(Returns) | |
|---|---|
Document |
A new DOM Document object. |
| 抛出异常(Throws) | |
|---|---|
IOException |
If any IO errors occur. |
SAXException |
If any parse errors occur. |
也可以看看:
void reset ()
将此 DocumentBuilder重置为其原始配置。
DocumentBuilder被重置为与使用newDocumentBuilder()创建时相同的状态。 reset()旨在允许重复使用现有的DocumentBuilder从而节省与创建新的DocumentBuilder相关的资源。
不保证重置DocumentBuilder具有相同的EntityResolver或ErrorHandler Object ,例如equals(Object) 。 它保证有一个功能相同的EntityResolver和ErrorHandler 。
void setEntityResolver (EntityResolver er)
指定EntityResolver用于解析要解析的XML文档中存在的实体。 将其设置为null将导致底层实现使用它自己的默认实现和行为。
| 参数(Parameters) | |
|---|---|
er |
EntityResolver: The EntityResolver to be used to resolve entities present in the XML document to be parsed. |
void setErrorHandler (ErrorHandler eh)
指定分析器使用的ErrorHandler 。 将其设置为null将导致底层实现使用它自己的默认实现和行为。
| 参数(Parameters) | |
|---|---|
eh |
ErrorHandler: The ErrorHandler to be used by the parser. |