Unified2OrchestraTransformer { public void transform(File inputXml, File phrasesFile, File outputXml) throws TransformerException { final File parentFile = outputXml.getParentFile(); if (parentFile != null) { parentFile.mkdirs(); } final Source xmlSource = new javax.xml.transform.stream.StreamSource(inputXml); final InputStream xsltFile = getClass().getClassLoader().getResourceAsStream("xsl/unified2orchestra.xslt"); final Source xsltSource = new javax.xml.transform.stream.StreamSource(xsltFile); final Result result = new javax.xml.transform.stream.StreamResult(outputXml); final TransformerFactory transFact = new TransformerFactoryImpl(); final Transformer trans = transFact.newTransformer(xsltSource); trans.setParameter("phrases-file", phrasesFile.toURI().toString()); trans.transform(xmlSource, result); }  static void main(String[] args); void transform(File inputXml, File phrasesFile, File outputXml);  }
@Test public void transformEP() throws TransformerException, URISyntaxException { File inputXml = new File(Thread.currentThread().getContextClassLoader() .getResource("FixRepositoryUnifiedEP247.xml").toURI()); File outputXml = new File("target/test/FixRepository50SP2EP247.xml"); String sourceDir = inputXml.getParent(); File phrasesFile = new File(String.format("%s/FIX.5.0SP2_EP247_en_phrases.xml", sourceDir)); new Unified2OrchestraTransformer().transform(inputXml, phrasesFile, outputXml); Assertions.assertTrue(outputXml.exists()); }
@Disabled @Test public void transform50() throws TransformerException, URISyntaxException, FileNotFoundException, ParserConfigurationException, SAXException, IOException { File inputXml = new File(Thread.currentThread().getContextClassLoader() .getResource("FixRepositoryUnified.xml").toURI()); File outputXml = new File("target/test/FixRepository50SP2.xml"); String sourceDir = inputXml.getParent(); File phrasesFile = new File(String.format("%s/FIX.5.0SP2_en_phrases.xml", sourceDir)); new Unified2OrchestraTransformer().transform(inputXml, phrasesFile, outputXml); Assertions.assertTrue(outputXml.exists()); RepositoryValidator validator = RepositoryValidator.builder().inputStream(new FileInputStream(outputXml)).build(); validator.validate(); }
@Disabled @Test public void transform44() throws TransformerException, URISyntaxException { File inputXml = new File(Thread.currentThread().getContextClassLoader() .getResource("FixRepositoryUnified.xml").toURI()); File outputXml = new File("target/test/FixRepository44.xml"); String sourceDir = inputXml.getParent(); File phrasesFile = new File(String.format("%s/FIX.4.4_en_phrases.xml", sourceDir)); new Unified2OrchestraTransformer().transform(inputXml, phrasesFile, outputXml); Assertions.assertTrue(outputXml.exists()); }
@Disabled @Test public void transform42() throws TransformerException, URISyntaxException { File inputXml = new File(Thread.currentThread().getContextClassLoader() .getResource("FixRepositoryUnified.xml").toURI()); File outputXml = new File("target/test/FixRepository42.xml"); String sourceDir = inputXml.getParent(); File phrasesFile = new File(String.format("%s/FIX.4.2_en_phrases.xml", sourceDir)); new Unified2OrchestraTransformer().transform(inputXml, phrasesFile, outputXml); Assertions.assertTrue(outputXml.exists()); }