Converting XML to XHTML from a servlet
843834Aug 7 2002 — edited Aug 9 2002Hi,
I'm using Tomcat as my server and am trying to convert the XML code I generate to XHTML and send it to the browser. This is the code I'm using
String lsUniqFileName = "C:/Program Files/Apache Tomcat 4.0/webapps/ROOT"+newfaq+".xml";
File loFile = new File(lsUniqFileName);
OutputStream loOutputStream = new FileOutputStream(loFile);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(new DOMSource(moXmlDocument),new StreamResult(loOutputStream));
Source xmlSource = new StreamSource(new URL(lsUniqFileName).openStream());
Source xslSource = new StreamSource(new URL("file:yt.xsl").openStream());
Transformer transformer1 = tf.newTransformer(xslSource);
transformer1.transform(xmlSource, new StreamResult(out));
Which creates an XML document but dosen't transform it to XHTML. I have the stylesheet in the root directory of Tomcat.
Any help is greatly appreciated