public class SAXBuilder extends Object
A new instance of SAXHandler is created and configured
each time one of the build methods is called.
SAXHandler| Constructor and Description |
|---|
SAXBuilder(boolean nsaware,
boolean validate)
Constructor that creates the parser on-the-fly.
|
SAXBuilder(boolean nsaware,
boolean validate,
boolean smartIgnore)
Constructor that creates the parser on-the-fly, that accepts
an additional option, smartIgnore.
|
SAXBuilder(SAXParser parser)
Constructor which reuses a parser.
|
| Modifier and Type | Method and Description |
|---|---|
Document |
build(File src)
Build an iDOM tree from a file.
|
Document |
build(InputSource src)
Build an iDOM tree from a input source.
|
Document |
build(InputStream src)
Build an iDOM tree from a input stream.
|
Document |
build(Reader src)
Build an iDOM tree from a Reader.
|
Document |
build(String uri)
Build an iDOM tree from a URI string.
|
Document |
build(URL url)
Build an iDOM tree from a URL.
|
EntityResolver |
getEntityResolver()
Gets the org.xml.sax.EntityResolver.
|
ErrorHandler |
getErrorHandler()
Gets the org.xml.sax.ErrorHandler.
|
IDOMFactory |
getIDOMFactory()
Gets the iDOM factory.
|
SAXParser |
getParser()
Gets the SAX parser.
|
boolean |
isCoalescing()
Indicates whether or not the factory is configured to produce parsers
which converts CDATA to Text and appends it to the adjacent (if any)
Text node.
|
boolean |
isExpandEntityReferences()
Tests whether to expand entity reference nodes.
|
boolean |
isIgnoringComments()
Indicates whether or not the factory is configured to produce parsers
which ignores comments.
|
boolean |
isIgnoringElementContentWhitespace()
Tests whether to ignore whitespaces in element content.
|
boolean |
isNamespaceAware()
Tests whether or not this parser is configured to understand namespaces.
|
boolean |
isValidating()
Tests whether or not this parser is configured to validate XML documents.
|
protected SAXHandler |
newHandler()
Creates a SAX Handler.
|
void |
setCoalescing(boolean coalescing)
Specifies that the parser produced by this code will convert
CDATA to Text and append it to the adjacent (if any) text.
|
void |
setEntityResolver(EntityResolver er)
Specifies the org.xml.sax.EntityResolver to be used to resolve
entities present in the XML document to be parsed.
|
void |
setErrorHandler(ErrorHandler eh)
Specifies the org.xml.sax.ErrorHandler to be used to report errors
present in the XML document to be parsed.
|
void |
setExpandEntityReferences(boolean expand)
Sets whether to expand entities during parsing.
|
void |
setIDOMFactory(IDOMFactory factory)
Sets the iDOM factory.
|
void |
setIgnoringComments(boolean ignoreComments)
Specifies that the parser produced by this code will ignore comments.
|
void |
setIgnoringElementContentWhitespace(boolean ignore)
Sets whether the parser should eliminate whitespace in
element content.
|
public SAXBuilder(SAXParser parser)
public SAXBuilder(boolean nsaware,
boolean validate)
throws ParserConfigurationException,
SAXException
nsaware - whether the parser is namespace awarevalidate - whether the parser shall validate the documentParserConfigurationException - if a parser cannot be created
which satisfies the requested configuration.SAXExceptionSAXBuilder(boolean, boolean, boolean)public SAXBuilder(boolean nsaware,
boolean validate,
boolean smartIgnore)
throws ParserConfigurationException,
SAXException
When parsing XML for input purpose only, it is better to use this constructor with smartIgnore true, and then comments will be ignored CDATA will be coalesced with TEXT. A smaller DOM tree is formed.
nsaware - whether the parser is namespace awarevalidate - whether the parser shall validate the documentsmartIgnore - whether to ignore comments and ignorable-whitespace
(if validate is true), and to coalesceParserConfigurationException - if a parser cannot be created
which satisfies the requested configuration.SAXExceptionpublic final boolean isIgnoringElementContentWhitespace()
public final void setIgnoringElementContentWhitespace(boolean ignore)
For this setting to take effect requires that validation be turned on.
Default: false.
ignore - Whether to ignore whitespaces in element content.public final boolean isExpandEntityReferences()
public final void setExpandEntityReferences(boolean expand)
EntityReference objects.
Default: true.
expand - whether entity expansion should occur.public final boolean isCoalescing()
Default: false.
public final void setCoalescing(boolean coalescing)
Default: false.
public final boolean isIgnoringComments()
Default: false.
public final void setIgnoringComments(boolean ignoreComments)
Default: false.
public final void setErrorHandler(ErrorHandler eh)
Default: null -- to use the default implementation and behavior.
public final ErrorHandler getErrorHandler()
public final void setEntityResolver(EntityResolver er)
Default: null -- to use the default implementation and behavior.
public final EntityResolver getEntityResolver()
public final boolean isNamespaceAware()
public final boolean isValidating()
public final IDOMFactory getIDOMFactory()
public final void setIDOMFactory(IDOMFactory factory)
public final SAXParser getParser()
public final Document build(File src) throws SAXException, IOException
SAXExceptionIOExceptionpublic final Document build(InputStream src) throws SAXException, IOException
SAXExceptionIOExceptionpublic final Document build(InputSource src) throws SAXException, IOException
SAXExceptionIOExceptionpublic final Document build(String uri) throws SAXException, IOException
SAXExceptionIOExceptionpublic final Document build(URL url) throws SAXException, IOException
SAXExceptionIOExceptionpublic final Document build(Reader src) throws SAXException, IOException
SAXExceptionIOExceptionprotected SAXHandler newHandler() throws SAXException
SAXExceptionCopyright © 2018. All rights reserved.