Overview | Package | Class
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class com.ibm.XMLEnabler.XMLEnabler

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.ibm.XMLEnabler.XMLEnabler

public class XMLEnabler
extends javax.servlet.http.HttpServlet

This servlet transforms an XML document using a particular XSL stylesheet. The stylesheet used is determined by two factors:

Currently the XML document is passed in as a parameter (URL=) in the URL itself. This document is parsed, the appropriate XSL stylesheet is parsed, then the two documents are combined. The results of the transformation are returned via HTTP to the caller.

Sample Invocation:

This URL invokes the servlet and returns a transformed XML document:

 http://localhost:8080/servlet/com.ibm.XMLEnabler.XMLEnabler?URL=http://localhost/testdata.xml
 

Property File Format:

The property file can include three types of parameters:

Default
Defines the URL of the default XSL stylesheet
Order
Defines the order of the browser types for which we should check.
search-strings
The name of this property is a search string that should be found in the HTTP header, along with the URL of the XSL stylesheet that should be used for any browser that matches the search string.

Here's a sample file format:

 Default=http://localhost/xmLDAP01.xsl
 Order=MSIE/Opera/Lynx/Mozilla
 MSIE=http://localhost/xmLDAP01.xsl
 Opera=http://localhost/xmLDAP02.xsl
 Lynx=http://localhost/xmLDAP03.xsl
 Mozilla=http://localhost/hlist.xsl
 

This file defines the default stylesheet, the order in which browser types should be searched, and stylesheets for browsers whose HTTP headers include the strings "MSIE" (Internet Explorer), "Opera," "Lynx," and "Mozilla" (Netscape). It is significant in this example that "MSIE" is queried before "Mozilla," because both Internet Explorer and Netscape contain the string "Mozilla" in their HTTP headers.

Ways to Enhance This Code:

Version:
1.00, 16 Nov 1998
Author:
Doug Tidwell, with thanks to Scott Boag for his XSL engine, and the Tokyo Research Lab team for their brilliant XML parser.
See Also:
Serialized Form

Method Summary
void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          The service method responds to an HTTP request.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, log, service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Method Detail

service

public void service(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
            throws java.io.IOException,
                   java.net.MalformedURLException
The service method responds to an HTTP request.
Parameters:
req - HttpServletRequest that encapsulates the request to the servlet
resp - HttpServletResponse that encapsulates the response from the servlet
Throws:
java.io.IOException - if detected when handling the request
java.net.MalformedURLException - if the requested URL is not valid
Overrides:
service in class javax.servlet.http.HttpServlet

Overview | Package | Class
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

© Copyright 1998 IBM Corporation.