dleslie     01/02/22 13:44:57

  Modified:    java/xdocs/sources/xalan DONE samples.xml usagepatterns.xml
  Log:
  Added info on servlets and 2 new samples.
  More bug fixes in "DONE".
  
  Revision  Changes    Path
  1.47      +20 -0     xml-xalan/java/xdocs/sources/xalan/DONE
  
  Index: DONE
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/xdocs/sources/xalan/DONE,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- DONE      2001/02/20 17:38:35     1.46
  +++ DONE      2001/02/22 21:44:54     1.47
  @@ -25,6 +25,17 @@
     NodeList, removed duplicate Boolean from both, and fixed Boolean 
conversion to give Boolean precedence over String. <br/><br/></li>  
     <li>Fixed a SQL library extension bug reported by Dimitry Voytenko. In 
some cases &lt;xsl:copy-of select="sql:query(...)"/&gt; was
     crashing with a NullPointerException.  The null nodetest is now used to 
mean the same as "node()".<br/><br/></li>  
  +  <li>Modified XPathParser to check for null token before checking for a 
letter.<br/><br/></li>
  +  <li>Fixed bug reported by Christian Glencross. The TransformerIdentityImpl 
ContentHandler is now initialized when called by the Xerces
  +   1.2.3 SAX Parser prior to startDocument().<br/><br/></li>
  +  <li>Fixed how string node values are returned in 
org.apache.xalan.lib.Extensions.<br/><br/></li>
  +  <li>Bug fix attributed to Norman Walsh. If the "name" attribute does not 
appear in the attribute list, getIndex(name) returns -1, but
  +  getChildAttribute() was incorrectly returning the first attribute. We now 
return null if index &lt;0.<br/><br/></li>
  +  <li>Implemented DeclHandler for identity transforms.<br/><br/></li>
  +  <li><br/><br/></li>
  +  <li><br/><br/></li>
  +  <li><br/><br/></li>
  +  
     <li></li>
   
   </ul>
  @@ -35,6 +46,15 @@
     <li><br/><br/></li>
     <li><br/><br/></li>
     <li></li>        
  +</ul>
  +
  +<p><em>Other:</em></p>
  +<ul>
  +  <li>In response to requests for simpler sample servlets, we have added two 
servlets to the servlet package: <link idref="samples"
  +  anchor="simplexsltservlet">servlet.SimpleXSLTServlet</link> and <link 
idref="samples" anchor="xsltservletwithparams">
  +     XSLTServletWithParams</link>. See also the example in <link 
idref="usagepatterns" anchor="servlet">Using &xslt4j; in a servlet</link>.
  +     <br/><br/>Both of these classes are in xalanservlet.jar and are 
recompiled when you use the Ant build.xml to rebuild the
  +     servlet.</li>
   </ul>
   <p>For a list of tasks in the &xslt4j2; To-Do list that have been completed, 
see <jump href="todo.html#release-date-completed">Tasks completed</jump>.</p>
   </s3>
  
  
  
  1.26      +53 -16    xml-xalan/java/xdocs/sources/xalan/samples.xml
  
  Index: samples.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/xdocs/sources/xalan/samples.xml,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- samples.xml       2001/02/01 15:35:50     1.25
  +++ samples.xml       2001/02/22 21:44:55     1.26
  @@ -68,7 +68,7 @@
   <li><link anchor="applyxpath">ApplyXPath</link></li>
   <li><link anchor="appletxmltohtml">AppletXMLtoHTML</link></li>
   <li><link anchor="get-todo-list">get-todo-list</link></li>
  -<li><link anchor="servlet">Servlet</link></li>
  +<li><link anchor="servlet">servlet</link></li>
   <li><link anchor="extensions">Extensions</link></li>
   <li><link anchor="trace">Trace</link></li>
   <li><link anchor="trax">trax</link></li>
  @@ -180,32 +180,68 @@
        subdirectory of the Apache CVS repository.</p>
        <p>How to run it: Open get-todo-list.html in the Internet Explorer 5 
