Name
DocumentBuilderFactory
Synopsis
A
DocumentBuilderFactory
is a factory class for creating
DocumentBuilder objects. You can obtain a
DocumentBuilderFactory by instantiating an
implementation-specific subclass provided by a parser vendor, but it
is much more common to simply call newInstance( )
to obtain an instance of the factory that has been configured as the
default for the system. Once you have obtained a factory object, you
can use the various set methods to configure the
properties of the DocumentBuilder objects it will
create. These methods allow you to specify whether the parsers
created by the factory will:
coalesce
CDATAsections with adjacent text nodes;expand entity references or leave them unexpanded in the document tree;
omit XML comments from the document tree;
omit ignorable whitespace from the document tree;
handle XML namespaces correctly; and
validate XML documents against a DTD or other schema.
In Java 5.0, you can use setSchema( ) to specify
the javax.xml.vaidation.Schema object against
which parsers should validate their documents. And you can use
setXIncludeAware( ) to indicate that parsers
should process XInclude markup.
In addition to the various implementation-independent
set methods, you can also use
setAttribute( ) pass an implementation-dependent
named attribute to the underlying parser implementation. Once you
have configured the factory object as desired, simply call
newDocumentBuilder( ) to create a
DocumentBuilder object with the all of the attributes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access