Source code: com/eireneh/bible/view/servlet/Web.java
1
2 package com.eireneh.bible.view.servlet;
3
4 import java.net.URL;
5 import java.io.*;
6
7 import javax.servlet.http.*;
8
9 import org.w3c.dom.*;
10 import org.xml.sax.*;
11 import org.xml.sax.helpers.*;
12 import org.apache.xerces.dom.*;
13
14 import com.eireneh.util.*;
15 import com.eireneh.bible.util.*;
16 import com.eireneh.bible.control.*;
17
18 /**
19 * The plan is to have the entire web site delivered via XML/XSL.
20 *
21 * <table border='1' cellPadding='3' cellSpacing='0' width="100%">
22 * <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
23 * Distribution Licence:<br />
24 * Project B is free software; you can redistribute it
25 * and/or modify it under the terms of the GNU General Public License,
26 * version 2 as published by the Free Software Foundation.<br />
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 * General Public License for more details.<br />
31 * The License is available on the internet
32 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
33 * <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
34 * MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
35 * The copyright to this program is held by it's authors.
36 * </font></td></tr></table>
37 * @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
38 * @see docs.Licence
39 * @author Joe Walker
40 */
41 public class Web extends BaseServlet
42 {
43 /**
44 * Enter elements into an XML Document that can be transformed into
45 * an HTML document using XSL
46 * @param state data about the current request
47 * @param node The place to start adding data
48 * @param request A description of the request
49 */
50 public void generateData(State state, Node node, HttpServletRequest request) throws Exception
51 {
52 String page = request.getParameter("page");
53
54 if (page == null || page.equals(""))
55 page = "home";
56
57 URL xml_url = NetUtil.lengthenURL(Project.getWebRoot(), page+".xml");
58 InputStream xml_in = xml_url.openStream();
59 InputSource xml_is = new InputSource(xml_in);
60
61 // Use SAX to add to the given document
62 HandlerBase handler = new DOMHandlerBase(node);
63
64 Parser parser = ParserFactory.makeParser(DEFAULT_PARSER_NAME);
65 parser.setDocumentHandler(handler);
66 parser.setErrorHandler(handler);
67 parser.parse(xml_is);
68 //XMLUtil.printDocument(doc);
69
70 // DOMParser xml_parser = new DOMParser();
71 // xml_parser.parse(xml_is);
72 }
73
74 /** Default parser name. */
75 private static final String DEFAULT_PARSER_NAME = "com.ibm.xml.parsers.SAXParser";
76 }