Friday, May 27, 2011

java code to transform xml to html using xsl



package com.trans;

import javax.xml.transform.*;
import java.net.*;
import java.io.*;

public class HowToXSLT {
public static void main(String[] args) {
try {

TransformerFactory tFactory = TransformerFactory.newInstance();

Transformer transformer =
tFactory.newTransformer
(new javax.xml.transform.stream.StreamSource
("C:\\xampp\\htdocs\\s3\\fancy-hist.xsl"));

transformer.transform
(new javax.xml.transform.stream.StreamSource
("C:\\xampp\\htdocs\\s3\\findbugsXml.xml"),
new javax.xml.transform.stream.StreamResult
( new FileOutputStream("C:\\howto.html")));
}
catch (Exception e) {
e.printStackTrace( );
}
}
}

No comments: