Transformer transformer = TransformerFactory.newInstance
().newTransformer();
It seems you are missing of adding xslt file.
It is supposed to be like this.
Transformer transformer = TransformerFactory.newInstance().newTransformer(inputXSL); Also check whether the xlan processor is in your path.It comes by default with j2sdk1.4.
Instead of
tomcat try following standalon class and see if it works.
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.Source;
import java.io.ByteArrayOutputStream;
public class Trans{
public static void main(
String args[]){
try{
Source inputXML= new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream("source.xml"));
Source inputXSL = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream("abc.xslt"));
Result result = new StreamResult(System.out);
TransformerFactory tFact = TransformerFactory.newInstance();
Transformer tf = tFact.newTransformer(inputXSL);
tf.setOutputProperty("indent", "yes");//
tf.transform(inputXML,result);
}catch(Exception e){
e.printStackTrace();
}
}
}