try {
String xslFile = DATA_DIR.resolve("XMLFile1.xml").toString();
String xmlFile = DATA_DIR.resolve("XSLTFile1.xslt").toString();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer =
factory.newTransformer(new StreamSource(xslFile));
StreamSource xmlSource = new StreamSource(xmlFile);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
StreamResult output = new StreamResult(baos);
transformer.transform(xmlSource, output);
com.aspose.pdf.HtmlLoadOptions options = new com.aspose.pdf.HtmlLoadOptions();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(bais, options);
pdfDocument.save(DATA_DIR.resolve("data_xml.pdf").toString());
} catch (Exception e) {
System.out.println(e.getMessage());
}