Hi Amit,
To transform an XML file using an XSL file in JSP page, you can use the xalan package from Apache.
Suppose u have a xml file content.xml and corresponding style file style.xml, then the required code will be
---------------------- xalanxsl.jsp -------------
<%@ import="java.io.*,org.apache.xalan.xslt.*,org.apache.xalan.xpath.*"%>
<%
ByteArrayOutputStream bStream=new ByteArrayOutputStream();
XSLTProcessor processor ;
try
{
processor= XSLTProcessorFactory.getProcessor();
XSLTInputSource inputxml=new XSLTInputSource("content.xml");
XSLTInputSource inputxsl=new XSLTInputSource("style.xsl");
processor.process(inputxml,inputxsl,new XSLTResultTarget(bStream));
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
%>
<!--Displaying the HTML OUTPUT by combing XML and XSL -->
<%=bStream%>
<!--End-->
---------------------- xalanxsl.jsp -------------
Remember you need to set xalan.jar in the class path.
George Joseph,
Transversal E Networks. [ June 29, 2002: Message edited by: George Joseph ]