public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
// Check that configuration options are all available
if (!isExpandEntityReferences()) {
throw new ParserConfigurationException(
"Saxon parser always expands entity references");
}
if (isIgnoringComments()) {
throw new ParserConfigurationException(
"Saxon parser does not allow comments to be ignored");
}
if (isIgnoringElementContentWhitespace()) {
throw new ParserConfigurationException(
"Saxon parser does not allow whitespace in element content to be ignored");
}
if (!isNamespaceAware()) {
throw new ParserConfigurationException(
"Saxon parser is always namespace aware");
}
DocumentBuilderImpl builder = new DocumentBuilderImpl();
builder.setValidating(isValidating());