From 08452f45531ca2ec479e61b9f7e37d3fadd95a7b Mon Sep 17 00:00:00 2001 From: Chris Burdess Date: Wed, 7 Feb 2007 18:22:26 +0000 Subject: re PR classpath/30718 (TransformerException in XSLURIResolver) 2007-02-07 Chris Burdess Fixes PR 30718. * gnu/xml/dom/ls/SAXEventSink.java: Add public accessor/mutators. * gnu/xml/transform/XSLURIResolver.java: Add support for custom SAXSources without a backing URL or stream. Fixes PR 27710. * gnu/xml/dom/DomDocumentBuilderFactory.java: Fall back to synchronous LSParser if implementation does not support asynchronous. * gnu/xml/stream/XMLParser.java, gnu/xml/stream/XIncludeFilter.java: Use custom code instead of java.net.URL to resolve to an an absolute URI, to avoid nonexistent protocol handler problems. From-SVN: r121694 --- .../gnu/xml/dom/DomDocumentBuilderFactory.java | 35 ++++++++++++++++++++-- libjava/classpath/gnu/xml/dom/ls/SAXEventSink.java | 7 ++++- 2 files changed, 39 insertions(+), 3 deletions(-) (limited to 'libjava/classpath/gnu/xml/dom') diff --git a/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java b/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java index 0234785..4d2828a 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); diff --git a/libjava/classpath/gnu/xml/dom/ls/SAXEventSink.java b/libjava/classpath/gnu/xml/dom/ls/SAXEventSink.java index 8c5b104..2855400 100644 --- a/libjava/classpath/gnu/xml/dom/ls/SAXEventSink.java +++ b/libjava/classpath/gnu/xml/dom/ls/SAXEventSink.java @@ -111,11 +111,16 @@ public class SAXEventSink interrupted = true; } - protected Document getDocument() + public Document getDocument() { return doc; } + public void setReader(XMLReader reader) + { + this.reader = reader; + } + // -- ContentHandler2 -- public void setDocumentLocator(Locator locator) -- cgit v1.1