+ @SuppressWarnings("unchecked")
+ @Override
+ public <C extends Closeable> C open(Class<C> clss) throws IOException, IllegalArgumentException {
+ if (InputStream.class.isAssignableFrom(clss)) {
+ PipedOutputStream out = new PipedOutputStream();
+ ForkJoinPool.commonPool().execute(() -> {
+ try {
+ Source source = new DOMSource(element);
+ Result result = new StreamResult(out);
+ provider.getTransformerFactory().newTransformer().transform(source, result);
+ out.flush();
+ out.close();
+ } catch (TransformerException | IOException e) {
+ throw new RuntimeException("Cannot read " + getPath(), e);
+ }
+ });
+ return (C) new PipedInputStream(out);
+ }
+ return super.open(clss);
+ }
+