browser.</p>
       </s2><anchor name="servlet"/>
  -    <s2 title="Servlet">
  +    <s2 title="servlet">
  +   <p>For a general introduction, see <link idref="usagepatterns" 
anchor="servlet">Using &xslt4j; in a servlet</link>.</p>
  +    <p>The servlet subdirectory contains three sample servlets that use 
&xslt4j; to perform transformations. These servlets are in a package
  +    named servlet and are compiled in
  +    xalanservlet.jar. To run these samples, you must place xalanservlet.jar, 
and any XML and XSL files you want to use
  +    on a web server with a servlet engine, place xalanservlet.jar on the 
servlet engine class path, and configure the servlet engine to
  +    locate the XML and XSL files, and the properties file used by 
ApplyXSL.</p>
  +    <p>SimplestXSLTServlet applies a particular stylesheet to a particular 
XML document. XSLTServletWithParams accepts parameters for
  +    stylesheet, XML document, and stylesheet parameters. ApplyXSLT (and 
associated classes) is much closer 
  +    to a production level servlet. It accepts parameters, provides a 
listener for capturing and reporting debugger messages, and supports 
  +    use of a property file to determine which stylesheet to apply based on 
the identity of the client browser/device.</p>
  +    <ul>
  +      <li><link 
anchor="simplexsltservlet">servlet.SimpleXSLTServlet</link></li>      
  +      <li><link 
anchor="xsltservletwithparams">servlet.XSLTServletWithParams</link></li>      
  +      <li><link anchor="applyxslt">servlet.ApplyXSLT</link></li>
  +    </ul><anchor name="simplexsltservlet"/>
  +    <s3 title="servlet.SimpleXSLTServlet">
  +    <p>What it does: servlet.SimpleXSLTServlet applies the todo.xsl 
stylesheet to todo.xml and returns the transformation result to the
  +    HTTP client.</p>
  +    <p>To run this servlet: place todo.xsl and todo.xml (from the 
distribution root directory) in the directory where your servlet engine
  +    looks for HTTP documents, place xalanservlet.jar on the servlet engine 
classpath, and set up an HTML page to call the servlet as
  +    follows:</p>
  
+<gloss><label>http://localhost/servlethome/servlet.SimpleXSLTServlet</label></gloss>
  +     </s3><anchor name="xsltservletwithparams"/>
  +     <s3 title="servlet.XSLTServletWithParams">
  +     <p>What it does: servlet.XSLTServletWithParams takes parameters in the 
request -- a URL parameter for
  +     the XML input document URL and an xslURL parameter for the stylesheet 
URL.</p>
  +     <p>To use XSLTServletWithParams to perform the same transformation as 
SimplestServlet: 
  +     place todo.xsl and todo.xml in the directory where your servlet engine 
looks for HTTP documents, place
  +     xalanservlet.jar on the servlet engine classpath, and set up an HTML 
page to call the servlet as follows:</p>
  
+<gloss><label>http://localhost/servlethome/servlet.XSLTServletWithParams?URL=file:todo.xml&amp;
  +xslURL=file:todo.xsl</label></gloss>
  +     <p>If the XML document contains an associated stylesheet (a stylesheet 
Processing Instruction) that you want to use, simply omit the
  +     xslURL parameter.</p>
  +     <p>If the stylesheet takes stylesheet parameters, you can include them 
in the URL. For example to set set the param1
  +     stylesheet parameter to foo, include param1=foo in the URL.</p>
  +     </s3><anchor name="applyxslt"/>
  +     <s3 title="servlet.ApplyXSLT">
       <p>What it does: The client (which you must set up) specifies an XML 
document and a stylesheet. The servlet
        performs the transformation and returns the output to the client. You 
can use media.properties to specify 
       which stylesheet is to be used depending on the client 
browser/device.</p>
  -    <p>How to run it:</p>
  -    <ol>
  -      <li>Configure your application server (Websphere or JServ, for 
example) so it can find the classes (in
  -       xalanservlet.jar) as well as the stylesheets and properties file in 
