* @return A new DOM Document object.
*/
public Document parse(InputSource in) throws SAXException {
try {
Builder builder = new TinyBuilder();
if (config == null) {
config = new Configuration();
}
PipelineConfiguration pipe = config.makePipelineConfiguration();
builder.setPipelineConfiguration(pipe);
SAXSource source = new SAXSource(in);
if (entityResolver != null) {
XMLReader reader = source.getXMLReader();
if (reader == null) {
reader = config.getSourceParser();
}
reader.setEntityResolver(entityResolver);
}
if (errorHandler != null) {
XMLReader reader = source.getXMLReader();
if (reader == null) {
reader = config.getSourceParser();
}
reader.setErrorHandler(errorHandler);
}
source.setSystemId(in.getSystemId());
ParseOptions options = new ParseOptions();
if (xIncludeAware) {
options.setXIncludeAware(true);
}
if (validating) {
options.setDTDValidationMode(Validation.STRICT);
}
if (stripSpace != Whitespace.UNSPECIFIED) {
options.setStripSpace(stripSpace);
}
new Sender(pipe).send(source, builder, options);
TinyDocumentImpl doc = (TinyDocumentImpl)builder.getCurrentRoot();
builder.reset();
return (Document)DocumentOverNodeInfo.wrap(doc);
} catch (XPathException err) {
throw new SAXException(err);
}
}