Does anyone know the best way to cast/convert a Node object properly (can't cast it directly as a SAXSource or DOMSource .. .or even via InputSource) so that you can do an xslTransform on it? In the code below, I'd want the Node cast appropriately where
SOURCE is in the transform. That is my input ... a Node object, and I want to apply XSL to it.
TIA!
String out;
TransformerFactory tFactory = TransformerFactory.newInstance();
StreamSource theXSL = new StreamSource(Constants.xslNodeTransform);
Templates template;
Transformer xslTrans;
try {
template = tFactory.newTemplates(theXSL);
xslTrans = tFactory.newTransformer(theXSL);
} catch (TransformerConfigurationException tce) {
// handle exception
}
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
Result res = new StreamResult(byteStream);
try {
xslTrans.transform(_SOURCE_ res);
} catch (TransformerException te) {
// handle exception
}
out = byteStream.toString();
Edited by: java5on on May 22, 2009 12:40 PM