1 package org.enhydra.snapper.business; 2 6 import javax.xml.transform.stream.StreamSource ; 7 import javax.xml.transform.TransformerFactory ; 9 import javax.xml.transform.Transformer ; 10 11 import org.enhydra.snapper.Log; 12 import org.enhydra.snapper.spec.*; 13 import java.io.*; 14 15 public class TransformManagerImpl implements TransformManager{ 16 17 18 public String transform(String content,String xslPath)throws Exception { 19 20 try{ 21 TransformerFactory tFactory = TransformerFactory.newInstance(); 22 Transformer transformer = tFactory.newTransformer(new StreamSource (xslPath)); 23 24 25 StringWriter stringWriter= new StringWriter(); 26 transformer.transform(new StreamSource (new StringReader(content)),new javax.xml.transform.stream.StreamResult 27 (stringWriter) ); 28 String result=stringWriter.toString(); 29 return result; 30 }catch(Exception e) 31 { 32 Log.logException(e); 33 return new String (); 34 } 35 } 36 37 38 } | Popular Tags |