 |
Return to article
private String xslTransformation(String msg, String rule)
throws TransformerException,
TransformerConfigurationException,
FileNotFoundException,
IOException {
InputSource in = new InputSource(new StringReader(msg));
DOMParser domParser = new DOMParser();
//build DOM object
try {
domParser.parse(in);
} catch (Exception e) {
System.out.println("QueueManager:xslTransformation:1:" + e.toString());
}
Document docInput = domParser.getDocument();
DOMSource ds = new DOMSource(docInput.getDocumentElement());
DOMResult dr = new DOMResult();
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource(rule + ".xsl"));
transformer.transform(ds, dr);
Document docTransform = (Document) dr.getNode();
StringWriter sr = null;
try {
OutputFormat of = new OutputFormat(docTransform);
sr = new StringWriter();
XMLSerializer s = new XMLSerializer(sr, of);
s.asDOMSerializer();
s.serialize(docTransform.getDocumentElement());
} catch (Exception e) {
System.out.println("QueueManager:xslTransformation:2:" + e.toString());
}
log("QueueManager: XSLT performed");
return sr.toString();
}
}
|
Return to article
|  |
|