the servlet subdirectory.</li>
  -      <li>Set up an HTML client to call DefaultApplyXSL with arguments as 
illustrated below.</li>
  -    </ol>
  -        <p>Examples:</p>
  +    <note>The source files for this servlet include ApplyXSLT.java, 
ApplyXSLTProperties.java, DefaultApplyXSLTProperties.java,
  +    ApplyXSLTListener.java, and ApplyXSLTException.java.</note>
  +    <p>To run the servlet: put xalanservlet.jar on the servlet engine 
classpath, configure your servlet engine so it can find the 
  +     stylesheets and properties file in the servlet subdirectory (and in 
xalanservlet.jar), and set up an HTML page to call
  +     servlet.ApplyXSLT with arguments as illustrated below.</p>
  +     <p>Examples:</p>
   <gloss>
  -<label>http://localhost/servlet/DefaultApplyXSL?URL=/data.xml&amp;xslURL=
  
+<label>http://localhost/servlethome/servlet.ApplyXSLT?URL=/data.xml&amp;xslURL=
   /style.xsl</label>
   <item>...applies the style.xsl stylesheet to the data.xml data. Both files 
are<br/>
  -served from the Web server's HTTP XSLTInputSource root.<br/><br/></item>
  -<label>http://localhost/servlet/DefaultApplyXSL?URL=/data.xml&amp;xslURL=
  +served from the Web server's HTTP document root.<br/><br/></item>
  
+<label>http://localhost/servlethome/servlet.ApplyXSLT?URL=/data.xml&amp;xslURL=
   /style.xsl&amp;debug=true</label>
   <item>...ensures that XML and XSL processor messages are returned in the 
event of problems
   applying style.xsl to data.xml<br/><br/></item>
  
-<label>http://localhost/servlet/DefaultApplyXSL/data.xml?xslURL=/style.xsl</label>
  
+<label>http://localhost/servlethome/servlet.ApplyXSLT/data.xml?xslURL=/style.xsl</label>
   <item>...applies the style.xsl stylesheet to the data.xml data, just like 
the first example.
   This is an alternative way of specifying the XML XSLTInputSource by 
utilizing the HTTP request's path
   information.<br/><br/></item>
  -<label>http://localhost/servlet/DefaultApplyXSL/data.xml</label>
  -<item>...examines data.xml for an associated XSL stylesheet. If multiple 
XSLs are associated with the data, the stylesheet whose media attribute maps to 
your browser type will be chosen.  If no mapping is successful, the primary 
associated stylesheet is used.<br/><br/></item>
  +<label>http://localhost/servlethome/servlet.ApplyXSLT/data.xml</label>
  +<item>...examines data.xml for an associated XSL stylesheet (a stylesheet 
Processing Instruction). If multiple XSLs are associated with the data, the 
stylesheet whose media attribute maps to your browser type will be chosen.  If 
no mapping is successful, the primary associated stylesheet is 
used.<br/><br/></item>
   <label>http://localhost/servlet/data.xml</label>
   <item>...provides the same function as the previous example, but this 
example assumes
   that /servlet/data.xml has been mapped to be executed by this servlet.  The 
servlet engine may be configured
  @@ -213,7 +249,8 @@
   
<label>http://localhost/servlet/data.xml?catalog=http://www.xml.org/dtds/oag.xml</label>
   <item>...supplements any servlet-configured XCatalog
   with a catalog of supply chain DTDs residing at the XML.ORG DTD 
repository.</item>
  -</gloss>
  +</gloss>     
  +   </s3>
        </s2><anchor name="extensions"/>
       <s2 title="Extensions">
       <p>For an introduction to the creation and use of extension elements and 
