public abstract class DocumentBuilderFactory
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
DocumentBuilderFactory() |
Modifier and Type | Method and Description |
---|---|
abstract java.lang.Object |
getAttribute(java.lang.String name)
Allows the user to retrieve specific attributes on the underlying
implementation.
|
abstract boolean |
getFeature(java.lang.String name)
Get the state of the named feature.
|
boolean |
isCoalescing()
Indicates whether or not the factory is configured to produce
parsers which converts CDATA nodes to Text nodes and appends it to
the adjacent (if any) Text node.
|
boolean |
isExpandEntityReferences()
Indicates whether or not the factory is configured to produce
parsers which expand entity reference nodes.
|
boolean |
isIgnoringComments()
Indicates whether or not the factory is configured to produce
parsers which ignores comments.
|
boolean |
isIgnoringElementContentWhitespace()
Indicates whether or not the factory is configured to produce
parsers which ignore ignorable whitespace in element content.
|
boolean |
isNamespaceAware()
Indicates whether or not the factory is configured to produce
parsers which are namespace aware.
|
boolean |
isValidating()
Indicates whether or not the factory is configured to produce
parsers which validate the XML content during parse.
|
abstract DocumentBuilder |
newDocumentBuilder()
Creates a new instance of a
DocumentBuilder
using the currently configured parameters. |
static DocumentBuilderFactory |
newInstance()
Obtain a new instance of a
DocumentBuilderFactory . |
abstract void |
setAttribute(java.lang.String name,
java.lang.Object value)
Allows the user to set specific attributes on the underlying
implementation.
|
void |
setCoalescing(boolean coalescing)
Specifies that the parser produced by this code will
convert CDATA nodes to Text nodes and append it to the
adjacent (if any) text node.
|
void |
setExpandEntityReferences(boolean expandEntityRef)
Specifies that the parser produced by this code will
expand entity reference nodes.
|
abstract void |
setFeature(java.lang.String name,
boolean value)
Set a feature for this
DocumentBuilderFactory and
DocumentBuilder s created by this factory. |
void |
setIgnoringComments(boolean ignoreComments)
Specifies that the parser produced by this code will
ignore comments.
|
void |
setIgnoringElementContentWhitespace(boolean whitespace)
Specifies that the parsers created by this factory must eliminate
whitespace in element content (sometimes known loosely as
'ignorable whitespace') when parsing XML documents (see XML Rec
2.10).
|
void |
setNamespaceAware(boolean awareness)
Specifies that the parser produced by this code will
provide support for XML namespaces.
|
void |
setValidating(boolean validating)
Specifies that the parser produced by this code will
validate documents as they are parsed.
|
public static DocumentBuilderFactory newInstance()
DocumentBuilderFactory
. This static method creates
a new factory instance.
This method uses the following ordered lookup procedure to determine
the DocumentBuilderFactory
implementation class to
load:
javax.xml.parsers.DocumentBuilderFactory
system
property.
DocumentBuilderFactory
instance.
DocumentBuilderFactory
it can use the factory to
configure and obtain parser instances.
Setting the jaxp.debug
system property will cause
this method to print a lot of debug messages
to System.err about what it is doing and where it is looking at.
If you have problems loading DocumentBuilder
s, try:
java -Djaxp.debug=1 YourProgram ....
DocumentBuilderFactory
FactoryConfigurationError
- if the implementation is not
available or cannot be instantiated.public abstract DocumentBuilder newDocumentBuilder() throws javax.xml.parsers.ParserConfigurationException
DocumentBuilder
using the currently configured parameters.ParserConfigurationException
- if a DocumentBuilder
cannot be created which satisfies the configuration requested.public void setNamespaceAware(boolean awareness)
false
awareness
- true
if the parser produced will provide support
for XML namespaces; false
otherwise.public void setValidating(boolean validating)
false
.
Note that "the validation" here means a validating parser as defined in the XML recommendation. In other words, it essentially just controls the DTD validation.
validating
- true
if the parser produced will validate documents
as they are parsed; false
otherwise.public void setIgnoringElementContentWhitespace(boolean whitespace)
false
.whitespace
- true
if the parser created must eliminate whitespace
in the element content when parsing XML documents;
false
otherwise.public void setExpandEntityReferences(boolean expandEntityRef)
true
expandEntityRef
- true
if the parser produced will expand entity
reference nodes; false
otherwise.public void setIgnoringComments(boolean ignoreComments)
Specifies that the parser produced by this code will
ignore comments. By default the value of this is set to false
.
ignoreComments
- boolean
value to ignore comments during processingpublic void setCoalescing(boolean coalescing)
false
coalescing
- true
if the parser produced will convert CDATA nodes
to Text nodes and append it to the adjacent (if any)
text node; false
otherwise.public boolean isNamespaceAware()
true
if the factory is configured to produce parsers which
are namespace aware; false
otherwise.public boolean isValidating()
true
if the factory is configured to produce parsers
which validate the XML content during parse; false
otherwise.public boolean isIgnoringElementContentWhitespace()
true
if the factory is configured to produce parsers
which ignore ignorable whitespace in element content;
false
otherwise.public boolean isExpandEntityReferences()
true
if the factory is configured to produce parsers
which expand entity reference nodes; false
otherwise.public boolean isIgnoringComments()
true
if the factory is configured to produce parsers
which ignores comments; false
otherwise.public boolean isCoalescing()
true
if the factory is configured to produce parsers
which converts CDATA nodes to Text nodes and appends it to
the adjacent (if any) Text node; false
otherwise.public abstract void setAttribute(java.lang.String name, java.lang.Object value) throws java.lang.IllegalArgumentException
name
- The name of the attribute.value
- The value of the attribute.java.lang.IllegalArgumentException
- thrown if the underlying
implementation doesn't recognize the attribute.public abstract java.lang.Object getAttribute(java.lang.String name) throws java.lang.IllegalArgumentException
name
- The name of the attribute.java.lang.IllegalArgumentException
- thrown if the underlying
implementation doesn't recognize the attribute.public abstract void setFeature(java.lang.String name, boolean value) throws javax.xml.parsers.ParserConfigurationException
Set a feature for this DocumentBuilderFactory
and
DocumentBuilder
s created by this factory.
Feature names are fully qualified URIs.
Implementations may define their own features.
An ParserConfigurationException
is thrown if this
DocumentBuilderFactory
or the
DocumentBuilder
s it creates cannot support the feature.
It is possible for an DocumentBuilderFactory
to expose
a feature value but be unable to change its state. A null
feature name parameter causes the XML reader to throw a
NullPointerException
.
All implementations are required to support the
XMLConstants.FEATURE_SECURE_PROCESSING
feature.
When the feature is:
true
: the implementation will limit XML processing to
conform to implementation limits. Examples include entity expansion
limits and XML Schema constructs that would consume large amounts of
resources. If XML processing is limited for security reasons, it will
be reported via a call to the registered
ErrorHandler.fatalError(SAXParseException exception)
.
See DocumentBuilder.setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
.
false
: the implementation will processing XML according
to the XML specifications without regard to possible implementation
limits.
name
- Feature name.value
- Is feature state true
or false
.ParserConfigurationException
- if this DocumentBuilderFactory
or the DocumentBuilder
s it creates cannot support this
feature.java.lang.NullPointerException
- If the name
parameter is null.public abstract boolean getFeature(java.lang.String name) throws javax.xml.parsers.ParserConfigurationException
Get the state of the named feature.
Feature names are fully qualified URIs.
Implementations may define their own features.
A ParserConfigurationException
is thrown if this
DocumentBuilderFactory
or the
DocumentBuilder
s it creates cannot support the feature.
It is possible for an DocumentBuilderFactory
to expose
a feature value but be unable to change its state.
A NullPointerException
is thrown if the feature name
parameter is null.
name
- Feature name.ParserConfigurationException
- if this
DocumentBuilderFactory
or the
DocumentBuilder
s it creates cannot support this feature.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Use is subject to License Terms. Your use of this web site or any of its contents or software indicates your agreement to be bound by these License Terms.