build
public Document build(File file)
throws JDOMException
This builds a document from the supplied
filename.
file
- File
to read from.
Document
- resultant Document object.
JDOMException
- when errors occur in parsing.
build
public Document build(InputSource in)
throws JDOMException
This builds a document from the supplied
input source.
in
- InputSource
to read from.
Document
- resultant Document object.
JDOMException
- when errors occur in parsing.
build
public Document build(InputStream in)
throws JDOMException
This builds a document from the supplied
input stream.
in
- InputStream
to read from.
Document
- resultant Document object.
JDOMException
- when errors occur in parsing.
build
public Document build(InputStream in,
String systemId)
throws JDOMException
This builds a document from the supplied
input stream.
in
- InputStream
to read from.systemId
- base for resolving relative URIs
Document
- resultant Document object.
JDOMException
- when errors occur in parsing.
build
public Document build(Reader characterStream)
throws JDOMException
This builds a document from the supplied
Reader.
Document
- resultant Document object.
JDOMException
- when errors occur in parsing.
build
public Document build(Reader characterStream,
String SystemId)
throws JDOMException
This builds a document from the supplied
Reader.
Document
- resultant Document object.
JDOMException
- when errors occur in parsing.
build
public Document build(String systemId)
throws JDOMException
This builds a document from the supplied
URI.
systemId
- URI for the input
Document
- resultant Document object.
JDOMException
- when errors occur in parsing.
build
public Document build(URL url)
throws JDOMException
This builds a document from the supplied
URL.
url
- URL
to read from.
Document
- resultant Document object.
JDOMException
- when errors occur in parsing.
configureContentHandler
protected void configureContentHandler(SAXHandler contentHandler)
throws Exception
This configures the SAXHandler that will be used to build the Document.
The default implementation simply passes through some configuration
settings that were set on the SAXBuilder: setExpandEntities() and
setIgnoringElementContentWhitespace().
configureParser
protected void configureParser(XMLReader parser,
SAXHandler contentHandler)
throws Exception
This configures the XMLReader to be used for reading the XML document.
The default implementation sets various options on the given XMLReader,
such as validation, DTD resolution, entity handlers, etc., according
to the options that were set (e.g. via
setEntityResolver
)
and set various SAX properties and features that are required for JDOM
internals. These features may change in future releases, so change this
behavior at your own risk.
createContentHandler
protected SAXHandler createContentHandler()
throws Exception
This creates the SAXHandler that will be used to build the Document.
createParser
protected XMLReader createParser()
throws Exception
This creates the XMLReader to be used for reading the XML document.
The default behavior is to (1) use the saxDriverClass, if it has been
set, (2) try to obtain a parser from JAXP, if it is available, and
(3) if all else fails, use a hard-coded default parser (currently
the Xerces parser). Subclasses may override this method to determine
the parser to use in a different way.
fileToURL
protected URL fileToURL(File f)
throws MalformedURLException
Imitation of File.toURL(), a JDK 1.2 method, reimplemented
here to work with JDK 1.1.
f
- the file to convert
- the file path converted to a file: URL
java.io.File
setDTDHandler
public void setDTDHandler(DTDHandler dtdHandler)
This sets custom DTDHandler for the Builder
.
dtdHandler
- DTDHandler
setEntityResolver
public void setEntityResolver(EntityResolver entityResolver)
This sets custom EntityResolver for the Builder
.
entityResolver
- EntityResolver
setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)
This sets custom ErrorHandler for the Builder
.
errorHandler
- ErrorHandler
setExpandEntities
public void setExpandEntities(boolean expand)
This sets whether or not to expand entities for the builder.
A true means to expand entities as normal content. A false means to
leave entities unexpanded as
EntityRef
objects. The
default is true.
When this setting is false, the internal DTD subset is retained; when
this setting is true, the internal DTD subset is not retained.
Note that Xerces (at least up to 1.4.4) has a bug where entities
in attribute values will be misreported if this flag is turned off,
resulting in entities to appear within element content. When turning
entity expansion off either avoid entities in attribute values, or
use another parser like Crimson.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6111
expand
- boolean
indicating whether entity expansion
should occur.
setFeature
public void setFeature(String name,
boolean value)
This sets a feature on the SAX parser. See the SAX documentation for
more information.
NOTE: SAXBuilder requires that some particular features of the SAX parser be
set up in certain ways for it to work properly. The list of such features
may change in the future. Therefore, the use of this method may cause
parsing to break, and even if it doesn't break anything today it might
break parsing in a future JDOM version, because what JDOM parsers require
may change over time. Use with caution.
name
- The feature name, which is a fully-qualified URI.value
- The requested state of the feature (true or false).
setIgnoringElementContentWhitespace
public void setIgnoringElementContentWhitespace(boolean ignoringWhite)
Specifies whether or not the parser should elminate whitespace in
element content (sometimes known as "ignorable whitespace") when
building the document. Only whitespace which is contained within
element content that has an element only content model will be
eliminated (see XML Rec 3.2.1). For this setting to take effect
requires that validation be turned on. The default value of this
setting is false
.
ignoringWhite
- Whether to ignore ignorable whitespace
setProperty
public void setProperty(String name,
Object value)
This sets a property on the SAX parser. See the SAX documentation for
more information.
NOTE: SAXBuilder requires that some particular properties of the SAX parser be
set up in certain ways for it to work properly. The list of such properties
may change in the future. Therefore, the use of this method may cause
parsing to break, and even if it doesn't break anything today it might
break parsing in a future JDOM version, because what JDOM parsers require
may change over time. Use with caution.
name
- The property name, which is a fully-qualified URI.value
- The requested value for the property.
setValidation
public void setValidation(boolean validate)
This sets validation for the builder.
validate
- boolean
indicating whether validation
should occur.
setXMLFilter
public void setXMLFilter(XMLFilter xmlFilter)
This sets custom XMLFilter for the Builder
.
xmlFilter
- XMLFilter