import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.File;
public class XmlToHtmlWithXSLT
{
public static void main(String[] args)
{
final String path = "%d.%s";
for (int i = 1; i <= 7; i++){
Source xmlInput = new StreamSource(new File(String.format(path, i, "xml")));
Source xsl = new StreamSource(new File(String.format(path, i, "xsl")));
Result xmlOutput = new StreamResult(new File(String.format(path, i, "html")));
try{
Transformer transformer =
TransformerFactory.newInstance().
newTransformer(xsl);
transformer.transform(xmlInput, xmlOutput);
}
catch (TransformerException e){
System.out.println("Tranform has failure for " + i);
}
}
}
}