javax.xml.parsers
public abstract class DocumentBuilder extends Object
An instance of this class can be obtained from the {@link javax.xml.parsers.DocumentBuilderFactory#newDocumentBuilder() DocumentBuilderFactory.newDocumentBuilder} method. Once an instance of this class is obtained, XML can be parsed from a variety of input sources. These input sources are InputStreams, Files, URLs, and SAX InputSources.
Note that this class reuses several classes from the SAX API. This
does not require that the implementor of the underlying DOM
implementation use a SAX parser to parse XML document into a
Document
. It merely requires that the implementation
communicate with the application using these existing APIs.
An implementation of DocumentBuilder
is NOT
guaranteed to behave as per the specification if it is used concurrently by
two or more threads. It is recommended to have one instance of the
DocumentBuilder
per thread or it is upto the application to
make sure about the use of DocumentBuilder
from more than one
thread.
Since: JAXP 1.0
Version: 1.0
Constructor Summary | |
---|---|
protected | DocumentBuilder() |
Method Summary | |
---|---|
abstract DOMImplementation | getDOMImplementation()
Obtain an instance of a {@link org.w3c.dom.DOMImplementation} object.
|
abstract boolean | isNamespaceAware()
Indicates whether or not this parser is configured to
understand namespaces.
|
abstract boolean | isValidating()
Indicates whether or not this parser is configured to
validate XML documents.
|
abstract Document | newDocument()
Obtain a new instance of a DOM {@link org.w3c.dom.Document} object
to build a DOM tree with. |
Document | parse(InputStream is)
Parse the content of the given InputStream as an XML
document and return a new DOM {@link org.w3c.dom.Document} object.
|
Document | parse(InputStream is, String systemId)
Parse the content of the given InputStream as an XML
document and return a new DOM {@link org.w3c.dom.Document} object.
|
Document | parse(String uri)
Parse the content of the given URI as an XML document
and return a new DOM {@link org.w3c.dom.Document} object.
|
Document | parse(File f)
Parse the content of the given file as an XML document
and return a new DOM {@link org.w3c.dom.Document} object.
|
abstract Document | parse(InputSource is)
Parse the content of the given input source as an XML document
and return a new DOM {@link org.w3c.dom.Document} object.
|
abstract void | setEntityResolver(EntityResolver er)
Specify the {@link org.xml.sax.EntityResolver} to be used to resolve
entities present in the XML document to be parsed. |
abstract void | setErrorHandler(ErrorHandler eh)
Specify the {@link org.xml.sax.ErrorHandler} to be used to report
errors present in the XML document to be parsed. |
Returns: A new instance of a DOMImplementation
.
Returns: true if this parser is configured to understand namespaces; false otherwise.
Returns: true if this parser is configured to validate XML documents; false otherwise.
Returns: A new instance of a DOM Document object.
InputStream
as an XML
document and return a new DOM {@link org.w3c.dom.Document} object.
Parameters: is InputStream containing the content to be parsed.
Throws: IOException If any IO errors occur. SAXException If any parse errors occur. IllegalArgumentException If the InputStream is null
See Also: DocumentHandler
InputStream
as an XML
document and return a new DOM {@link org.w3c.dom.Document} object.
Parameters: is InputStream containing the content to be parsed. systemId Provide a base for resolving relative URIs.
Returns: A new DOM Document object.
Throws: IOException If any IO errors occur. SAXException If any parse errors occur. IllegalArgumentException If the InputStream is null.
See Also: DocumentHandler
Parameters: uri The location of the content to be parsed.
Returns: A new DOM Document object.
Throws: IOException If any IO errors occur. SAXException If any parse errors occur. IllegalArgumentException If the URI is null.
See Also: DocumentHandler
Parameters: f The file containing the XML to parse.
Returns: A new DOM Document object.
Throws: IOException If any IO errors occur. SAXException If any parse errors occur. IllegalArgumentException If the file is null.
See Also: DocumentHandler
Parameters: is InputSource containing the content to be parsed.
Returns: A new DOM Document object.
Throws: IOException If any IO errors occur. SAXException If any parse errors occur. IllegalArgumentException If the InputSource is null.
See Also: DocumentHandler
null
will result in the underlying
implementation using it's own default implementation and
behavior.
Parameters: er The EntityResolver
to be used to resolve entities
present in the XML document to be parsed.
null
will result in the underlying
implementation using it's own default implementation and
behavior.
Parameters: eh The ErrorHandler
to be used to report errors
present in the XML document to be parsed.