extension functions, and
  
  
  
  1.29      +45 -1     xml-xalan/java/xdocs/sources/xalan/usagepatterns.xml
  
  Index: usagepatterns.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/xdocs/sources/xalan/usagepatterns.xml,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- usagepatterns.xml 2001/02/14 20:09:51     1.28
  +++ usagepatterns.xml 2001/02/22 21:44:56     1.29
  @@ -362,7 +362,51 @@
   
   </s2><anchor name="servlet"/>
   <s2 title="Using &xslt4j; in a servlet">
  -<p>You can set up a servlet to use &xslt4j; to respond to requests for XML 
documents by transforming those documents into HTML and serving them to 
clients. For a sample of how this can be done, see <link idref="samples" 
anchor="servlet">sample servlet</link>.</p>
  +<p>You can set up a servlet to use &xslt4j; to respond to requests for XML 
documents by transforming those documents into HTML and serving them to web 
browsers. To respond to HTTP GET requests, all you need to do is overwrite the 
HttpServlet doGet() method with a procedure that instantiates a Transformer and 
uses it to perform a transformation. As the following example shows, you can 
generate a ResultStream that a PrintWriter writes to the HttpResponse 
OutputStream, returning the transformation output to the web browser.</p>
  +<source>
  +public class SampleXSLServlet extends javax.servlet.http.HttpServlet {
  +  
  +  // Respond to HTTP GET requests from browsers.
  +  public void doGet (javax.servlet.http.HttpServletRequest request,
  +                     javax.servlet.http.HttpServletResponse response)
  +    throws javax.servlet.ServletException, java.io.IOException
  +  {
  +    // Output goes in the response stream.
  +    java.io.PrintWriter out = 
  +                         new java.io.PrintWriter(response.getOutputStream());
  +    // Set content type for HTML.
  +    response.setContentType("text/html");    
  +    try
  +    {        
  +      javax.xml.transform.TransformerFactory tFactory = 
  +                javax.xml.transform.TransformerFactory.newInstance();
  +      // Get the XML input document and the stylesheet, both in the servlet
  +      // engine document directory.
  +      javax.xml.transform.Source xmlSource = 
  +                new javax.xml.transform.stream.StreamSource
  +                             (new java.net.URL("file:foo.xml").openStream());
  +      javax.xml.transform.Source xslSource = 
  +                new javax.xml.transform.stream.StreamSource
  +                             (new java.net.URL("file:foo.xsl").openStream());
  +      // Generate the transformer.
  +      javax.xml.transform.Transformer transformer = 
  +                             tFactory.newTransformer(xslSource);
  +      // Perform the transformation, sending the output to the response.
  +      transformer.transform(xmlSource, 
  +                           new javax.xml.transform.stream.StreamResult(out));
  +    }
  +    // If an Exception occurs, return the error to the client.
  +    catch (Exception e)
  +    {
  +      out.write(e.getMessage());
  +      e.printStackTrace(out);    
  +    }
  +    // Close the PrintWriter.
  +    out.close();
  +  }  
  +}</source>
  +<p>For a working sample, see <link idref="samples" 
anchor="simplexsltservlet">SimpleXSLTServlet</link>.</p>
  +<p>In the preceding example, the URLs for the XML document and XSL 
stylesheet are hardcoded in the servlet. You can also create a servlet that 
parses the request URL for input parameters specifying the XML document, XSL 
stylesheet, and any relevant stylesheet parameters. For a sample, see <link 
idref="samples" anchor="xsltservletwithparams">XSLTServletWithParams</link>. 
For a more robust and complex sample that also employs a properties file to 
determine which stylesheet to use depending on the client browser/device, see 
<link idref="samples" anchor="applyxslt">ApplyXSLT</link>.</p>
   </s2><anchor name="extensions"/>
   <s2 title="Creating and using extensions">
   <p>For those cases where you want to be able to call procedural code from 
within a stylesheet, the &xslt4j; Extensions facility supports the creation of 
extension elements and extension functions. See <link 
idref="extensions">Extensions</link> and <link idref="samples" 
anchor="extensions">Extensions samples</link>.</p>
  
  
  

Reply via email to