Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Converting XML to XHTML from a servlet

843834Aug 7 2002 — edited Aug 9 2002
Hi,
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 6 2002
Added on Aug 7 2002
1 comment
150 views