Performing XSL Transformations : XML « JSP « Java






Performing XSL Transformations

 


<%@ page language="java" contentType="text/html" %>
<%@ page pageEncoding="UTF-8"%>
<%@ page import="javax.xml.transform.*"%>
<%@ page import="javax.xml.transform.stream.*"%>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Customer Orders</title>
  </head>
  <body>

    <h1>Customer Orders</h1>

      <%! String FS = System.getProperty("file.separator"); %>
        <%
        String xmlFile = request.getParameter("XML");
        String xslFile = request.getParameter("XSL");

        String ctx = getServletContext().getRealPath("") + FS;
        xslFile = ctx + xslFile;
        xmlFile = ctx + xmlFile;

        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
        transformer.transform(new StreamSource(xmlFile), new StreamResult(out));
        %>
    </body>
</html>

 








Related examples in the same category

1.Using the Core XML tags
2.XML transformation
3.JSP in pure XML generating conforming XHTML
4.XSLT In JSP
5.XSLT in JSP 2
6.JSP Parsing using the DOM
7.JSP Parsing using JDOM
8.JSP Parsing using the DOM and JSTL
9.JSP and SAX
10.JSP Displaying a Subset in XML
11.JSP XML and XSLT transform
12.JSP List of data in the XML document
13.Deal With XML In JSP