SchematronPipeline { public static void processSchematron(InputStream schematronSource, OutputStream xslDest) throws TransformerException, IOException { File isoDsdResult = createTempFileResult(cachedIsoDsdXsl.newTransformer(), new StreamSource(schematronSource), "IsoDsd"); File isoExpResult = createTempFileResult(cachedExpXsl.newTransformer(), new StreamSource(isoDsdResult), "ExpXsl"); cachedIsoSvrlXsl.newTransformer().transform(new StreamSource(isoExpResult), new StreamResult(xslDest)); if (!isoDsdResult.delete()) { isoDsdResult.deleteOnExit(); } if (!isoExpResult.delete()) { isoExpResult.deleteOnExit(); } } private  SchematronPipeline(); static void processSchematron(InputStream schematronSource, OutputStream xslDest);  }
@Test public void testProcessSchematron() throws IOException, TransformerException { File tempResult = File.createTempFile("veraPDF", "unitTest"); assertTrue(tempResult.length() == 0); try (InputStream is = SchematronPipelineTest.class.getResourceAsStream(basicSchematronPath); FileOutputStream fos = new FileOutputStream(tempResult)) { SchematronPipeline.processSchematron(is, fos); } assertTrue(tempResult.length() > 0); Source test = Input.fromFile(tempResult).build(); Source control = Input.fromStream(this.getClass().getResourceAsStream(basicXslControlPath)).build(); Diff myDiff = DiffBuilder.compare(control).checkForSimilar().ignoreComments().ignoreWhitespace().withTest(test) .build(); assertFalse(myDiff.toString(), myDiff.hasDifferences()); tempResult.delete(); }