protected void process(Document document) throws Exception {
// load the transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xsl
.toString()));
// Since we are using the native DOM implementation
// converting the tree to DOM should be really fast...
DOMWriter domWriter = new DOMWriter();
long start = System.currentTimeMillis();
org.w3c.dom.Document domDocument = domWriter.write(document);
long end = System.currentTimeMillis();
System.out.println("Converting to a W3C Document took: "
+ (end - start) + " milliseconds");
// now lets create the TrAX source and result
// objects and do the transformation
Source source = new DOMSource(domDocument);
StreamResult result = new StreamResult(System.out);
transformer.transform(source, result);
}
Perform XSLT on the stylesheet |