Hi all friends,
I have some problem with my servlet .I want to
convert my xml file into html on the fly for this iam
using "xalan.jar".It complies perfectly but when I am
going to run this file through javawebserver only
println statement comes on browser but no .html file
formed.
Can any one tell me where I done a mistake.Any help
will be highly appreciated.Below r my codes.
It is my xml file:-
------------------
<?xml version="1.0"?>
<root>
<doc>Hello</doc>
</root>
It is my xsl file:-
----------------------
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="//root"/>
</xsl:template>
<xsl:template match="root">
<html>
<body bgcolor="#ffffff" text="#000000">
<b><u><xsl:value-of select="doc"/></u></b>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
It is my servlet:-
-------------------
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.TransformerException;
import
javax.xml.transform.TransformerConfigurationException;
import java.io.*;
public class Sample6 extends HttpServlet
{
public void doGet (HttpServletRequest
request,HttpServletResponse response)
throws IOException,ServletException
{ response.setContentType("text/html");
PrintWriter out=response.getWriter();
try
{
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new
StreamSource("c:/foo.xsl"));
transformer.transform(new StreamSource("c:/foo.xml"),
new StreamResult(new
FileOutputStream("c:/foo.html")));
}catch(Exception e){}
out.println("The result is in foo.out");
}
}
Thanks in Advance
Bikash
__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger.
http://im.yahoo.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html