The following example shows how to apply an XSL Transformation to a JDOM document and get the transformation result in the form of a list of JDOM nodes:
public static List transform(Document doc, String stylesheet) throws JDOMException { try { Transformer transformer = TransformerFactory.newInstance() .newTransformer(new StreamSource(stylesheet)); JDOMSource in = new JDOMSource(doc); JDOMResult out = new JDOMResult(); transformer.transform(in, out); return out.getResult(); } catch (TransformerException e) { throw new JDOMException("XSLT Transformation failed", e); } }
@see org.jdom.transform.JDOMSource
@version $Revision: 1.24 $, $Date: 2007/11/10 05:29:02 $
@author Laurent Bihanic
@author Jason Hunter
|
|