Created
May 11, 2017 23:09
-
-
Save jkiddo/280aff148e48f83d53a50909724d8dc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void run(String sourceDoc, String xslDoc, String resultDoc, | |
Boolean dtdValidation) throws SaxonApiException { | |
/* | |
* http://www.cs.duke.edu/courses/fall08/cps116/docs/saxon/samples/java/ | |
* S9APIExamples.java | |
*/ | |
Processor proc = new Processor(false); | |
XsltCompiler comp = proc.newXsltCompiler(); | |
XsltExecutable exec = comp.compile(new StreamSource(xslDoc)); | |
XsltTransformer transformer = exec.load(); | |
System.out.println("Doing time ... " + new Date()); | |
DocumentBuilder builder = proc.newDocumentBuilder(); | |
builder.setLineNumbering(true); | |
builder.setDTDValidation(dtdValidation); | |
XdmNode source = builder.build(new StreamSource(new File(sourceDoc))); | |
Serializer out = new Serializer(); | |
// out.setOutputProperty(Serializer.Property.METHOD, "html"); | |
out.setOutputProperty(Serializer.Property.INDENT, "yes"); | |
out.setOutputFile(new File(resultDoc)); | |
transformer.setInitialContextNode(source); | |
transformer.setDestination(out); | |
transformer.transform(); | |
System.out.println("Doing time end ... " + new Date()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment