*/
public static Document read(InputStream aIs) throws XMLException {
try {
- DOMImplementationRegistry registry = DOMImplementationRegistry
- .newInstance();
-
- DOMImplementationLS impl = (DOMImplementationLS) registry
- .getDOMImplementation("LS");
+ DOMImplementationLS impl = getDomImplementationLS();
LSParser builder = impl.createLSParser(
DOMImplementationLS.MODE_SYNCHRONOUS, null);
LSInput input = impl.createLSInput();
input.setByteStream(aIs);
return builder.parse(input);
- } catch (IllegalAccessException e) {
- throw new XMLException(e.getMessage(), e);
- } catch (InstantiationException e) {
- throw new XMLException(e.getMessage(), e);
- } catch (ClassNotFoundException e) {
- throw new XMLException(e.getMessage(), e);
} catch (LSException e) {
throw new XMLException(e.getMessage(), e);
} finally {
}
}
+ /**
+ * Gets a dom level 3 implementation.
+ * @return Dom implementation.
+ * @throws ClassNotFoundException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ public static DOMImplementationLS getDomImplementationLS() {
+ final String message = "Could not get Dom level 3 implementation";
+ try {
+ DOMImplementationRegistry registry = DOMImplementationRegistry
+ .newInstance();
+
+ DOMImplementationLS impl = (DOMImplementationLS) registry
+ .getDOMImplementation("LS");
+ return impl;
+ } catch (ClassCastException e) {
+ throw new RuntimeException(message, e);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(message, e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(message, e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(message, e);
+ }
+ }
+
/**
* Reads and validates a document against a schema.
*