public class SAXBuilder
extends java.lang.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(javax.xml.parsers.SAXParser parser)
Constructor which reuses a parser.
|
Modifier and Type | Method and Description |
---|---|
Document |
build(java.io.File src)
Build an iDOM tree from a file.
|
Document |
build(org.xml.sax.InputSource src)
Build an iDOM tree from a input source.
|
Document |
build(java.io.InputStream src)
Build an iDOM tree from a input stream.
|
Document |
build(java.io.Reader src)
Build an iDOM tree from a Reader.
|
Document |
build(java.lang.String uri)
Build an iDOM tree from a URI string.
|
Document |
build(java.net.URL url)
Build an iDOM tree from a URL.
|
org.xml.sax.EntityResolver |
getEntityResolver()
Gets the org.xml.sax.EntityResolver.
|
org.xml.sax.ErrorHandler |
getErrorHandler()
Gets the org.xml.sax.ErrorHandler.
|
IDOMFactory |
getIDOMFactory()
Gets the iDOM factory.
|
javax.xml.parsers.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(org.xml.sax.EntityResolver er)
Specifies the org.xml.sax.EntityResolver to be used to resolve
entities present in the XML document to be parsed.
|
void |
setErrorHandler(org.xml.sax.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(javax.xml.parsers.SAXParser parser)
public SAXBuilder(boolean nsaware, boolean validate) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
nsaware
- whether the parser is namespace awarevalidate
- whether the parser shall validate the documentjavax.xml.parsers.ParserConfigurationException
- if a parser cannot be created
which satisfies the requested configuration.org.xml.sax.SAXException
SAXBuilder(boolean, boolean, boolean)
public SAXBuilder(boolean nsaware, boolean validate, boolean smartIgnore) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.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 coalescejavax.xml.parsers.ParserConfigurationException
- if a parser cannot be created
which satisfies the requested configuration.org.xml.sax.SAXException
public 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(org.xml.sax.ErrorHandler eh)
Default: null -- to use the default implementation and behavior.
public final org.xml.sax.ErrorHandler getErrorHandler()
public final void setEntityResolver(org.xml.sax.EntityResolver er)
Default: null -- to use the default implementation and behavior.
public final org.xml.sax.EntityResolver getEntityResolver()
public final boolean isNamespaceAware()
public final boolean isValidating()
public final IDOMFactory getIDOMFactory()
public final void setIDOMFactory(IDOMFactory factory)
public final javax.xml.parsers.SAXParser getParser()
public final Document build(java.io.File src) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public final Document build(java.io.InputStream src) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public final Document build(org.xml.sax.InputSource src) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public final Document build(java.lang.String uri) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public final Document build(java.net.URL url) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public final Document build(java.io.Reader src) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
protected SAXHandler newHandler() throws org.xml.sax.SAXException
org.xml.sax.SAXException
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.