CrossrefBuilder { TransformErrorListener createCrossrefXml(Source src, Result dst) { try { tranformationErrorHandler.reset(); crosssrefXsl.setParameter("export_time", exportDateFormat.format(new Date())); crosssrefXsl.transform(src, dst); } catch (TransformerException ex) { if (tranformationErrorHandler.getErrors().isEmpty()) { tranformationErrorHandler.getErrors().add(ex.getMessageAndLocation()); } } return tranformationErrorHandler; } CrossrefBuilder(File outputFolder); File createPackage(CrossrefPackage pkg);  }
@Test public void testCreateCrossrefXml() throws Exception { File targetFolder = temp.getRoot(); CrossrefBuilder builder = new CrossrefBuilder(targetFolder); builder.addPeriodicalTitle("1210-8510", "titleTest", "abbrevTest", "print"); builder.addVolume("1", null, null); builder.addIssue("10", "2010", "uuid"); Document article = builder.getDocumentBuilder().parse( CejshBuilderTest.class.getResource("article_mods.xml").toExternalForm()); builder.addArticle(article); Document articles = builder.mergeArticles(); StringWriter dump = new StringWriter(); TransformErrorListener errors = builder.createCrossrefXml(new DOMSource(articles), new StreamResult(dump)); assertTrue(errors.getErrors().toString(), errors.getErrors().isEmpty()); List<String> validateErrors = builder.validateCrossref(new StreamSource(new StringReader(dump.toString()))); assertTrue(validateErrors.toString(), validateErrors.isEmpty()); }