diff options
Diffstat (limited to 'libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java')
-rw-r--r-- | libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java b/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java index 02347858002..4d2828af84e 100644 --- a/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java +++ b/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java @@ -43,6 +43,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.DOMConfiguration; +import org.w3c.dom.DOMException; import org.w3c.dom.DOMImplementation; import org.w3c.dom.bootstrap.DOMImplementationRegistry; import org.w3c.dom.ls.DOMImplementationLS; @@ -84,8 +85,38 @@ public class DomDocumentBuilderFactory public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException { - LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_ASYNCHRONOUS, - "http://www.w3.org/TR/REC-xml"); + LSParser parser = null; + try + { + parser = ls.createLSParser(DOMImplementationLS.MODE_ASYNCHRONOUS, + "http://www.w3.org/TR/REC-xml"); + } + catch (DOMException e) + { + if (e.code == DOMException.NOT_SUPPORTED_ERR) + { + // Fall back to synchronous parser + try + { + parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, + "http://www.w3.org/TR/REC-xml"); + } + catch (DOMException e2) + { + ParserConfigurationException pce = + new ParserConfigurationException(); + pce.initCause(e2); + throw pce; + } + } + else + { + ParserConfigurationException pce = + new ParserConfigurationException(); + pce.initCause(e); + throw pce; + } + } DOMConfiguration config = parser.getDomConfig(); setParameter(config, "namespaces", isNamespaceAware() ? Boolean.TRUE : Boolean.FALSE); |