xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Samson, Lyndon [IT]" <lyndon.sam...@ssmb.com>
Subject RE: req for servlet example
Date Tue, 30 Jan 2001 09:39:29 GMT
I combbled this together so haven't checked for compile errors. You get the
general idea though. 

hope it helps
lyndon

 --- cut ---
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

import org.w3c.dom.Document;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.w3c.dom.*;

//
----------------------------------------------------------------------------
-----------------------------
public class BogStdServlet extends HttpServlet {

    public void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
        StringWriter outXML = new java.io.StringWriter(); 

        resp.setContentType("text/html");
        PrintWriter out = new PrintWriter(resp.getOutputStream());

        String inXML = getInputXML(); // User method to load data to be
tranformed into a String
	  String fileNameXSL = "myHTMLconverter_sylesheet.xsl";

        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer(new
StreamSource(fileNameXSL));
        transformer.transform(new StreamSource(new StringReader(inXML)), new
StreamResult(outXML)); 

        out.println(outXML.toString());
        out.close();
    }
}
 --- cut ---

-----Original Message-----
From: Heather Lloyd [mailto:lloydheat@yahoo.com]
Sent: Monday, January 29, 2001 4:55 PM
To: general@xml.apache.org
Subject: req for servlet example


can you point me to a really, really simple example of
a java class that extends HttpServlet and uses an
XSLTProcessor to transform a simple XML doc using a
simple XSL Stylesheet to return an HTML doc to a
browser?  thanks


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org

Mime
View raw message