dleslie     00/02/11 16:00:15

  Added:       samples/AppletXMLtoHTML README.html appletXMLtoHTML.html
                        client.html foo-s1.xml lts3611beac.jpg
                        rabbitwhorn.jpg runAppletFromServer.html
                        s1ToHTML.xsl target.html testOut.html
                        xalanApplets.xml
               samples/Extensions 1basicJscript.xml 1basicJscript.xsl
                        2java-namespace.xml 2java-namespace.xsl
                        3numlistJava.xml 3numlistJava.xsl
                        4numlistJscript.xml 4numlistJscript.xsl
                        IntDate.java MyCounter.java readme.html
               samples/Pipe Pipe.java foo.xml foo.xsl foo2.xsl readme.html
               samples/Servlet ApplyXSL.java ApplyXSLException.java
                        ApplyXSLListener.java ApplyXSLProperties.java
                        DefaultApplyXSL.java DefaultApplyXSLProperties.java
                        default.xsl default2.xsl media.properties
                        readme.html
               samples/SimpleTransform SimpleTransform.java foo.xml foo.xsl
                        readme.html
               samples/TransformToDom TransformToDom.java foo.xml foo.xsl
                        readme.html
               samples/UseStylesheetParam UseStylesheetParam.java foo.xml
                        foo.xsl readme.html
  Log:
  Updates around new "Getting Started"
  
  Revision  Changes    Path
  1.1                  xml-xalan/samples/AppletXMLtoHTML/README.html
  
  Index: README.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
  <head>
        <title></title>Xalan Sample Applet</title>
  </head>
  <body bgcolor="#808080" text="#ffffff">
    <table>
      <tr>
        <td><img border="0" hspace="0" vspace="0" align="left" 
src="rabbitwhorn.jpg"></td>
        <td><h2>&nbsp;Running the Xalan sample applet</h2></td>
      </tr>
    </table>
    <hr>
    <p>This applet transforms XML into HTML. Given the restrictions imposed by 
the applet sandbox, the local
    copy of this applet does not load and run correctly in some environments 
and with some versions of IE/Netscape. 
    Run the applet from an HTTP server, and these problems disappear.</p>
  
    <p>To run the applet from one of our Domino servers,
    <a href="http://ipg.lotus.com/lotusxsl/appletXMLtoHTML.html";><b>click 
here</b></a>.</p>
  
    <p>The local copy of client.html assumes that xalan.jar and xerces.jar are 
in the Xalan root directory, 
    two directories above the samples/applet subdirectory. If these JAR files 
are located elsewhere,
    you must edit the applet archive attribute in client.html to point to 
xalan.jar and xerces.jar.</p>
    <p>To run the applet locally, <a href="appletXMLtoHTML.html"><b>click 
here</b></a>.</p>
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/samples/AppletXMLtoHTML/appletXMLtoHTML.html
  
  Index: appletXMLtoHTML.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
  <head>
        <title>Using an applet to perform XSL transformations</title>
  </head>
    <FRAMESET ROWS="125,*" >
      <FRAME NAME="processor" SRC="client.html" SCROLLING="auto" >
        <frameset cols="33%, 33%, *">
          <FRAME NAME="targetArea0" SRC="target.html" >
          <FRAME NAME="targetArea1" SRC="target.html" >
          <FRAME NAME="targetArea2" SRC="target.html" >        
        </frameset>
    </FRAMESET>
  
  </html>
  
  
  
  1.1                  xml-xalan/samples/AppletXMLtoHTML/client.html
  
  Index: client.html
  ===================================================================
  <!doctype HTML public "-//W3C//DTD HTML 4.0 Transitional//EN">
  <html>
    <head>
          <title>Untitled</title>
    </head>
    <script language="JavaScript">
  
      var target="";
  
      function writeSource()
      {
        var sourceString=document.xslControl.getSourceTreeAsText();
        var escString=document.xslControl.escapeString(sourceString);
        var title="XML Source Doc";
        var doc=top.frames[1].document;      
        doc.open();
        doc.write("<h3>" + title + "</h3>");
        doc.write("<PRE>");
        doc.write(escString);
        doc.write("</PRE>");
        doc.close();    
      }
    
      function writeStylesheet()
      {
        var styleString=document.xslControl.getStyleTreeAsText();
        var escString=document.xslControl.escapeString(styleString);
        var title="XSL Stylesheet";
        var doc=top.frames[2].document;          
        doc.open();
        doc.write("<h3>" + title + "</h3>");
        doc.write("<PRE>");
        doc.write(escString);
        doc.write("</PRE>");
        doc.close();     
      } 
  
      function writeTarget()
      {
        var doc=top.frames[3].document;
        doc.open();
        var title="HTML Output";      
        doc.write("<h3>" + title + "</h3>");
        if (document.xmlTransform.displayMode[0].checked) //display HTML
        {
          doc.write(target);
        }
        else // display source
        {
          var escString=document.xslControl.escapeString(target);
          doc.write("<PRE>");
          doc.write(escString);
          doc.write("</PRE>");
        }
        doc.close();    
      }
    
      function clearFrames()
      {
        document.xslControl.freeCache();
        for (i=1; i<4; i++)
          {
          var doc=top.frames[i].document;
          doc.open();
          doc.clear();
          doc.close();
          }
      }
    
      function transform()
      {  
        clearFrames();
        var 
xmlSource=document.xmlTransform.xmlSourceList.options[document.xmlTransform.xmlSourceList.selectedIndex].value;
        document.xslControl.setDocumentURL(xmlSource);
        target=document.xslControl.getHtmlText();
  //    alert("Output: " + target);
        writeSource();
        writeStylesheet();
        writeTarget();
      }
    </script>
    <body onLoad="clearFrames();" bgcolor="#808080" text="#ffffff">
      <form name="xmlTransform" action="" method="POST">
        <h2><img border="0" hspace="0" vspace="0" align="left" 
src="rabbitwhorn.jpg">&nbsp;Transform XML Document</h2>
          <table>
            <tr>
              <td width="50"></td>
              <td align="center"><i>Document to transform</i></td>
              <td align="center"><i>Display output as</i></td>
            </tr>
            <tr>
            <td></td>
            <td align="center">
              <select name="xmlSourceList">
                <option value="xalanApplets.xml" 
selected>&nbsp;xalanApplets.xml&nbsp;
                <option value="foo-s1.xml">&nbsp;foo-s1.xml&nbsp;
              </select>
            </td>
            <td align="center">
              <input type="radio" name="displayMode" checked>HTML&nbsp;&nbsp;
              <input type="radio" name="displayMode">HTML Source
            </td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="button" name="transformButton" value="Transform" 
              onClick="transform();">
            </td>
          </tr>
        </table>
      </form>
      <!-- Be sure you have applet archive attribute set
           so the applet can find xalan.jar and xerces.jar -->  
      <applet  
        name="xslControl"
        code="org.apache.xalan.xslt.client.XSLTProcessorApplet.class"
        archive="../../xalan.jar,../../xerces.jar"
        height="0"
        width"0">
        <param name="documentURL" value="xalanApplets.xml"/>  <!--default 
setting-->
        <param name="styleURL" value="s1ToHTML.xsl"/> <!--doesn't change-->
      </applet>
    </body>
  </html>
  
  
  
  1.1                  xml-xalan/samples/AppletXMLtoHTML/foo-s1.xml
  
  Index: foo-s1.xml
  ===================================================================
  <?xml version="1.0"?>
  <si title="s1 foo">
    <s2 title="Foo">
      <p>Hello</p>
    </s2>
  </si>
  
  
  1.1                  xml-xalan/samples/AppletXMLtoHTML/lts3611beac.jpg
  
        <<Binary file>>
  
  
  1.1                  xml-xalan/samples/AppletXMLtoHTML/rabbitwhorn.jpg
  
        <<Binary file>>
  
  
  1.1                  
xml-xalan/samples/AppletXMLtoHTML/runAppletFromServer.html
  
  Index: runAppletFromServer.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
  <head>
        <title>Xalan Sample Applet</title>
  </head>
  <body bgcolor="#808080" text="#ffffff">
    <table>
      <tr>
        <td><img border="0" hspace="0" vspace="0" align="left" 
src="rabbitwhorn.jpg"></td>
        <td><h2>&nbsp;Run the applet from an HTTP server</h2></td>
      </tr>
    </table>
    <hr>
    <p>To run the applet that appears in this directory from one of our Domino 
servers,
    <a href="http://ipg.lotus.com/lotusxsl/appletXMLtoHTML.html";><b>click 
here</b></a>.</p>
    <p>If you want to run this applet locally, edit the applet archive 
attribute in client.html so that it points to
    xalan.jar and xerces.jar.</p>
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/samples/AppletXMLtoHTML/s1ToHTML.xsl
  
  Index: s1ToHTML.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:output method="html" indent="yes"/>
      
    <xsl:template match="/">
      <xsl:apply-templates/>
    </xsl:template>
  
    <xsl:template match="s1">
      <html>
        <head><title><xsl:value-of select="@title"/></title></head>
        <body  bgcolor="#ffffff" text="#000000">
          <xsl:apply-templates select="s2"/>
        </body>
      </html>
    </xsl:template>
  
    <xsl:template match="s2">
      <table width="100%" border="0" cellspacing="0" cellpadding="4">
        <tr>
          <td bgcolor="#006699">
            <font color="#ffffff" size="+1">
              <b><xsl:value-of select="@title"/></b>
            </font>
          </td>
        </tr>
      </table>
      <xsl:apply-templates/>
      <br/>
    </xsl:template>
  
    <xsl:template match="p">
      <p><xsl:apply-templates/></p>
    </xsl:template>
  
    <xsl:template match="note">
      <table border="0" width="100%">
        <tr>
          <td width="20">&#160;</td>
          <td bgcolor="#88aacc">
            <font size="-1"><i>NOTE: <xsl:apply-templates/></i></font>
          </td>
          <td width="20">&#160;</td>
        </tr>
      </table>
    </xsl:template>
    
    <xsl:template match="ul">
      <ul><xsl:apply-templates/></ul>
    </xsl:template>
  
    <xsl:template match="ol">
      <ol><xsl:apply-templates/></ol>
    </xsl:template>
    
    <xsl:template match="gloss">
      <dl><xsl:apply-templates/></dl>
    </xsl:template>
     <!-- <term> contains a single-word, multi-word or symbolic 
         designation which is regarded as a technical term. --> 
    <xsl:template match="term">
      <dfn><xsl:apply-templates/></dfn>
    </xsl:template>
  
    <xsl:template match="label" priority="1">
      <dt><xsl:apply-templates/></dt>
    </xsl:template>
  
    <xsl:template match="item" priority="2">
      <dd>
        <xsl:apply-templates/>
      </dd>
    </xsl:template>
  
    <xsl:template match="table">
      <p align="center"><table border="0"><xsl:apply-templates/></table></p>
    </xsl:template>
  
    <xsl:template match="source">
      <table border="0" width="100%">
        <tr>
          <td width="20">&#160;</td>
          <td bgcolor="#88aacc"><pre><xsl:apply-templates/></pre></td>
          <td width="20">&#160;</td>
        </tr>
      </table>
    </xsl:template>
  
    <xsl:template match="li">
      <li><xsl:apply-templates/></li>
    </xsl:template>
  
    <xsl:template match="tr">
      <tr><xsl:apply-templates/></tr>
    </xsl:template>
  
    <xsl:template match="th">
      <td bgcolor="#006699" align="center">
        <font color="#ffffff"><b><xsl:apply-templates/></b></font>
      </td>
    </xsl:template>
  
    <xsl:template match="td">
      <td bgcolor="#88aacc"><xsl:apply-templates/>&#160;</td>
    </xsl:template>
  
    <xsl:template match="tn">
      <td>&#160;</td>
    </xsl:template>
  
    <xsl:template match="em">
      <b><xsl:apply-templates/></b>
    </xsl:template>
  
    <xsl:template match="ref">
      <i><xsl:apply-templates/></i>
    </xsl:template>
  
    <xsl:template match="code">
      <code><xsl:apply-templates/></code>
    </xsl:template>
  
    <xsl:template match="br">
      <br/>
    </xsl:template>
  
  
    <xsl:template match="jump">
      <a href="[EMAIL PROTECTED]" target="_top"><xsl:apply-templates/></a>
    </xsl:template>  
  
    <xsl:template match="anchor">
      <a name="[EMAIL PROTECTED]"> </a>
    </xsl:template>
  
    <xsl:template match="img">
      <img src="[EMAIL PROTECTED]" align="right" border="0" vspace="4" 
hspace="4"/>
    </xsl:template>
    
  </xsl:stylesheet>
  
  
  1.1                  xml-xalan/samples/AppletXMLtoHTML/target.html
  
  Index: target.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <html>
    <head>
      <title>Untitled</title>
    </head>
    <body>&nbsp;</body>
  </html>
  
  
  
  1.1                  xml-xalan/samples/AppletXMLtoHTML/testOut.html
  
  Index: testOut.html
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <html>
  <head>
  <title>LotusXSL Applets</title>
  </head>
  <body text="#000000" bgcolor="#ffffff">
  <table cellpadding="4" cellspacing="0" border="0" width="100%">
  <tr><td bgcolor="#006699"><font size="+1" color="#ffffff"><b>Transforming XML 
in an Appplet</b></font></td></tr>
  </table>
      <ol> 
        <li>
          <p>Include
          org.apache.xalan.xslt.client.XSLTProcessorApplet
          in an HTML client.</p>
        </li>
        <li>
          <p>Specify the XML source document and XSL
          stylesheet.</p>
          <p>You can use the DocumentURL and StyleURL PARAM tags 
          or the setDocumentURL() and setStyleURL() methods. 
          If the XML document contains a stylesheet Processing
          Instruction (PI), you do not need to specify an XSL
          stylesheet.</p>
        </li>
        <li>
          <p>Call the transformToHTML() method, which performs
          the transformation and returns the new document as a
          String.</p>
        </li>
      </ol>
    <br>
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/samples/AppletXMLtoHTML/xalanApplets.xml
  
  Index: xalanApplets.xml
  ===================================================================
  <?xml version="1.0"?> 
  <s1 title="About Xalan Applets">
    <s2 title="Transforming XML to HTML in an Applet">
      <ol> 
        <li>
          <p>Include
          org.apache.xalan.xslt.client.XSLTProcessorApplet
          in an HTML client.</p>
        </li>
        <li>
          <p>Specify the XML source document and XSL
          stylesheet.</p>
          <p>You can use the DocumentURL and StyleURL PARAM tags 
          or the setDocumentURL() and setStyleURL() methods. 
          If the XML document contains a stylesheet Processing
          Instruction (PI), you do not need to specify an XSL
          stylesheet.</p>
        </li>
        <li>
          <p>Call the getHtmlText() method, which performs
          the transformation and returns the new document as a
          String.</p>
        </li>
      </ol>
    </s2>
  </s1>
  
  
  1.1                  xml-xalan/samples/Extensions/1basicJscript.xml
  
  Index: 1basicJscript.xml
  ===================================================================
  <?xml version="1.0"?>
  <doc>
    <deadline numdays="2"/>
  </doc>  
   
  
  
  1.1                  xml-xalan/samples/Extensions/1basicJscript.xsl
  
  Index: 1basicJscript.xsl
  ===================================================================
  <?xml version="1.0"?>
  <!--Namespaces are global if you set them in the stylesheet element-->
  <xsl:stylesheet 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
      version="1.0"   
      xmlns:lxslt="http://xml.apache.org/xslt";
      xmlns:my-ext="ext1"
      extension-element-prefixes="my-ext">
      
    <!--The component and its script are in the lxslt namespace and define the 
implementation-->
    <lxslt:component prefix="my-ext" elements="timelapse" functions="getdate">
      <lxslt:script lang="javascript">
        var multiplier=1;
        // Extension element implementations always take two arguments. The 
first
        // argument is the XSL Processor context; the second argument is the 
element.
        function timelapse(xslProcessorContext, elem)
        {
          multiplier=parseInt(elem.getAttribute("multiplier"));
          // The element return value is placed in the result tree.
          // If you do not want a return value, return null.
          // return null;
        }
        function getdate(numdays)
        {
          var d = new Date();
          d.setDate(d.getDate() + parseInt(numdays*multiplier));
          return d.toLocaleString();
        }
      </lxslt:script>
    </lxslt:component>
        
    <xsl:template match="deadline">
      <p><my-ext:timelapse multiplier="2"/>We have received your enquiry and 
will 
        respond by <xsl:value-of select="my-ext:getdate(string(@numdays))"/></p>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  
  1.1                  xml-xalan/samples/Extensions/2java-namespace.xml
  
  Index: 2java-namespace.xml
  ===================================================================
  <?xml version="1.0"?> 
  <doc>
     <date
      year="2000" month="4" day="27"
      format="EEEE, MMM dd, yyyy"/>
  </doc>
  
  
  1.1                  xml-xalan/samples/Extensions/2java-namespace.xsl
  
  Index: 2java-namespace.xsl
  ===================================================================
  <?xml version="1.0"?> 
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                  xmlns:java="http://xml.apache.org/xslt/java";
                  version="1.0">
   
    <xsl:template match="date">
      <xsl:variable name="year" select="string(./@year)"/>
      <xsl:variable name="month" select="string(./@month)"/> 
      <xsl:variable name="day" select="string(./@day)"/>          
      <xsl:variable name="format" select="string(./@format)"/>
      
      <xsl:variable name="formatter"       
           select="java:java.text.SimpleDateFormat.new($format)"/>
      <xsl:variable name="date" 
           select="java:IntDate.getDate($year,$month,$day)"/>         
      <p>Date: <xsl:value-of select="java:format($formatter, $date)"/></p>
    </xsl:template>
   
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/samples/Extensions/3numlistJava.xml
  
  Index: 3numlistJava.xml
  ===================================================================
  <?xml version="1.0"?>
  <doc>
    <name first="David" last="Marston"/>
    <name first="David" last="Bertoni"/>
    <name first="Donald" last="Leslie"/>
    <name first="Emily" last="Farmer"/>
    <name first="Jack" last="Donohue"/>
    <name first="Myriam" last="Midy"/>
    <name first="Paul" last="Dick"/>
    <name first="Robert" last="Weir"/>
    <name first="Scott" last="Boag"/>
    <name first="Shane" last="Curcuru"/>
  </doc>
  
  
  1.1                  xml-xalan/samples/Extensions/3numlistJava.xsl
  
  Index: 3numlistJava.xsl
  ===================================================================
  <?xml version="1.0"?> 
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                  xmlns:lxslt="http://xml.apache.org/xslt";
                  xmlns:counter="MyCounter"
                  extension-element-prefixes="counter"
                  version="1.0">
  
  
    <lxslt:component prefix="counter"
                     elements="init incr" functions="read">
      <lxslt:script lang="javaclass" src="MyCounter"/>
    </lxslt:component>
  
    <xsl:template match="/">
      <HTML>
        <H1>Java Example</H1>
        <counter:init name="index" value="1"/>
        <p>Here are the names in alphabetical order by last name:</p>
        <xsl:for-each select="doc/name">
          <xsl:sort select="@last"/>
          <xsl:sort select="@first"/>
          <p>
          <xsl:text>[</xsl:text>
          <xsl:value-of select="counter:read('index')"/>
          <xsl:text>]. </xsl:text>
          <xsl:value-of select="@last"/>
          <xsl:text>, </xsl:text>
          <xsl:value-of select="@first"/>
          </p>
          <counter:incr name="index"/>
        </xsl:for-each>
      </HTML>
    </xsl:template>
   
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/samples/Extensions/4numlistJscript.xml
  
  Index: 4numlistJscript.xml
  ===================================================================
  <?xml version="1.0"?>
  <doc>
    <name first="David" last="Marston"/>
    <name first="David" last="Bertoni"/>
    <name first="Donald" last="Leslie"/>
    <name first="Emily" last="Farmer"/>
    <name first="Jack" last="Donohue"/>
    <name first="Myriam" last="Midy"/>
    <name first="Paul" last="Dick"/>
    <name first="Robert" last="Weir"/>
    <name first="Scott" last="Boag"/>
    <name first="Shane" last="Curcuru"/>
  </doc>
  
  
  1.1                  xml-xalan/samples/Extensions/4numlistJscript.xsl
  
  Index: 4numlistJscript.xsl
  ===================================================================
  <?xml version="1.0"?> 
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                  xmlns:lxslt="http://xml.apache.org/xslt";
                  xmlns:counter="MyCounter"
                  extension-element-prefixes="counter"
                  version="1.0">
  
    <lxslt:component prefix="counter"
                     elements="init incr" functions="read">
      <lxslt:script lang="javascript">
        var counters = new Array();
  
        function init (xslproc, elem) {
          name = elem.getAttribute ("name");
          value = parseInt(elem.getAttribute ("value"));
          counters[name] = value;
          return null;
        }
  
        function read (name) {
          return "" + (counters[name]);
        }
  
        function incr (xslproc, elem)
        {
          name = elem.getAttribute ("name");
          counters[name]++;
          return null;
        }
      </lxslt:script>
    </lxslt:component>
  
    <xsl:template match="/">
      <HTML>
        <H1>JavaScript Example.</H1>
        <counter:init name="index" value="1"/>
        <p>Here are the names in alphabetical order by last name:</p>
        <xsl:for-each select="doc/name">
          <xsl:sort select="@last"/>
          <xsl:sort select="@first"/>
          <p>
          <xsl:text>[</xsl:text>
          <xsl:value-of select="counter:read('index')"/>
          <xsl:text>]. </xsl:text>
          <xsl:value-of select="@last"/>
          <xsl:text>, </xsl:text>
          <xsl:value-of select="@first"/>
          </p>
          <counter:incr name="index"/>
        </xsl:for-each>
      </HTML>
    </xsl:template>
   
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/samples/Extensions/IntDate.java
  
  Index: IntDate.java
  ===================================================================
  
  import java.util.Date;
  import java.util.Calendar;
  
  public class IntDate
  {
    public static Date getDate(String year, String month, String day)
      {
        // Date(int, int, int) has been deprecated, so use Calendar to
        // set the year, month, and day.
        Calendar c = Calendar.getInstance();
        // Convert each argument to int.
        
c.set(Integer.parseInt(year),Integer.parseInt(month),Integer.parseInt(day));
        return c.getTime();
      }
  }
  
  
  
  
  1.1                  xml-xalan/samples/Extensions/MyCounter.java
  
  Index: MyCounter.java
  ===================================================================
  import java.util.*;
  
  public class MyCounter {
    Hashtable counters = new Hashtable ();
  
    public MyCounter () 
    {}
  
    public void init(org.apache.xalan.xslt.XSLProcessorContext context, 
                     org.apache.xalan.xslt.ElemExtensionCall extElem) 
    {
      String name = extElem.getAttribute("name");
      String value = extElem.getAttribute("value");
      int val;
      try 
      {
        val = Integer.parseInt (value);
      } 
      catch (NumberFormatException e) 
      {
        e.printStackTrace ();
        val = 0;
      }
      counters.put (name, new Integer (val));
    }
  
    public int read(String name) 
    {
      Integer cval = (Integer) counters.get (name);
      return (cval == null) ? 0 : cval.intValue ();
    }
  
    public void incr(org.apache.xalan.xslt.XSLProcessorContext context, 
                     org.apache.xalan.xslt.ElemExtensionCall extElem) {
      String name = extElem.getAttribute("name");
      Integer cval = (Integer) counters.get(name);
      int nval = (cval == null) ? 0 : (cval.intValue () + 1);
      counters.put (name, new Integer (nval));
    }
  }
  
  
  
  1.1                  xml-xalan/samples/Extensions/readme.html
  
  Index: readme.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
  <head>
        <title>Xalan Samples</title>
  </head>
  <body>
  <h2>Xalan Samples</h2>
  <p>For information about the samples (what they illustrate and how to run 
them), see <a href="../../docs/samples.html">Samples</a>.</p>
  
  
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/samples/Pipe/Pipe.java
  
  Index: Pipe.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, Lotus
   * Development Corporation., http://www.lotus.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.xalan.xslt.XSLTProcessor;
  import org.apache.xalan.xslt.XSLTInputSource;
  import org.apache.xalan.xslt.XSLTResultTarget;
  import org.apache.xalan.xslt.XSLTProcessorFactory;
  import org.apache.xalan.xslt.StylesheetRoot;
  
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  
  /**
   * Simple sample code to show how to pipe one transform
   * into another processor.
   */
  public class Pipe
  {
        public static void main(String[] args)
      throws java.io.IOException,
             java.net.MalformedURLException,
             org.xml.sax.SAXException
        {
      // Use the XSLTProcessorFactory to create a processor.
      XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
  
      // Compile the two stylesheets.
      StylesheetRoot stylesheet = processor.processStylesheet("foo.xsl");
      StylesheetRoot stylesheet2 = processor.processStylesheet("foo2.xsl");
  
      // Don't really need to set the processor Stylesheet property, since it's
      // still set from the 2nd processStylesheet, but it's good form....
      processor.setStylesheet(stylesheet2);
  
      // Get and set a DocumentHandler for final output.
      processor.setDocumentHandler(stylesheet2.getSAXSerializer(System.out));
  
      // Use the processor (which extends DocumentHandler) to instantiate the
      // XSLTResultTarget object for the first transform.
      XSLTResultTarget firstResult = new XSLTResultTarget(processor);
      // firstResult now functions as a SAX DocumentHandler.
  
      // The first transform (uses foo.xsl to transform foo.xml) produces a 
sequence of SAX
      // events (firstResult) that are in turn processed by the processor 
DocumentHandler
      // (using foo2.xsl), sending the ouput of the second transform to 
System.out.
      stylesheet.process(new XSLTInputSource("foo.xml"),
                         firstResult);
        }
  }
  
  
  
  1.1                  xml-xalan/samples/Pipe/foo.xml
  
  Index: foo.xml
  ===================================================================
  <?xml version="1.0"?>
  <doc>Hello</doc>
  
  
  1.1                  xml-xalan/samples/Pipe/foo.xsl
  
  Index: foo.xsl
  ===================================================================
  <?xml version="1.0"?> 
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:template match="doc">
      <out><xsl:value-of select="."/></out>
    </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/samples/Pipe/foo2.xsl
  
  Index: foo2.xsl
  ===================================================================
  <?xml version="1.0"?> 
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:template match="out">
      <out><xsl:value-of select="."/> ...and goodby!</out>
    </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/samples/Pipe/readme.html
  
  Index: readme.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
  <head>
        <title>Xalan Samples</title>
  </head>
  <body>
  <h2>Xalan Samples</h2>
  <p>For information about the samples (what they illustrate and how to run 
them), see <a href="../../docs/samples.html">Samples</a>.</p>
  
  
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/samples/Servlet/ApplyXSL.java
  
  Index: ApplyXSL.java
  ===================================================================
  
/*****************************************************************************************************
   * $Id: ApplyXSL.java,v 1.1 2000/02/12 00:00:12 dleslie Exp $
   *
   * Copyright (c) 1998-1999 Lotus Corporation, Inc. All Rights Reserved.
   *                            This software is provided without a warranty of 
any kind.
   *
   * $State: Exp $
   
*****************************************************************************************************/
  
  import java.io.*;
  import java.util.Properties;
  import java.util.StringTokenizer;
  import java.util.Enumeration;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  import org.apache.xalan.xslt.Constants;
  import org.apache.xalan.xslt.StylesheetRoot;
  import org.apache.xalan.xslt.XSLTProcessor;
  import org.apache.xalan.xslt.XSLTInputSource;
  import org.apache.xalan.xslt.XSLTResultTarget;
  import org.apache.xalan.xpath.XObject;
  import org.apache.xalan.xpath.XString;
  import org.apache.xalan.xpath.xml.XMLParserLiaison;
  
  
/*****************************************************************************************************
   *
   * ApplyXSL is an abstract class that can be extended to supply the basic
   * functions for transforming XML data using XSL stylesheets.
   *
   * @author Spencer Shepard ([EMAIL PROTECTED])
   * @author R. Adam King ([EMAIL PROTECTED])
   * @author Tom Rowe ([EMAIL PROTECTED])
   *
   
*****************************************************************************************************/
  
  public abstract class ApplyXSL extends HttpServlet
  {
  
    /**
     * Operational parameters for this class.
     * <p>Request-time values override init-time values which override class 
defaults.</p>
     * @see #init
     * @serial
     */
    protected ApplyXSLProperties ourDefaultParameters = null;
  
    /**
     * String representing the end of line characters for the System.
     */
    public final static String EOL = System.getProperty("line.separator");
  
    /**
     * String representing the file separator characters for the System.
     */
    public final static String FS = System.getProperty("file.separator");
  
     /**
     * String representing the current directory for properties files. See 
init().
     */
    public final static String ROOT = System.getProperty("server.root");
    public static String CURRENTDIR;
  
    /**
     * Initialize operational parameters from the configuration.
     * @param config Configuration
     * @exception ServletException Never thrown
     */
    public void init(ServletConfig config)
      throws ServletException
    {
      super.init(config);
      // If the server.root property --see above-- is null, use current working 
directory
      // as default location for media.properties.
      if (ROOT != null)
        CURRENTDIR= ROOT + FS + "servlets" + FS;
      else
        CURRENTDIR = System.getProperty("user.dir")+ FS;
      setDefaultParameters(config);
    }
  
    /**
     * Sets the default parameters for the servlet from the configuration.
     * @param config Configuration
     */
    protected void setDefaultParameters(ServletConfig config)
    {
      ourDefaultParameters = new ApplyXSLProperties(config);
    }
  
    /**
     * Implementers of this abstract method must return an XML XSLTInputSource 
DOM.
     * @param request  May contain or point to the XML XSLTInputSource
     * @param listener To record detailed parsing messages for possible return 
to requestor
     * @return XML XSLTInputSource DOM, or null if no XML XSLTInputSource can 
be created, found, or parsed
     * @see #process
     * @exception ApplyXSLException Thrown if exception occurs while handling 
request
     */
    protected abstract XSLTInputSource getDocument(XSLTProcessor processor,
                                                   HttpServletRequest request,
                                                   ApplyXSLListener listener)
      throws ApplyXSLException;
  
    /**
     * Implementers of this abstract method must return an XSL XSLTInputSource.
     * @param request May point to the XSLTInputSource
     * @param xmlSource  XML XSLTInputSource to be transformed
     * @param listener To record detailed parsing messages for possible return 
to requestor
     * @return XSL XSLTInputSource, or null if no stylesheet can be created, 
found, or parsed
     * @see #process
     * @exception ApplyXSLException Thrown if exception occurs while handling 
request
     */
    protected abstract XSLTInputSource getStylesheet(HttpServletRequest request,
                                                     XSLTInputSource xmlSource,
                                                     ApplyXSLListener listener)
      throws ApplyXSLException;
  
    /**
     * Returns the response content type specified by the media-type and 
encoding attributes of
     * the &lt;xsl:output> element(s) of the stylesheet.
     * @param xslSourceRoot XSL Stylesheet to be examined for &lt;xsl:output> 
elements.
     * @return The response content type (MIME type and charset) of the 
stylesheet output
     * @see #process
     */
    public String getContentType(StylesheetRoot xslSourceRoot)
    {
      String encoding = xslSourceRoot.getOutputEncoding(), media = 
xslSourceRoot.getOutputMediaType();
      if (encoding != null)
        return media + "; charset=" + encoding;
      return media;
    }
  
    /**
     * Defines and sets select top-level XSL stylesheet variables from the HTTP 
request, which
     * can be evaluated using &lt;xsl:param-variable&gt;.  The following 
variables will be
     * automatically set:
     * <dl>
     * <dt><i>ParameterName</i></dt>
     * <dd>Each non-reserved request parameter returned from 
request.getParameterNames().  If a
     *     parameter contains more than a single value, only the first value is 
available.</dd>
     * <dt>servlet-RemoteAddr</dt>
     * <dd>Contains String output from request.getRemoteAddr(), which is the IP 
address
     *     of the client machine.</dd>
     * <dt>servlet-RemoteHost</dt>
     * <dd>Contains String output from request.getRemoteHost(), which is the 
host name
     *     of the client machine.</dd>
     * <dt>servlet-RemoteUser</dt>
     * <dd>Contains String output from request.getRemoteUser(), which was the 
user name
     *     accepted by the server to grant access to this servlet.</dd>
     * <dt>servlet-Request</dt>
     * <dd>Contains the request object.</dd>
     * </dl>
     * @param xslprocessor Where to register parameters to be set
     * @param request Provides access to all meaningful parameters to set
     * @see #process
     */
    public void setStylesheetParams(XSLTProcessor xslprocessor, 
HttpServletRequest request)
    {
      XMLParserLiaison liaison = xslprocessor.getXMLProcessorLiaison();
      try
      {
        xslprocessor.setStylesheetParam("servlet-request",
                                        new XObject(request)); // Update ctor 
-sc
      }
      catch (Exception e)
      {
        return;
      } // Bail out if we can't do this simple set
      Enumeration paramNames = request.getParameterNames();
      while (paramNames.hasMoreElements())
      {
        String paramName = (String) paramNames.nextElement();
        try
        {
          /*
          @@scott -- it's better to pass these in than not... they won't
          @@do any harm.
          if (paramName.equals("URL")                 ||
          paramName.equals("xslURL")              ||
          paramName.equals("debug")               ||
          paramName.equals("noConflictWarnings")  ||
          paramName.equals("catalog"))
          {
          // Reserved parameter names for this servlet
          }
          else
          */
          {
            String[] paramVals = request.getParameterValues(paramName);
            if (paramVals != null)
            {
              xslprocessor.setStylesheetParam(paramName,
                                              new XString(paramVals[0])); // 
Update ctor -sc
            }
          }
        }
        catch (Exception e)
        {
        }
      }
      try
      {
        xslprocessor.setStylesheetParam("servlet-RemoteAddr",
                                        new XString(request.getRemoteAddr())); 
// Update ctor -sc
      }
      catch (Exception e)
      {
      }
      try
      {
        xslprocessor.setStylesheetParam("servlet-RemoteHost",
                                        new XString(request.getRemoteHost())); 
// Update ctor -sc
      }
      catch (Exception e)
      {
      }
      try
      {
        xslprocessor.setStylesheetParam("servlet-RemoteUser",
                                        new XString(request.getRemoteUser())); 
// Update ctor -sc
      }
      catch (Exception e)
      {
      }
    }
  
    // doPost removed for security reasons due to the possibility of sending
    // unsecure XML and XSL XSLTInputSources through the request input stream
  
    /**
     * HTTP Get method passed on to process.
     * @param request The request
     * @param response The response
     * @see #process
     * @exception ServletException Never thrown
     * @exception IOException Never thrown
     */
    public void doGet (HttpServletRequest request,
                       HttpServletResponse response)
      throws ServletException, IOException
    {
      try
      {
        XSLTProcessor processor = 
org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor();
        process(processor, request, response);
      }
      catch (Exception e)
      {
      }
    }
  
    /**
     * Coordinates applying an XSL stylesheet to XML data using operational 
parameters.
     * <p>If successfully applied, the result tree will be streamed to the 
response object
     * and the content type set according to the XSL stylesheet's 
&lt;xsl:output> element(s).</p>
     * <p>If there is a problem in parsing the XML/XSL or if there is a problem 
in applying
     * the XSL to the XML, an exception will be streamed to the response 
object.  The detail
     * of the information returned in the response object will depend on 
whether we're
     * running in debug mode or not.</p>
     * @param request  May contain information relevant to creating XML and XSL 
XSLTInputSource's
     * @param response Where to write the transformation result
     * @see #getDocument
     * @see #getStylesheet
     * @see #getContentType
     * @see #displayException
     * @see #setStylesheetParams
     * @exception ServletException Never thrown
     * @exception IOException Never thrown
     */
    public void process(XSLTProcessor processor, HttpServletRequest request,
                        HttpServletResponse response)
      throws ServletException, IOException
    {
      boolean debug = ourDefaultParameters.isDebug(request);
  
      long time = 0;
      if (debug)
        time = System.currentTimeMillis();
  
      // Listener to be used for all reporting
      ApplyXSLListener listener = new ApplyXSLListener();
  
      XSLTInputSource xmlSource = null, xslSource = null;
      // creating XML XSLTInputSource
      try
      {
        if ((xmlSource = getDocument(processor, request, listener)) == null)
          throw new ApplyXSLException("getDocument() returned null",
            new NullPointerException(),
            response.SC_NOT_FOUND);
      }
      catch (ApplyXSLException axe)
      {
        axe.appendMessage(EOL + "getDocument() resulted in ApplyXSLException" + 
EOL
                          + listener.getMessage());
        if (debug) writeLog(axe);
        displayException(response, axe, debug);
        xmlSource = null;
      }
      // creating XSL Stylesheet
      if (xmlSource != null)
      {
        try
        {
          if ((xslSource = getStylesheet(request, xmlSource, listener)) == null)
            throw new ApplyXSLException("getStylesheet() returned null",
              new NullPointerException(),
              response.SC_NOT_FOUND);
        }
        catch (ApplyXSLException axe)
        {
          axe.appendMessage(EOL + "getStylesheet() resulted in 
ApplyXSLException" + EOL
                            + listener.getMessage());
          if (debug) writeLog(axe);
          displayException(response, axe, debug);
          xslSource = null;
        }
      }
      // perform Transformation
      if ((xmlSource != null) && (xslSource != null))
      {
          try
          { // new try ... catch around ctor Update -sc
          XSLTProcessor xslprocessor = 
org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor();
          {
            try
            {
              String contentType = null;
              if ((contentType = 
getContentType(xslprocessor.processStylesheet(xslSource))) != null)
                response.setContentType(contentType);
              
xslprocessor.setQuietConflictWarnings(ourDefaultParameters.isNoCW(request));
              xslprocessor.setProblemListener(listener);
              if (debug)
              {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                XSLTResultTarget outBuffer = new XSLTResultTarget(baos);
                setStylesheetParams(xslprocessor, request);
                xslprocessor.process(xmlSource, xslSource, outBuffer);
                baos.writeTo(response.getOutputStream());
                writeLog(listener.getMessage(), response.SC_OK);
              }
              else
              {
                setStylesheetParams(xslprocessor, request);
                xslprocessor.process(xmlSource, xslSource,
                                     new 
XSLTResultTarget(response.getWriter()));
              }
            }
            catch (Exception exc)
            {
              ApplyXSLException axe = new ApplyXSLException("Exception occurred 
during Transformation:"
                                                            + EOL + 
listener.getMessage() + EOL
                                                            + exc.getMessage(), 
exc,
                                                                                
response.SC_INTERNAL_SERVER_ERROR);
              if (debug) writeLog(axe);
              displayException(response, axe, debug);
            }
            finally
            {
              xslprocessor.reset();
            } // end of try ... catch ... finally
          } // end of blank block
          }
        catch (org.xml.sax.SAXException saxExc)
        {
          ApplyXSLException axe = new ApplyXSLException("Exception occurred 
during ctor/Transformation:"
                                                        + EOL + 
listener.getMessage() + EOL
                                                        + saxExc.getMessage(), 
saxExc,
                                                                            
response.SC_INTERNAL_SERVER_ERROR);
          if (debug) writeLog(axe);
          displayException(response, axe, debug);
        } // end of new try ... catch around ctor Update -sc
      } // end of if((xmlSource != null) ...
      if (debug)
      {
        time = System.currentTimeMillis() - time;
        writeLog("  No Conflict Warnings = " + 
ourDefaultParameters.isNoCW(request) +
                 "  Transformation time: " + time + " ms", response.SC_OK);
      }
    }
  
    /**
     * Writes the following information to the servlet log:
     * <ol>
     * <li>HTTP status code</li>
     * <li>Message</li>
     * <li>Stack trace</li>
     * </ol>
     * @param axe Contains valid HTTP status code, message, and stack trace 
(optional)
     */
    protected void writeLog(ApplyXSLException axe)
    {
      writeLog(axe.getMessage(), axe.getStatusCode(), axe.getException());
    }
  
    /**
     * Writes the following information to the servlet log:
     * <ol>
     * <li>HTTP status code</li>
     * <li>Message</li>
     * <li>Stack trace</li>
     * </ol>
     * @param msg Message to be logged
     * @param statusCode Valid status code from 
javax.servlet.http.HttpServletResponse
     * @param t Used to generate stack trace (may be =null to suppress stack 
trace)
     */
    protected void writeLog(String msg, int statusCode, Throwable t)
    {
      if (t == null)
        writeLog(msg, statusCode);
      else
      {
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        PrintWriter writer = new PrintWriter(bytes, true);
        System.out.println("Exception is " + t.getClass().getName());
        t.printStackTrace(writer);
        log("HTTP Status Code: " + statusCode + " - " + msg + EOL + 
bytes.toString());
      }
    }
  
    /**
     * Writes the following information to the servlet log:
     * <ol>
     * <li>HTTP status code</li>
     * <li>Message</li>
     * </ol>
     * @param msg Message to be logged
     * @param statusCode Valid status code from 
javax.servlet.http.HttpServletResponse
     */
    protected void writeLog(String msg, int statusCode)
    {
      log("HTTP Status Code: " + statusCode + " - " + msg);
    }
  
    /**
     * Invokes response.sendError setting an HTTP status code and optionally an 
error message
     * as an HTML page.
     * <p>If running in debug mode, also try to return a stack trace of the 
exception and
     * and xml/xsl processor messages.</p>
     * @param response Where to stream the exception to
     * @param xse The wrapper which contains the exception and its HTTP status 
code
     * @param debug Indicates whether to include stack trace, etc.
     */
    protected void displayException(HttpServletResponse response, 
ApplyXSLException xse, boolean debug)
    {
      String mesg = xse.getMessage();
      if (mesg == null)
        mesg = "";
      else mesg = "<B>" + mesg + "</B>";
      StringTokenizer tokens = new StringTokenizer(mesg, EOL);
      StringBuffer strBuf = new StringBuffer();
      while (tokens.hasMoreTokens())
        strBuf.append(tokens.nextToken() + EOL + "<BR>");
      mesg = strBuf.toString();
      if (debug)
      {
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        PrintWriter writer = new PrintWriter(bytes, true);
        xse.getException().printStackTrace(writer);
        mesg += " <PRE> " + bytes.toString() + " </PRE> ";
      }
      response.setContentType("text/html");
      try
      {
        response.sendError(xse.getStatusCode(), mesg);
      }
      catch (IOException ioe)
      {
        System.err.println("IOException is occurring when sendError is called");
      }
    }
  }
  
  
  1.1                  xml-xalan/samples/Servlet/ApplyXSLException.java
  
  Index: ApplyXSLException.java
  ===================================================================
  
/*****************************************************************************************************
   * $Id: ApplyXSLException.java,v 1.1 2000/02/12 00:00:12 dleslie Exp $
   * 
   * Copyright (c) 1998-1999 Lotus Corporation, Inc. All Rights Reserved.
   *                            This software is provided without a warranty of 
any kind.
   * 
   * $State: Exp $
   
*****************************************************************************************************/
   
  
/*****************************************************************************************************
   *
   * Wrapper for exceptions occurring during apply XSL processing.  
   * Allows for exceptions to be returned with an associated HTTP Status Code.
   *
   * @author Spencer Shepard ([EMAIL PROTECTED])
   * @author R. Adam King ([EMAIL PROTECTED])
   * @author Tom Rowe ([EMAIL PROTECTED])
   *
   
*****************************************************************************************************/
  
  public class ApplyXSLException extends Exception {
  
      /**
        * Exception Message.
        * @serial
        */ 
      private String myMessage = "";
  
      /**
        * HTTP Status Code. Default= internal server error.
        * @serial
        */
      private int  myHttpStatusCode = 
javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; 
  
      /**
        * Wrapped exception
        * @serial
        */
      private Exception myException = null;
  
      /**
        * Constructor for exception with no additional detail.
        */
      public ApplyXSLException() 
      { 
          super(); 
      }
  
      /**
        * Constructor for exception with message.
        * @param s Exception message
        */
      public ApplyXSLException(String s) 
      { 
          super(); 
        myMessage = s;
      }
  
      /**
        * Constructor for exception with HTTP status code.
        * @param hsc Valid status code from 
javax.servlet.http.HttpServletResponse
        */
      public ApplyXSLException(int hsc) 
      {
        super();
        myHttpStatusCode = hsc;
      }
  
      /**
        * Constructor for exception with message and HTTP status code.
        * @param s Exception message
        * @param hsc Valid status code from 
javax.servlet.http.HttpServletResponse
        */
      public ApplyXSLException(String s, int hsc)
      {
        super();
        myHttpStatusCode = hsc;
      }
  
      /**
        * Constructor for exception.
        * @param e Exception to be wrapped.
        */
      public ApplyXSLException(Exception e)
      {
        super();
        myMessage = e.getMessage();
        myException = e;
      }
  
      /**
        * Constructor for passed exception with message.
        * @param s Exception message
        * @param e Exception to be wrapped.
        */
      public ApplyXSLException (String s, Exception e)
      {
        super();
        myMessage = s;
        myException = e;
      }
  
      /**
        * Constructor for passed exception with HTTP status code.
        * @param e Exception to be wrapped.
        * @param hsc Valid status code from 
javax.servlet.http.HttpServletResponse
        */
      public ApplyXSLException(Exception e, int hsc)
      {
        super();
        myMessage = e.getMessage();
        myException = e;
        myHttpStatusCode = hsc;
      }
  
      /**
        * Constructor for passed exception with HTTP status code and message.
        * @param s Exception message
        * @param e Exception to be wrapped.
        * @param hsc Valid status code from 
javax.servlet.http.HttpServletResponse
        */
      public ApplyXSLException(String s, Exception e, int hsc)
      {
        super();
        myMessage = s;
        myException = e;
        myHttpStatusCode = hsc;
      }
  
      /**
        * Returns exception message.
        * @return exception message
        */
      public String getMessage()
      {
        return myMessage;
      }
  
      /**
        * Appends string to exception message.
        * @param s String to be added to message
        */
      public void appendMessage(String s)
      {
        myMessage += s;
      }
  
      /**
        * Returns the wrapped exception.
        * @return Wrapped exception
        */
      public Exception getException()
      {
        return myException;
      }
  
      /**
        * Returns the HTTP status code associated with the exception.
        * @return Valid status code from javax.servlet.http.HttpServletResponse
        */
      public int getStatusCode()
      {
        return myHttpStatusCode;
      }
  }
  
  
  
  
  1.1                  xml-xalan/samples/Servlet/ApplyXSLListener.java
  
  Index: ApplyXSLListener.java
  ===================================================================
  
/*****************************************************************************************************
   * $Id: ApplyXSLListener.java,v 1.1 2000/02/12 00:00:13 dleslie Exp $
   * 
   * Copyright (c) 1998-1999 Lotus Corporation, Inc. All Rights Reserved.
   *                            This software is provided without a warranty of 
any kind.
   * 
   * $State: Exp $
   
*****************************************************************************************************/
  
  import java.io.*;
  import org.xml.sax.*;
  import org.apache.xalan.xpath.xml.ProblemListenerDefault.*;
  
  
/*****************************************************************************************************
   * ApplyXSLListener provides a buffered listener essential for capturing, and 
then subsequently
   * reporting, XML and XSL processor messages which may be of use in debugging 
XML+XSL processed at
   * the server.
   *
   * @author Spencer Shepard ([EMAIL PROTECTED])
   * @author R. Adam King ([EMAIL PROTECTED])
   * @author Tom Rowe ([EMAIL PROTECTED])
   *
   
*****************************************************************************************************/
  
  public class ApplyXSLListener extends 
org.apache.xalan.xpath.xml.ProblemListenerDefault implements ErrorHandler 
  {
  
      /**
        * Output stream
        */
      private ByteArrayOutputStream outStream = new ByteArrayOutputStream();
  
      /**
        * Buffered output stream
        */
      public PrintWriter out = null;
  
      /**
        * Constructor.
        */
      public ApplyXSLListener()
      {
        out = new PrintWriter(new BufferedOutputStream(outStream), true);
      }
  
      /**
        * Receive notification of a warning.
        *
        * @param spe The warning information encapsulated in a SAX parse 
exception.
        */
      public void warning(SAXParseException spe)
      {
        out.println("Parser " + warningHeader + spe.getMessage());
      }
  
      /**
        * Receive notification of a recoverable error.
        *
        * @param spe The error information encapsulated in a SAX parse 
exception.
        */
      public void error(SAXParseException spe)
      {
        out.println("Parser " + errorHeader + spe.getMessage());
      }
  
      /**
        * Receive notification of a non-recoverable error.
        *
        * @param spe The error information encapsulated in a SAX parse 
exception.
        * @exception SAXException Always thrown  
        */
      public void fatalError(SAXParseException spe)
      throws SAXException
      {
        out.println("Parser Fatal " + errorHeader + spe.getMessage());
        throw spe;
      }
  
      /**
        * Returns the buffered processing message(s).
        * @return Buffered processing message(s)
        */
      public String getMessage()
      {
        return outStream.toString();
      }
  }
  
  
  
  
  1.1                  xml-xalan/samples/Servlet/ApplyXSLProperties.java
  
  Index: ApplyXSLProperties.java
  ===================================================================
  
/*****************************************************************************************************
   * $Id: ApplyXSLProperties.java,v 1.1 2000/02/12 00:00:13 dleslie Exp $
   * 
   * Copyright (c) 1998-1999 Lotus Corporation, Inc. All Rights Reserved.
   *                            This software is provided without a warranty of 
any kind.
   * 
   * $State: Exp $
   
*****************************************************************************************************/
  
  import java.net.MalformedURLException;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  
/*****************************************************************************************************
   * 
   * ApplyXSLProperties contains operational parameters for ApplyXSL based 
   * on program defaults and configuration.  
   * <p>This class is also used to return values for request-time 
parameters.</p>
   *
   * @author Spencer Shepard ([EMAIL PROTECTED])
   * @author R. Adam King ([EMAIL PROTECTED])
   * @author Tom Rowe ([EMAIL PROTECTED])
   *
   
*****************************************************************************************************/
  
  public class ApplyXSLProperties {
  
      /**
        * Program default for parameter "URL"
        */
      private final String DEFAULT_URL;
  
      /**
        * Program default for parameter "xslURL"
        */
      private final String DEFAULT_xslURL;
      
      /**
        * Program default for parameter "debug"
        */
      private final boolean DEFAULT_debug;
  
      /**
        * Program default for parameter "noConflictWarnings"
        */
      private final boolean DEFAULT_noCW;
      
      /**
        * Constructor to use program defaults.
        */
      public ApplyXSLProperties() 
      {
        DEFAULT_URL = null;
        DEFAULT_xslURL = null;
        DEFAULT_debug = false;
        DEFAULT_noCW = false;
      }
  
      /**
        * Constructor to use to override program defaults.
        * @param config Servlet configuration
        */
      public ApplyXSLProperties(ServletConfig config)
      {
        String xm = config.getInitParameter("URL"),
               xu = config.getInitParameter("xslURL"),
               db = config.getInitParameter("debug"),
               cw = config.getInitParameter("noConflictWarnings");
               
        if (xm != null) DEFAULT_URL = xm;
        else DEFAULT_URL = null;
        if (xu != null) DEFAULT_xslURL = xu;
        else DEFAULT_xslURL = null;
        if (db != null) DEFAULT_debug = new Boolean(db).booleanValue();
        else DEFAULT_debug = false;
        if (cw != null) DEFAULT_noCW = new Boolean(cw).booleanValue();
        else DEFAULT_noCW = false;
      }
     
      /**
        * Given a parameter name, returns the HTTP request's String value; 
        * if not present in request, returns default String value.
        * @param request Request to check for default override
        * @param param Name of the parameter
        * @return String value of named parameter
        */
      public String getRequestParmString(HttpServletRequest request, String 
param)
      {
        if (request != null) { 
            String[] paramVals = request.getParameterValues(param); 
            if (paramVals != null) 
                return paramVals[0];
        }
        return null;
      }
  
      /**
        * Returns the current setting for "URL".
        * @param request Request to check for parameter value
        * @return String value for "URL"
        * @exception MalformedURLException Will not be thrown
        */
      public String getXMLurl(HttpServletRequest request)
      throws MalformedURLException
      {
        String temp = getRequestParmString(request, "URL");
        if (temp != null)
            return temp;
        return DEFAULT_URL;
      }     
      
      /**
        * Returns the current setting for "xslURL".
        * @param request Request to check for parameter value
        * @return String value for "xslURL"
        * @exception MalformedURLException Will not be thrown
        */
      public String getXSLurl(HttpServletRequest request)
      throws MalformedURLException
      {  
        String temp = getRequestParmString(request, "xslURL");
        if (temp != null)
            return temp;
        return DEFAULT_xslURL;
      }
      
      /**
        * Returns the current setting for "debug".
        * @param request Request to check for parameter value
        * @return Boolean value for "debug"
        */
      public boolean isDebug(HttpServletRequest request)
      {
        String temp = getRequestParmString(request, "debug");
        if (temp != null)
            return new Boolean(temp).booleanValue();
        return DEFAULT_debug;
      }
  
      /**
        * Returns the current setting for "noConflictWarnings".
        * @param request Request to check for parameter value
        * @return Boolean value for "noConflictWarnings"
        */
      boolean isNoCW(HttpServletRequest request)
      {
        String temp = getRequestParmString(request, "noConflictWarnings");
        if (temp != null)
            return new Boolean(temp).booleanValue();
        return DEFAULT_noCW;
      }    
  }
  
  
  1.1                  xml-xalan/samples/Servlet/DefaultApplyXSL.java
  
  Index: DefaultApplyXSL.java
  ===================================================================
  
/*****************************************************************************************************
   * $Id: DefaultApplyXSL.java,v 1.1 2000/02/12 00:00:13 dleslie Exp $
   *
   * Copyright (c) 1998-1999 Lotus Corporation, Inc. All Rights Reserved.
   *                            This software is provided without a warranty of 
any kind.
   *
   * $State: Exp $
   
*****************************************************************************************************/
  
  import org.w3c.dom.*;
  import org.xml.sax.*;
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  import org.apache.xerces.parsers.DOMParser;
  // import org.apache.xerces.framework.Catalog;
  // import com.ibm.xml.internal.XCatalog;
  
  import org.apache.xalan.xslt.XSLTInputSource;
  
  
/*****************************************************************************************************
   * DefaultApplyXSL extends the ApplyXSL abstract class.  It's primary 
function is to provide a
   * baseline servlet to let you apply XSL stylesheets to XML data at the 
server.  Why do you
   * want to apply XSL stylesheets to XML data at the server?  Because you can 
maximize the sharability
   * of your data without regard to the XML/XSL processing capabilities of your 
clients.
   *
   * <p>Attempts will be made to create an XML XSLTInputSource DOM from the 
following sources:</p>
   * <ol>
   * <li>A relative URL specified in the HTTP request's path information. This 
capability is intended
   * for use by <b>servlet engines that map</b> some or all XML data to be 
processed at the server.</li>
   * <li>A URL specified in the HTTP request's <code>URL=</code> parameter.  
This capability
   * is intended for <b>clients wishing to selectively process</b> XML data at 
the server.  For
   * security reasons, this URL will be forced to the local IP host.</li>
   * <li>The HTTP request's XML input stream. This capability is intended for 
use by chained servlets.</li>
   * </ol>
   *
   * <p>Attempts will be made to create an XSL XSLTInputSource from the 
following sources:</p>
   * <ol>
   * <li>A URL specified in the HTTP request's <code>xslURL=</code> parameter.  
This capability
   * is intended for clients wishing to selectively override the server 
algorithm for applying XSL
   * stylesheets.  For security reasons, this URL will be forced to the local 
IP host.</li>
   * <li>XML association.  XML XSLTInputSources may contain references to one 
or more stylesheets using
   * <a HREF="http://www.w3.org/TR/1999/PR-xml-stylesheet-19990114";>this</a> 
W3C proposed recommendation.
   * If the XML XSLTInputSource does contain such references, a best match will 
be chosen based on the browser
   * type making the request and the default association.  This capability 
enables relationships to be
   * defined between client capabilities and stylesheets capable of acting on 
these capabilities.</li>
   * <li>A <a NAME="globalxsl">configured default stylesheet URL</a></li>
   * </ol>
   *
   * <hr>
   *
   * <p >This servlet <a NAME="prereqs">requires</a> the following software:</p>
   * <ul>
   * <li>A servlet engine which implements a 2.x-level servlet API, such as
   * <a HREF="http://www.software.ibm.com/webservers/appserv/";>IBM WebSphere 
Application Server</a>
   * or <a HREF="http://www.lotus.com/home.nsf/welcome/domino";>Lotus Domino 
R5</a>.</li>
   * <li>Version 2.x of <a 
HREF="http://www.alphaworks.ibm.com/formula/xml";>IBM's XML for Java</a>.
   * LotusXSL will run with either a 1.x- or 2.x-level XML4J, but this servlet 
requires XML4J 2.x.
   * XML4J is already embedded in the IBM and Lotus software listed above.</li>
   * </ul>
   *
   * <hr>
   *
   * <p>If you are running WebSphere Application Server v2.03 or later, this 
servlet is already
   * installed and default configured.  Otherwise, <a 
NAME="install">install</a> this servlet by:</p>
   * <ol>
   * <li>Ensure that your servlet engine meets the <a HREF="#prereqs">system 
requirements</a>.</li>
   * <li>Install the xml4j.jar and lotusxsl.jar files in your servlet engine's 
class path.  Unfortunately,
   * the servlet specification does not yet define a standard way to install 
servlets.  Please refer to
   * your servlet engine's operational instructions; for IBM WebSphere 
Application Server, the instructions
   * are <a 
HREF="http://www.software.ibm.com/webservers/appserv/library.html";>here</a>.</li>
   * <li><a NAME="#configprops">Copy</a> the 
lotusxsl/examples/servlet/media.properties file
   * to a servlet-accessible location in your directory tree.  This file 
provides configuration
   * information to this servlet.</li>
   * <li>Copy the lotusxsl/examples/servlet/*.xsl files to a servlet-accessible 
location in your
   * directory tree.  These files provide default XSL stylesheets to be used 
when no others are
   * available.  Default.xsl provides a Microsoft IE5-like default display 
using JavaScript to expand
   * and contract nodes; default2.xsl provides a similar display without the 
use of JavaScript.</li>
   * <li>Configure this servlet to your servlet engine.  Once again, the 
servlet specification defines
   * no standard servlet configuration procedure, so you must consult the 
operational instructions for
   * your servlet engine.
   * <table ID="config1" BORDER="1" CELLPADDING="2" CELLSPACING="0">
   * <tr>
   *    <td COLSPAN="5" BGCOLOR="#000000"><font COLOR="#ffffff">
   *    <b>Default Apply XSL Servlet Base Configuration</b></font></td>
   * </tr>
   * <tr>
   *    <td><b>Parm Name</b></td>
   *    <td><b>Parm Value</b></td>
   *    <td><b>Required?</b></td>
   * </tr>
   * <tr>
   *    <td>Servlet Name</td>
   *    <td>DefaultApplyXSL</td>
   *    <td>Yes</td>
   * </tr>
   * <tr>
   *    <td>Description</td>
   *    <td>Apply XSL to XML</td>
   *    <td>No</td>
   * </tr>
   * <tr>
   *    <td>Servlet Class</td>
   *    <td>com.lotus.xsl.server.DefaultApplyXSL</td>
   *    <td>Yes</td>
   * </tr>
   * </table>
   * <br>
   * <table ID="config2" BORDER="1" CELLPADDING="2" CELLSPACING="0">
   * <tr>
   *    <td COLSPAN="5" BGCOLOR="#000000"><font COLOR="#ffffff">
   *    <b>Default Apply XSL Servlet Initialization Properties</b></font></td>
   * </tr>
   * <tr>
   *    <td><b>Description</b></td>
   *    <td><b>Parm Name</b></td>
   *    <td><b>Parm Value</b></td>
   *    <td><b>Required?</b></td>
   *    <td><b>Default Value</b></td>
   * </tr>
   * <tr>
   *    <td><a HREF="#configprops">Location</a> of user-Agent/media mapping 
rules file</td>
   *    <td>mediaURL</td>
   *    <td>a full URL, or path relative to the System's server.root /servlets 
directory</td>
   *    <td>No</td>
   *    <td>None</td>
   * </tr>
   * <tr>
   *    <td><a HREF="#globalxsl">XSL stylesheet URL</a></td>
   *    <td><b>xslURL</b></td>
   *    <td>http://<i>localhost/localpath/yourDefault.xsl</i></td>
   *    <td>No</td>
   *    <td>None</td>
   * </tr>
   * <tr>
   *    <td>Run in debug mode?</td>
   *    <td><b>debug</b></td>
   *    <td>true or false</td>
   *    <td>No</td>
   *    <td>false</td>
   * </tr>
   * <tr>
   *    <td>Generate warning messages from XSL processor</td>
   *    <td><b>noConflictWarnings</b></td>
   *    <td>true or false</td>
   *    <td>No</td>
   *    <td>false</td>
   * </tr>
   * <tr>
   *    <td><a HREF="#xcatalog">Catalog</a> for public identifiers</td>
   *    <td><b>catalog</b></td>
   *    <td>a full URL</td>
   *    <td>No</td>
   *    <td>none</td>
   * </table>
   * </li>
   * <li>If you wish to configure your servlet engine to automatically process 
some or all XML data
   * at the server, you should follow your servlet engine's operational 
instructions on how to
   * route these files to the default apply XSL servlet.  Usually, this entails 
defining a servlet
   * filter(s) or alias(es).</li>
   * <li>Restart your servlet engine.</li>
   * <li>Access an XML XSLTInputSource using one of the techniques outlined in 
the
   * <a HREF="#examples">examples</a></li>
   * </ol>
   *
   * <hr>
   *
   * <p>The following <a NAME="examples">examples</a> serve to illustrate the 
use of this servlet:</p>
   * <dl>
   * 
<dt>http://localhost/servlet/DefaultApplyXSL?URL=/data.xml&xslURL=/style.xsl</dt>
   * <dd>...will apply the style.xsl stylesheet to the data.xml data.  Both 
files will be
   * served from the Web server's HTTP XSLTInputSource root.</dd>
   * 
<dt>http://localhost/servlet/DefaultApplyXSL?URL=/data.xml&xslURL=/style.xsl&debug=true</dt>
   * <dd>...will ensure that XML and XSL processor messages will be returned in 
the event of problems
   * applying style.xsl to data.xml</dd>
   * 
<dt>http://localhost/servlet/DefaultApplyXSL/data.xml?xslURL=/style.xsl</dt>
   * <dd>...will apply 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.
   * <dt>http://localhost/servlet/DefaultApplyXSL/data.xml</dt>
   * <dd>...will examine data.xml for an <a 
HREF="http://www.w3.org/TR/1999/PR-xml-stylesheet-19990114";>associated</a>
   * XSL stylesheet.  If multiple XSLs are associated with the data, the 
stylesheet whose media
   * attribute <a HREF="#media">maps</a> to your browser type will be chosen.  
If no mapping is
   * successful, the primary associated stylesheet will be used.
   * <dt>http://localhost/servlet/data.xml</dt>
   * <dd>...will provide the exact 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
   * to map all or some *.xml files to this servlet through the use of servlet 
aliases or filters.
   * 
<dt>http://localhost/servlet/data.xml?catalog=http://www.xml.org/dtds/oag.xml</dt>
   * <dd>...will supplement any servlet-configured <a 
HREF="#xcatalog">XCatalog</a>
   * with a catalog of supply chain DTDs residing at the XML.ORG DTD repository.
   * </dl>
   *
   * <hr>
   *
   * <p>The following <a NAME="usage">usage notes</a> may 
prove...well...useful:</p>
   * <ul>
   * <li>All <b>bold</b> servlet initialization parameters listed in the
   * <a HREF="#config2">configuration table</a> may be overridden on any HTTP 
request.  For example,
   * when the servlet is initialized to not run in debug mode, this setting may 
be overridden on a
   * request by specifying a <code>debug=true</code> HTTP request parameter.
   * <p>All request-time parameters may be specified once with the exception of 
the "catalog"
   * paramater, which may be specified multiple times in order to load multiple
   * <a HREF="#xcatalog">XCatalogs</a>.</p></li>
   * <li>A number of HTTP request variables are automatically set as XSL 
stylesheet
   * top-level parameters.  A complete list of these variables is available
   * <a HREF="com.lotus.xsl.server.ApplyXSL.html#setStylesheetParams">here</a>
   * These parameters are directly accessible to your stylesheet by doing 
something like:
   * <pre>
   *     &lt;?xml version="1.0"?&gt;
   *     &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"&gt;
   *     &lt;xsl:param name="servlet-RemoteAddr" select="'defaultAddr'"/&gt;
   *     &nbsp;
   *     &lt;xsl:template match="documentElement"&gt;
   *       Client's address is &lt;xsl:value-of 
select="$servlet-RemoteAddr"/&gt;
   *     &lt;/xsl:template&gt;
   *     &nbsp;
   *     &lt;/xsl:stylesheet&gt;
   * </pre></li>
   * <li>For performance reasons, this servlet will not validate XML data or 
XSL stylesheet documents.</li>
   * <li>For security reasons, this servlet will only process HTTP/GET 
requests.</li>
   * <li>The <a NAME="media">media.properties</a> file provides mapping rules 
between a value contained
   * in the HTTP request's user-Agent field and a value to be scanned for in 
XSL stylesheet(s) associated
   * with the XML data. This mapping enables relationships to be defined 
between client capabilities and
   * stylesheets capable of acting on these capabilities.  For example, mapping 
rules of...
   * <pre>
   *     MSIE=explorer
   *     MSPIE=pocketexplorer
   * </pre>
   * ...and XML data that contains XSL stylesheet associations of...
   * <pre>
   *     &lt;?xml-stylesheet                 media="explorer"       
href="alldata.xsl"  type="text/xsl"?>
   *     &lt;?xml-stylesheet alternate="yes" media="pocketexplorer" 
href="somedata.xsl" type="text/xsl"?>
   * </pre>
   * ...and an HTTP request from Microsoft's Pocket Internet Explorer (that 
contains a user-Agent value
   * of <code>foo MSPIE bar</code>) will apply the XSL stylesheet somedata.xsl. 
 If you wish to define
   * additional browser types, or define relationships that exploit specific 
presentation capabilities
   * of browsers, simply define additional mapping rules in 
media.properties.</li>
   * <li><a NAME="xcatalog">XML Catalogs</a> are Web resources which contain 
mappings from public
   * identifiers to system identifiers. Public identifiers are often used to 
abstract embedded file
   * locations.  For example, an XML file that contains...
   * <pre>
   *     &lt;!ENTITY % CarPartNumbers PUBLIC "FordProbePartNumbers" 
"http://www.ford.com/parts/probe.ent";>
   *     %CarPartNumbers;
   * </pre>
   * ...is relying on a catalog to map "FordProbePartNumbers" to a meaningful 
local file.  Failing to map
   * to a local file will result in remote retrieval from 
http://www.ford.com/parts/probe.ent
   * <p>The underlying XML processor for this servlet (XML4J) supports multiple 
catalog formats.  However,
   * this servlet assumes <a 
HREF="http://www.ccil.org/~cowan/XML/XCatalog.html";>XCatalog</a> format.</li>
   * <li>Programmers wishing to dynamically construct XML or XSL data should 
consider subclassing
   * the getDocument or getStylesheet methods.</li>
   * </ul>
   *
   * @author Spencer Shepard ([EMAIL PROTECTED])
   * @author R. Adam King ([EMAIL PROTECTED])
   * @author Tom Rowe ([EMAIL PROTECTED])
   *
   
*****************************************************************************************************/
  
  import org.apache.xalan.xslt.XSLTProcessor;
  
  public class DefaultApplyXSL extends ApplyXSL
  {
    /**
     * Mapping of HTTP request's user-Agent values to stylesheet media= values.
     * <p>This mapping is defined by a file pointed to by the operational 
parameter "mediaURL" which can
     *  either contain a full URL or a path relative to the System's 
server.root /servlets directory.</p>
     * @see #setMediaProps
     * @see #getMedia
     * @serial
     */
    protected OrderedProps ourMediaProps = null;
  
    /**
     * Initialize operational parameters from the configuration.
     * @param config Configuration
     * @exception ServletException Never thrown
     */
    public void init(ServletConfig config) throws ServletException
    {
      super.init(config);
      setMediaProps(config.getInitParameter("mediaURL"));
    }
  
    /**
     * Overrides method in ApplyXSL in order to use DefaultApply Properties.
     * @param config Configuration
     */
    protected void setDefaultParameters(ServletConfig config)
    {
      ourDefaultParameters = new DefaultApplyXSLProperties(config);
    }
  
    /**
     * Returns a connection which respects the Accept-Language header of the 
HTTP request.  This
     * is useful when XSL files are internationalized for use with Web servers 
which respect this
     * header.
     * <p>For example, Apache 1.3.6 may be configured for multiviews.  Under 
this configuration,
     * requests for http://myhost/index.html would return 
http://myhost/index.html.fr to French browsers
     * and http://myhost/index.html.en to English browsers.</p>
     * @param url Location to connect to
     * @param request Could contain an Accept-Language header
     * @return An Accept-Language-enabled URL connection
     * @see #getStylesheet
     */
    protected URLConnection toAcceptLanguageConnection(URL url, 
HttpServletRequest request)
      throws Exception
    {
      URLConnection tempConnection = url.openConnection();
      tempConnection.setRequestProperty("Accept-Language", 
request.getHeader("Accept-Language"));
      return tempConnection;
    }
  
    /**
     *  Loads the media properties file specified by the given string.
     * @param mediaURLstring Location of the media properties file.  Can be 
either a full URL or a path relative
     * to the System's server.root /servlets directory.  If this parameter is 
null,
     * server.root/servlets/media.properties will be used.
     * @see ApplyXSL#CURRENTDIR
     */
    protected void setMediaProps(String mediaURLstring)
    {
      if (mediaURLstring != null)
      {
        URL url = null;
        try
        {
          url = new URL(mediaURLstring);
        }
        catch (MalformedURLException mue1)
        {
          try
          {
            url = new URL("file", "", CURRENTDIR + mediaURLstring);
          }
          catch (MalformedURLException mue2)
          {
            writeLog("Unable to find the media properties file based on 
parameter 'mediaURL' = "
                     + mediaURLstring, HttpServletResponse.SC_ACCEPTED, mue2);
            url = null;
          }
        }
        if (url != null)
        {
          try
          {
            ourMediaProps = new OrderedProps(url.openStream());
          }
          catch (IOException ioe1)
          {
            writeLog("Exception occurred while opening media properties file: " 
+ mediaURLstring +
                     ".  Media table may be invalid.", 
HttpServletResponse.SC_ACCEPTED, ioe1);
          }
        }
      }
      else
      {
        String defaultProp = CURRENTDIR + "media.properties";
        try
        {
          ourMediaProps = new OrderedProps(new FileInputStream(defaultProp));
        }
        catch (IOException ioe2)
        {
          writeLog("Default media properties file " + defaultProp + " not 
found.",
                   HttpServletResponse.SC_ACCEPTED, ioe2);
        }
      }
    }
  
    /**
     * Returns a DOM from the specified input stream.
     * @param request Could contain the URL(s) for catalog(s)
     * @param ins Input stream to parse
     * @param listener To record detailed parsing messages for a possible 
return to requestor
     * @return The DOM
     * @exception IOException Thrown when input stream cannot be opened for 
parsing
     * @exception SAXException Thrown by parser if stream not XSLTInputSource 
compliant
     * @exception com.lotus.xsl.XSLProcessorException Thrown when stream cannot 
be parsed
     * @exception Exception Only the above Exceptions should be thrown
     */
    public XSLTInputSource makeDocument(XSLTProcessor processor,
                                        HttpServletRequest request,
                                        InputStream ins,
                                        ErrorHandler listener)
      throws Exception
    {
      /*
      DOMParser parser = new DOMParser();
      //parser.setNodeExpansion(NonValidatingDOMParser.DEFERRED);
      parser.setNodeExpansion(NonValidatingDOMParser.FULL);
      parser.setExpandEntityReferences(true);
      parser.setErrorHandler(listener);
      String catalogURL[] = ((DefaultApplyXSLProperties) 
ourDefaultParameters).getCatalog(request);
      if (catalogURL != null)
      {
        XCatalog catalog = new XCatalog(parser.getParserState());
        parser.getEntityHandler().setEntityResolver(catalog);
        int i, len = catalogURL.length;
        for (i = 0; i < len; i++)
        {
          parser.loadCatalog(new InputSource(catalogURL[i]));
        }
      }
      parser.parse(new InputSource(ins));
      return new XSLTInputSource(parser.getDocument());
      */
  
      XSLTInputSource source = new XSLTInputSource(ins);
  
      // Not sure what to do about the catalog business here.  If this is 
needed,
      // we should have the liaison do it, if possible.
  
      return source;
    }
  
    /**
     * Returns a media name mapped from the specified request's user-Agent 
header.
     * This mapping enables relationships to be defined between client 
capabilities and stylesheets
     * capable of acting on these capabilities.
     * <p>Refer to the media.properties file for details.</p>
     * @param request Contains the user-Agent header
     * @return The media name that corresponds to the user-Agent, or "unknown"
     * @see #getStylesheet
     * @see #HEADER_NAME
     */
    public String getMedia(HttpServletRequest request)
    {
      return ourMediaProps.getValue(request.getHeader(HEADER_NAME));
    }
  
    /**
     * Returns the XSL stylesheet URL associated with the specified XML 
document.  If multiple XSL
     * stylesheets are associated with the XML document, preference will be 
given to the stylesheet
     * which contains an attribute name/value pair that corresponds to the 
specified attributeName
     * and attributeValue.
     * @param xmlSource XML XSLTInputSource to be searched for associated XSL 
stylesheets
     * @param attributeName  Attribute name to provide preferential matching
     * @param attributeValue Attribute value to provide preferential matching
     * @return The preferred XSL stylesheet URL, or null if no XSL stylesheet 
association is found
     * @see #getStylesheet
     */
    public static String getXSLURLfromDoc(XSLTInputSource xmlSource, String 
attributeName, String attributeValue)
    {
      String tempURL = null, returnURL = null;
      NodeList children = xmlSource.getNode().getChildNodes();
      int nNodes = children.getLength(), i;
      for(i = 0; i < nNodes; i++)
      {
        Node child = children.item(i);
        if(Node.PROCESSING_INSTRUCTION_NODE == child.getNodeType())
        {
          ProcessingInstruction pi = (ProcessingInstruction)child;
          if(pi.getNodeName().equals("xml-stylesheet"))
          {
            PIA pia = new PIA(pi);
            if("text/xsl".equals(pia.getAttribute("type")))
            {
              tempURL = pia.getAttribute("href");
              String attribute = pia.getAttribute(attributeName);
              if ((attribute != null) && (attribute.indexOf(attributeValue) > 
-1))
                return tempURL;
              if (!"yes".equals(pia.getAttribute("alternate")))
                returnURL = tempURL;
            }
          }
        }
      }
      return returnURL;
    }
  
    /**
     * Returns an XSL XSLTInputSource.  Attempts will be make to create the 
Stylesheet from the following
     * sources:
     * <ol>
     * <li>A URL specified in the HTTP request's <code>xslURL=</code> 
parameter.  This capability
     * is intended for clients wishing to selectively override the server 
algorithm for applying XSL
     * stylesheets.  For security reasons, this URL will be forced to the local 
IP host.</li>
     * <li>XML association.  XML documents may contain references to one or 
more stylesheets using
     * <a HREF="http://www.w3.org/TR/1999/PR-xml-stylesheet-19990114";>this</a> 
W3C proposed recommendation.
     * If the XML document does contain such references, a best match will be 
chosen based on the browser
     * type making the request and the default association.  This capability 
enables relationships to be
     * defined between client capabilities and stylesheets capable of acting on 
these capabilities.</li>
     * <li>A configured default stylesheet URL</li>
     * </ol>
     * @param request May contain or point to the XSL XSLTInputSource
     * @param xmlSource  May point to the XSL XSLTInputSource
     * @param listener To record detailed parsing messages for possible return 
to requestor
     * @return XSL XSLTInputSource, or null if the request could not be parsed
     * @see #makeDocument
     * @see #getMedia
     * @see #STYLESHEET_ATTRIBUTE
     * @see #getXSLURLfromDoc
     * @see #toAcceptLanguageConnection
     * @exception ApplyXSLException Thrown if exception occurs while handling 
request
     */
    protected XSLTInputSource getStylesheet(HttpServletRequest request,
                                            XSLTInputSource xmlSource,
                                            ApplyXSLListener listener)
      throws ApplyXSLException
    {
      try
      {
        //stylesheet URL from request
        String xslURL = ((DefaultApplyXSLProperties) 
ourDefaultParameters).getXSLRequestURL(request);
        if (xslURL != null)
          listener.out.println("Parsing XSL Stylesheet Document from request 
parameter: "
                               + xslURL);
        else
        {
          // find stylesheet from XML Document, Media tag preference
          if (xmlSource != null)
            xslURL = getXSLURLfromDoc(xmlSource, STYLESHEET_ATTRIBUTE, 
getMedia(request));
          if (xslURL != null)
            listener.out.println("Parsing XSL Stylesheet Document from XML 
Document tag: " + xslURL);
          else
            // Configuration Default
            if ((xslURL = ourDefaultParameters.getXSLurl(null)) != null)
              listener.out.println("Parsing XSL Stylesheet Document from 
configuration: " + xslURL);
        }
        return new XSLTInputSource(toAcceptLanguageConnection(new URL(xslURL),
                                                              
request).getURL().toString());
      }
      catch (IOException ioe)
      {
        throw new ApplyXSLException(ioe, HttpServletResponse.SC_NOT_FOUND);
      }
      catch (Exception e)
      {
        throw new ApplyXSLException(e, 
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      }
    }
  
    /**
     * Returns an XML XSLTInputSource DOM.  Attempts will be make to create the 
DOM from the following
     * sources:
     * <ol>
     * <li>A relative URL specified in the HTTP request's path information. 
This capability is intended
     * for use by <b>servlet engines that map</b> some or all XML data to be 
processed at the server.</li>
     * <li>A URL specified in the HTTP request's <code>URL=</code> parameter.  
This capability
     * is intended for <b>clients wishing to selectively process</b> XML data 
at the server.  For
     * security reasons, this URL will be forced to the local IP host.</li>
     * <li>The HTTP request's XML input stream. This capability is intended for 
use by chained servlets.</li>
     * </ol>
     * @param request May contain or point to the XML XSLTInputSource
     * @param listener To record detailed parsing messages for possible return 
to requestor
     * @return XML XSLTInputSource DOM, or null if the XSLTInputSource could 
not be parsed
     * @exception ApplyXSLException Thrown if exception occurs while handling 
request
     */
    protected XSLTInputSource getDocument(XSLTProcessor processor,
                                          HttpServletRequest request,
                                          ApplyXSLListener listener)
      throws ApplyXSLException
    {
      try
      {
        String xmlURL = null;
        // document from PathInfo
        if ((xmlURL = request.getPathInfo()) != null)
        {
          listener.out.println("Parsing XML Document from PathInfo: " + xmlURL);
          return makeDocument(processor,
                              request, new URL("http", 
((DefaultApplyXSLProperties)
                                                         
ourDefaultParameters).getLocalHost(),
                                               xmlURL.replace('\\', 
'/')).openStream(), listener);
        }
        // document from Request parameter
        if ((xmlURL = ourDefaultParameters.getXMLurl(request)) != null)
        {
          listener.out.println("Parsing XML Document from request parameter: " 
+ xmlURL);
          return makeDocument(processor, request, new URL(xmlURL).openStream(), 
listener);
        }
        // document from chain
        String contentType = request.getContentType();
        if ((contentType != null) && contentType.startsWith("text/xml"))
        {
          listener.out.println("Parsing XML Document from request chain");
          return makeDocument(processor, request, request.getInputStream(), 
listener);
        }
      }
      catch (IOException ioe)
      {
        throw new ApplyXSLException(ioe, HttpServletResponse.SC_NOT_FOUND);
      }
      catch (Exception e)
      {
        throw new ApplyXSLException(e, 
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      }
      return null;
    }
  
    /**
     * The attribute name in the <?xml-stylesheet> tag used in stylesheet 
selection.
     */
    protected static final String STYLESHEET_ATTRIBUTE = "media";
  
    /**
     *  The HTTP Header used for matching the Stylesheet attribute via the
     * media properties file selected.
     */
    protected static final String HEADER_NAME = "user-Agent";
  }
  
  /**
   *  Stores the keys and values from a file (similar to a properties file) and
   *  can return the first value which has a key contained in its string.
   *  File can have comment lines starting with '#" and for each line the 
entries are
   *  separated by tabs and '=' char.
   */
  class OrderedProps
  {
  
    /**
     * Stores the Key and Values as an array of Strings
     */
    private Vector attVec = new Vector(15);
  
    /**
     * Constructor.
     * @param inputStream Stream containing the properties file.
     * @exception IOException Thrown if unable to read from stream
     */
    OrderedProps(InputStream inputStream)
      throws IOException
    {
      BufferedReader input  = new BufferedReader(new 
InputStreamReader(inputStream));
      String currentLine, Key = null;
      StringTokenizer currentTokens;
      while ((currentLine = input.readLine()) != null)
      {
        currentTokens = new StringTokenizer(currentLine, "=\t\r\n");
        if (currentTokens.hasMoreTokens()) Key = 
currentTokens.nextToken().trim();
        if ((Key != null) && !Key.startsWith("#") && 
currentTokens.hasMoreTokens())
        {
          String temp[] = new String[2];
          temp[0] = Key; temp[1] = currentTokens.nextToken().trim();
          attVec.addElement(temp);
        }
      }
    }
  
    /**
     * Iterates through the Key list and returns the first value for whose
     * key the given string contains.  Returns "unknown" if no key is contained
     * in the string.
     * @param s String being searched for a key.
     * @return Value for key found in string, otherwise "unknown"
     */
    String getValue(String s)
    {
      int i, j = attVec.size();
      for (i = 0; i < j; i++)
      {
        String temp[] = (String[]) attVec.elementAt(i);
        if (s.indexOf(temp[0]) > -1)
          return temp[1];
      }
      return "unknown";
    }
  }
  
  
  
  /**
   * Parses a processing instruction's (PI) attributes for easy retrieval.
   */
  class PIA
  {
  
    private Hashtable piAttributes = null;
  
    /**
     * Constructor.
     * @param pi The processing instruction whose attributes are to be parsed
     */
    PIA(ProcessingInstruction pi)
    {
      piAttributes = new Hashtable();
      StringTokenizer tokenizer = new StringTokenizer(pi.getNodeValue(), "=\"");
      while(tokenizer.hasMoreTokens())
      {
        piAttributes.put(tokenizer.nextToken().trim(), 
tokenizer.nextToken().trim());
      }
    }
  
    /**
     * Returns value of specified attribute.
     *  @param name Attribute name
     *  @return Attribute value, or null if the attribute name does not exist
     */
    String getAttribute(String name)
    {
      return (String) piAttributes.get(name);
    }
  
  }
  
  
  
  1.1                  xml-xalan/samples/Servlet/DefaultApplyXSLProperties.java
  
  Index: DefaultApplyXSLProperties.java
  ===================================================================
  
/*****************************************************************************************************
   * $Id: DefaultApplyXSLProperties.java,v 1.1 2000/02/12 00:00:13 dleslie Exp $
   * 
   * Copyright (c) 1998-1999 Lotus Corporation, Inc. All Rights Reserved.
   *                            This software is provided without a warranty of 
any kind.
   * 
   * $State: Exp $
   
*****************************************************************************************************/
  
  import java.net.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  
/*****************************************************************************************************
   * 
   * DefaultApplyXSLProperties contains operational parameters for 
DefaultApplyXSL based 
   * on program defaults and configuration.  
   * <p>This class is also used to return values for request-time 
parameters.</p>
   *
   * @author Spencer Shepard ([EMAIL PROTECTED])
   * @author R. Adam King ([EMAIL PROTECTED])
   * @author Tom Rowe ([EMAIL PROTECTED])
   *
   
*****************************************************************************************************/
  
  public class DefaultApplyXSLProperties extends ApplyXSLProperties {
      
      /**
        * Program default for parameter "catalog".
        * @see #getCatalog
        */
      private final String DEFAULT_catalog;
  
      /**
        * Host used for local context comparisons.
        * @see #getLocalHost
        * @see #setLocalHost
        */
      protected transient String localHost = null;
  
      /**
        * Constructor to use program defaults.
        */
      public DefaultApplyXSLProperties()
      {
        super();
        DEFAULT_catalog = null;
        setLocalHost();
      }
  
      /**
        * Constructor to use to override program defaults.
        * @param config Servlet configuration
        * @see #setLocalHost
        */
      public DefaultApplyXSLProperties(ServletConfig config)
      {
        super(config);
        String cat = config.getInitParameter("catalog");
        if (cat != null) DEFAULT_catalog = cat;
        else DEFAULT_catalog = null;
        setLocalHost();
      }
  
      /**
        * Sets the name of the local IP host name; this value will be used to 
constrain untrusted 
        * XML document and XSL stylesheet URLs to this trusted host.
        * @see #getLocalHost
        */
      protected void setLocalHost()
      {
        try { 
            localHost = InetAddress.getLocalHost().getHostName();
        } catch (Exception uhe) {
            localHost = null;
        }
      }
  
      /**
        * Returns the name of trusted IP host.
        * @return Name of trusted host
        * @see #setLocalHost
        */
      public String getLocalHost()
      {
        return localHost;
      }
  
      /**
        * Returns a URL which is constrained to a trusted IP host.
        * @param xURL URL or file path to be made safe 
        * @return Safe URL
        * @exception MalformedURLException Thrown when xURL is not a valid URL
        * @see #setLocalHost
        * @see #getLocalHost
        */
      public URL toSafeURL(String xURL)
      throws MalformedURLException
      {
        if (xURL == null)
            return null;
  
        if (xURL.startsWith("/")) {
            try {
                return new URL("http", localHost, xURL);
            } catch (MalformedURLException mue) {
            throw new MalformedURLException("toSafeURL(): " + xURL + 
                                            " did not map to local");
            }
        }
        URL tempURL = null;
        try { 
            tempURL = new URL(xURL);
        } catch (MalformedURLException mue) {
            throw new MalformedURLException("toSafeURL(): " + xURL + 
                                            " not a valid URL");
        }
        try { 
            return new URL(tempURL.getProtocol(), localHost, 
                           tempURL.getPort(), tempURL.getFile());
        } catch (MalformedURLException mue) {
            throw new MalformedURLException("toSafeURL(): " + xURL + 
                                            " could not be converted to local 
host");
        }
      }
  
      /**
        *       Returns a string representing the constrained URL for the XML 
document.
        * If there is no request parameter for the XML document, return the 
configured default.
        * @param request May contain an XML document URL parameter
        * @return String form of XML URL
        * @exception MalformedURLException Thrown when request URL is not a 
valid URL or path
        * @see #toSafeURL
        */
      public String getXMLurl(HttpServletRequest request)
      throws MalformedURLException
      {
        URL url = toSafeURL(getRequestParmString(request, "URL"));
        if (url == null)
            return super.getXMLurl(null);
        return url.toExternalForm();
      }
  
      /**
        * Returns a string representing the constrained URL for the XSL 
stylesheet 
        * from the request.
        * @param request May contain an XSL stylesheet URL parameter
        * @return String form of request XSL URL, or null if request contains 
no xslURL parameter
        * @exception MalformedURLException Thrown when request URL is not a 
valid URL or path
        * @see #toSafeURL
        */
      public String getXSLRequestURL(HttpServletRequest request)
      throws MalformedURLException
      {
        URL url = toSafeURL(getRequestParmString(request, "xslURL"));
        if (url == null)
            return null;
        return url.toExternalForm();
      }
  
      /**
        * Returns a string representing the constrained request URL for the XSL 
stylesheet.
        * If there is no request parameter for the XSL stylesheet, return the 
configured default.
        * @param request May contain an XSL stylesheet URL parameter
        * @return String form of XSL URL
        * @exception MalformedURLException Thrown when request URL is not a 
valid URL or path
        * @see #toSafeURL
        */
      public String getXSLurl(HttpServletRequest request)
      throws MalformedURLException
      {
        String reqURL = getXSLRequestURL(request);
        if (reqURL != null)
            return reqURL;
        return super.getXSLurl(null);
      }
  
      /**
        * Returns URLs for all <a 
href="http://www.ccil.org/~cowan/XML/XCatalog.html";>XCatalogs</a> 
        * that are to be used to process the request.  Catalogs are used to 
resolve XML public identifiers
        * into system identifiers.
        * <p>A single XCatalog can be configured as a default,
        * but multiple XCatalogs can be specified at request time to augment 
the configured default.
        * @param request May contain one or more XCatalog parameters
        * @return Array of strings for all catalog URLs
        */
      public String[] getCatalog(HttpServletRequest request)
      {
        String temp[] = request.getParameterValues("catalog");
        if (DEFAULT_catalog == null)
            return temp;
        if (temp == null) {
            String defaultArray[] = new String [1];
            defaultArray[0] = DEFAULT_catalog;
            return defaultArray;
        }
        int i, len = temp.length + 1;
        String newCatalogs[] = new String[len];
        newCatalogs[0] = DEFAULT_catalog;
        for (i=1; i < len; i++) {
            newCatalogs[i] = temp[i-1];
        }
        return newCatalogs;
      }
  }
  
  
  
  1.1                  xml-xalan/samples/Servlet/default.xsl
  
  Index: default.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <!--                                                                          
      -->
  <!--  Default XSL stylesheet for use by com.lotus.xsl.server#DefaultApplyXSL. 
      -->
  <!--                                                                          
      -->
  <!--  This stylesheet mimics the default behavior of IE when XML data is 
displayed  -->
  <!--  without a corresponding XSL stylesheet.  This stylesheet uses 
JavaScript      -->
  <!--  to accommodate node expansion and contraction.                          
      -->
  <!--                                                                          
      -->
  
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0";
                  xmlns="http://www.w3.org/TR/REC-html40";>
                  
  <xsl:output method="html" indent="no"/>
  <xsl:strip-space elements="*"/>
  
  <xsl:template match="/">
    <HTML>
      <HEAD>
        <STYLE type="text/css">
          BODY {font:x-small 'Verdana'; margin-right:1.5em}
        <!-- container for expanding/collapsing content -->
          .c  {cursor:hand}
        <!-- button - contains +/-/nbsp -->
          .b  {color:red; font-family:'Courier New'; font-weight:bold; 
text-decoration:none}
        <!-- element container -->
          .e  {margin-left:1em; text-indent:-1em; margin-right:1em}
        <!-- comment or cdata -->
          .k  {margin-left:1em; text-indent:-1em; margin-right:1em}
        <!-- tag -->
          .t  {color:#990000}
        <!-- tag in xsl namespace -->
          .xt {color:#990099}
        <!-- attribute in xml or xmlns namespace -->
          .ns {color:red}
        <!-- markup characters -->
          .m  {color:blue}
        <!-- text node -->
          .tx {font-weight:bold}
        <!-- multi-line (block) cdata -->
          .db {text-indent:0px; margin-left:1em; margin-top:0px; 
margin-bottom:0px;
               padding-left:.3em; border-left:1px solid #CCCCCC; font:small 
Courier}
        <!-- single-line (inline) cdata -->
          .di {font:small Courier}
        <!-- DOCTYPE declaration -->
          .d  {color:blue}
        <!-- pi -->
          .pi {color:blue}
        <!-- multi-line (block) comment -->
          .cb {text-indent:0px; margin-left:1em; margin-top:0px; 
margin-bottom:0px;
               padding-left:.3em; font:small Courier; color:#888888}
        <!-- single-line (inline) comment -->
          .ci {font:small Courier; color:#888888}
          PRE {margin:0px; display:inline}
        </STYLE>
  
        <SCRIPT type="text/javascript"><xsl:comment><![CDATA[
          // Detect and switch the display of CDATA and comments from an inline 
view
          //  to a block view if the comment or CDATA is multi-line.
          function f(e)
          {
            // if this element is an inline comment, and contains more than a 
single
            //  line, turn it into a block comment.
            if (e.className == "ci") {
              if (e.children(0).innerText.indexOf("\n") > 0)
                fix(e, "cb");
            }
            
            // if this element is an inline cdata, and contains more than a 
single
            //  line, turn it into a block cdata.
            if (e.className == "di") {
              if (e.children(0).innerText.indexOf("\n") > 0)
                fix(e, "db");
            }
            
            // remove the id since we only used it for cleanup
            e.id = "";
          }
          
          // Fix up the element as a "block" display and enable expand/collapse 
on it
          function fix(e, cl)
          {
            // change the class name and display value
            e.className = cl;
            e.style.display = "block";
            
            // mark the comment or cdata display as a expandable container
            j = e.parentElement.children(0);
            j.className = "c";
  
            // find the +/- symbol and make it visible - the dummy link enables 
tabbing
            k = j.children(0);
            k.style.visibility = "visible";
            k.href = "#";
          }
  
          // Change the +/- symbol and hide the children.  This function works 
on "element"
          //  displays
          function ch(e)
          {
            // find the +/- symbol
            mark = e.children(0).children(0);
            
            // if it is already collapsed, expand it by showing the children
            if (mark.innerText == "+")
            {
              mark.innerText = "-";
              for (var i = 1; i < e.children.length; i++)
                e.children(i).style.display = "block";
            }
            
            // if it is expanded, collapse it by hiding the children
            else if (mark.innerText == "-")
            {
              mark.innerText = "+";
              for (var i = 1; i < e.children.length; i++)
                e.children(i).style.display="none";
            }
          }
          
          // Change the +/- symbol and hide the children.  This function work 
on "comment"
          //  and "cdata" displays
          function ch2(e)
          {
            // find the +/- symbol, and the "PRE" element that contains the 
content
            mark = e.children(0).children(0);
            contents = e.children(1);
            
            // if it is already collapsed, expand it by showing the children
            if (mark.innerText == "+")
            {
              mark.innerText = "-";
              // restore the correct "block"/"inline" display type to the PRE
              if (contents.className == "db" || contents.className == "cb")
                contents.style.display = "block";
              else contents.style.display = "inline";
            }
            
            // if it is expanded, collapse it by hiding the children
            else if (mark.innerText == "-")
            {
              mark.innerText = "+";
              contents.style.display = "none";
            }
          }
          
          // Handle a mouse click
          function cl()
          {
            e = window.event.srcElement;
            
            // make sure we are handling clicks upon expandable container 
elements
            if (e.className != "c")
            {
              e = e.parentElement;
              if (e.className != "c")
              {
                return;
              }
            }
            e = e.parentElement;
            
            // call the correct funtion to change the collapse/expand state and 
display
            if (e.className == "e")
              ch(e);
            if (e.className == "k")
              ch2(e);
          }
          
          // Erase bogus link info from the status window
          function h()
          {
            window.status=" ";
          }
  
          // Set the onclick handler
          document.onclick = cl;
          
        ]]>//</xsl:comment></SCRIPT>
      </HEAD>
  
      <BODY class="st"><xsl:apply-templates/></BODY>
  
    </HTML>
  </xsl:template>
  
  <!-- Templates for each node type follows.  The output of each template has a 
similar structure
    to enable script to walk the result tree easily for handling user 
interaction. -->
    
  <!-- Template for pis not handled elsewhere -->
  <xsl:template match="processing-instruction()">
    <DIV class="e">
    <SPAN class="b">&#160;</SPAN>
    <SPAN class="m">&lt;?</SPAN><SPAN class="pi"><xsl:value-of 
select="name(.)"/> <xsl:value-of select="."/></SPAN><SPAN class="m">?&gt;</SPAN>
    </DIV>
  </xsl:template>
  
  <!-- Template for the XML declaration.  Need a separate template because the 
pseudo-attributes
      are actually exposed as attributes instead of just element content, as in 
other pis 
  <xsl:template match="processing-instruction('xml')">
    <DIV class="e">
    <SPAN class="b">&#160;</SPAN>
    <SPAN class="m">&lt;?</SPAN><SPAN class="pi">xml <xsl:for-each 
select="@*"><xsl:value-of select="name(.)"/>="<xsl:value-of select="."/>" 
</xsl:for-each></SPAN><SPAN class="m">?&gt;</SPAN>
    </DIV>
  </xsl:template>
  -->
  
  <!-- Template for attributes not handled elsewhere -->
  <xsl:template match="@*"><SPAN class="t"><xsl:text> </xsl:text><xsl:value-of 
select="name(.)"/></SPAN><SPAN class="m">="</SPAN><B><xsl:value-of 
select="."/></B><SPAN class="m">"</SPAN></xsl:template>
  
  <!-- Template for attributes in the xmlns or xml namespace
  <xsl:template match="@xmlns:*|@xmlns|@xml:*"><SPAN class="ns"> <xsl:value-of 
select="name(.)"/></SPAN><SPAN class="m">="</SPAN><B class="ns"><xsl:value-of 
select="."/></B><SPAN class="m">"</SPAN></xsl:template>
  -->
  
  <!-- Template for text nodes -->
  <xsl:template match="text()">
    <xsl:choose><xsl:when test="name(.) = '#cdata-section'"><xsl:call-template 
name="cdata"/></xsl:when>
    <xsl:otherwise><DIV class="e">
    <SPAN class="b">&#160;</SPAN>
    <SPAN class="tx"><xsl:value-of select="."/></SPAN>
    </DIV></xsl:otherwise></xsl:choose>
  </xsl:template>
    
  <!-- Template for comment nodes -->
  <xsl:template match="comment()">
    <DIV class="k">
    <SPAN><A class="b" onclick="return false" onfocus="h()" 
STYLE="visibility:hidden">-</A> <SPAN class="m">&lt;!--</SPAN></SPAN>
    <SPAN id="clean" class="ci"><PRE><xsl:value-of select="."/></PRE></SPAN>
    <SPAN class="b">&#160;</SPAN> <SPAN class="m">--&gt;</SPAN>
    <SCRIPT>f(clean);</SCRIPT></DIV>
  </xsl:template>
  
  <!-- Template for cdata nodes -->
  <xsl:template name="cdata">
    <DIV class="k">
    <SPAN><A class="b" onclick="return false" onfocus="h()" 
STYLE="visibility:hidden">-</A> <SPAN class="m">&lt;![CDATA[</SPAN></SPAN>
    <SPAN id="clean" class="di"><PRE><xsl:value-of select="."/></PRE></SPAN>
    <SPAN class="b">&#160;</SPAN> <SPAN class="m">]]&gt;</SPAN>
    <SCRIPT>f(clean);</SCRIPT></DIV>
  </xsl:template>
  
  <!-- Template for elements not handled elsewhere (leaf nodes) -->
  <xsl:template match="*">
    <DIV class="e"><DIV STYLE="margin-left:1em;text-indent:-2em">
    <SPAN class="b">&#160;</SPAN>
    <SPAN class="m">&lt;</SPAN><SPAN class="t"><xsl:value-of 
select="name(.)"/></SPAN> <xsl:apply-templates select="@*"/><SPAN class="m"> 
/&gt;</SPAN>
    </DIV></DIV>
  </xsl:template>
    
  <!-- Template for elements with comment, pi and/or cdata children
  <xsl:template match="*[comment() or processing-instruction() or cdata()]">
    <DIV class="e">
    <DIV class="c"><A href="#" onclick="return false" onfocus="h()" 
class="b">-</A> <SPAN class="m">&lt;</SPAN><SPAN><xsl:attribute 
name="class"><xsl:if test="xsl:*">x</xsl:if>t</xsl:attribute><xsl:value-of 
select="name(.)"/></SPAN><xsl:apply-templates select="@*"/> <SPAN 
class="m">&gt;</SPAN></DIV>
    <DIV><xsl:apply-templates/>
    <DIV><SPAN class="b">&#160;</SPAN> <SPAN 
class="m">&lt;/</SPAN><SPAN><xsl:attribute name="class"><xsl:if 
test="xsl:*">x</xsl:if>t</xsl:attribute><xsl:value-of 
select="name(.)"/></SPAN><SPAN class="m">&gt;</SPAN></DIV>
    </DIV></DIV>
  </xsl:template> -->
  
  <!-- Template for elements with only text children -->
  <xsl:template match="*[text() and not(comment() or processing-instruction() 
or *)]">
    <DIV class="e"><DIV STYLE="margin-left:1em;text-indent:-2em">
    <SPAN class="b">&#160;</SPAN> <SPAN class="m">&lt;</SPAN><SPAN 
class="t"><xsl:value-of select="name(.)"/></SPAN><xsl:apply-templates 
select="@*"/>
    <SPAN class="m">&gt;</SPAN><SPAN class="tx"><xsl:value-of 
select="."/></SPAN><SPAN class="m">&lt;/</SPAN><SPAN class="t"><xsl:value-of 
select="name(.)"/></SPAN><SPAN class="m">&gt;</SPAN>
    </DIV></DIV>
  </xsl:template>
  
  <!-- Template for elements with element children -->
  <xsl:template match="*[*]">
    <DIV class="e">
    <DIV class="c" STYLE="margin-left:1em;text-indent:-2em"><A href="#" 
onclick="return false" onfocus="h()" class="b">-</A> <SPAN 
class="m">&lt;</SPAN><SPAN class="t"><xsl:value-of 
select="name(.)"/></SPAN><xsl:apply-templates select="@*"/><SPAN 
class="m">&gt;</SPAN></DIV>
    <DIV><xsl:apply-templates/>
    <DIV><SPAN class="b">&#160;</SPAN><SPAN class="m">&lt;/</SPAN><SPAN 
class="t"><xsl:value-of select="name(.)"/></SPAN><SPAN 
class="m">&gt;</SPAN></DIV>
    </DIV></DIV>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  1.1                  xml-xalan/samples/Servlet/default2.xsl
  
  Index: default2.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <!--                                                                          
      -->
  <!--  Default XSL stylesheet for use by com.lotus.xsl.server#DefaultApplyXSL. 
      -->
  <!--                                                                          
      -->
  <!--  This stylesheet mimics the default behavior of IE when XML data is 
displayed  -->
  <!--  without a corresponding XSL stylesheet.  This stylesheet uses no 
JavaScript   -->
  <!--  and displays all nodes as fully expanded.                               
      -->
  <!--                                                                          
      -->
  
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0";
                  xmlns="http://www.w3.org/TR/REC-html40";>
                  
  <xsl:output method="html" indent="no"/>
  <xsl:strip-space elements="*"/>
  
  <xsl:template match="/">
    <HTML>
      <HEAD>
        <STYLE type="text/css">
          BODY {font:x-small 'Verdana'; margin-right:1.5em}
        <!-- container for expanding/collapsing content -->
          .c  {cursor:hand}
        <!-- button - contains +/-/nbsp -->
          .b  {color:red; font-family:'Courier New'; font-weight:bold; 
text-decoration:none}
        <!-- element container -->
          .e  {margin-left:1em; text-indent:-1em; margin-right:1em}
        <!-- comment or cdata -->
          .k  {margin-left:1em; text-indent:-1em; margin-right:1em}
        <!-- tag -->
          .t  {color:#990000}
        <!-- tag in xsl namespace -->
          .xt {color:#990099}
        <!-- attribute in xml or xmlns namespace -->
          .ns {color:red}
        <!-- markup characters -->
          .m  {color:blue}
        <!-- text node -->
          .tx {font-weight:bold}
        <!-- multi-line (block) cdata -->
          .db {text-indent:0px; margin-left:1em; margin-top:0px; 
margin-bottom:0px;
               padding-left:.3em; border-left:1px solid #CCCCCC; font:small 
Courier}
        <!-- single-line (inline) cdata -->
          .di {font:small Courier}
        <!-- DOCTYPE declaration -->
          .d  {color:blue}
        <!-- pi -->
          .pi {color:blue}
        <!-- multi-line (block) comment -->
          .cb {text-indent:0px; margin-left:1em; margin-top:0px; 
margin-bottom:0px;
               padding-left:.3em; font:small Courier; color:#888888}
        <!-- single-line (inline) comment -->
          .ci {font:small Courier; color:#888888}
          PRE {margin:0px; display:inline}
        </STYLE>
      </HEAD>
  
      <BODY class="st"><xsl:apply-templates/></BODY>
  
    </HTML>
  </xsl:template>
  
  <!-- Templates for each node type follows.  The output of each template has a 
similar structure
    to enable script to walk the result tree easily for handling user 
interaction. -->
    
  <!-- Template for pis not handled elsewhere -->
  <xsl:template match="processing-instruction()">
    <DIV class="e">
    <SPAN class="b">&#160;</SPAN>
    <SPAN class="m">&lt;?</SPAN><SPAN class="pi"><xsl:value-of 
select="name(.)"/> <xsl:value-of select="."/></SPAN><SPAN class="m">?&gt;</SPAN>
    </DIV>
  </xsl:template>
  
  <!-- Template for the XML declaration.  Need a separate template because the 
pseudo-attributes
      are actually exposed as attributes instead of just element content, as in 
other pis 
  <xsl:template match="processing-instruction('xml')">
    <DIV class="e">
    <SPAN class="b">&#160;</SPAN>
    <SPAN class="m">&lt;?</SPAN><SPAN class="pi">xml <xsl:for-each 
select="@*"><xsl:value-of select="name(.)"/>="<xsl:value-of select="."/>" 
</xsl:for-each></SPAN><SPAN class="m">?&gt;</SPAN>
    </DIV>
  </xsl:template>
  -->
  
  <!-- Template for attributes not handled elsewhere -->
  <xsl:template match="@*"><SPAN class="t"><xsl:text> </xsl:text><xsl:value-of 
select="name(.)"/></SPAN><SPAN class="m">="</SPAN><B><xsl:value-of 
select="."/></B><SPAN class="m">"</SPAN></xsl:template>
  
  <!-- Template for attributes in the xmlns or xml namespace
  <xsl:template match="@xmlns:*|@xmlns|@xml:*"><SPAN class="ns"> <xsl:value-of 
select="name(.)"/></SPAN><SPAN class="m">="</SPAN><B class="ns"><xsl:value-of 
select="."/></B><SPAN class="m">"</SPAN></xsl:template>
  -->
  
  <!-- Template for text nodes -->
  <xsl:template match="text()">
    <xsl:choose><xsl:when test="name(.) = '#cdata-section'"><xsl:call-template 
name="cdata"/></xsl:when>
    <xsl:otherwise><DIV class="e">
    <SPAN class="b">&#160;</SPAN>
    <SPAN class="tx"><xsl:value-of select="."/></SPAN>
    </DIV></xsl:otherwise></xsl:choose>
  </xsl:template>
    
  <!-- Template for comment nodes -->
  <xsl:template match="comment()">
    <DIV class="k">
    <SPAN><SPAN class="b" STYLE="visibility:hidden">-</SPAN> <SPAN 
class="m">&lt;!--</SPAN></SPAN>
    <SPAN class="cb"><PRE><xsl:value-of select="."/></PRE></SPAN>
    <SPAN class="b">&#160;</SPAN> <SPAN class="m">--&gt;</SPAN>
    </DIV>
  </xsl:template>
  
  <!-- Template for cdata nodes -->
  <xsl:template name="cdata">
    <DIV class="k">
    <SPAN><SPAN class="b" STYLE="visibility:hidden">-</SPAN> <SPAN 
class="m">&lt;![CDATA[</SPAN></SPAN>
    <SPAN class="db"><PRE><xsl:value-of select="."/></PRE></SPAN>
    <SPAN class="b">&#160;</SPAN> <SPAN class="m">]]&gt;</SPAN>
    </DIV>
  </xsl:template>
  
  <!-- Template for elements not handled elsewhere (leaf nodes) -->
  <xsl:template match="*">
    <DIV class="e"><DIV STYLE="margin-left:1em;text-indent:-2em">
    <SPAN class="b">&#160;</SPAN>
    <SPAN class="m">&lt;</SPAN><SPAN class="t"><xsl:value-of 
select="name(.)"/></SPAN> <xsl:apply-templates select="@*"/><SPAN class="m"> 
/&gt;</SPAN>
    </DIV></DIV>
  </xsl:template>
    
  <!-- Template for elements with comment, pi and/or cdata children
  <xsl:template match="*[comment() or processing-instruction() or cdata()]">
    <DIV class="e">
    <DIV class="c"><A href="#" onclick="return false" onfocus="h()" 
class="b">-</A> <SPAN class="m">&lt;</SPAN><SPAN><xsl:attribute 
name="class"><xsl:if test="xsl:*">x</xsl:if>t</xsl:attribute><xsl:value-of 
select="name(.)"/></SPAN><xsl:apply-templates select="@*"/> <SPAN 
class="m">&gt;</SPAN></DIV>
    <DIV><xsl:apply-templates/>
    <DIV><SPAN class="b">&#160;</SPAN> <SPAN 
class="m">&lt;/</SPAN><SPAN><xsl:attribute name="class"><xsl:if 
test="xsl:*">x</xsl:if>t</xsl:attribute><xsl:value-of 
select="name(.)"/></SPAN><SPAN class="m">&gt;</SPAN></DIV>
    </DIV></DIV>
  </xsl:template> -->
  
  <!-- Template for elements with only text children -->
  <xsl:template match="*[text() and not(comment() or processing-instruction() 
or *)]">
    <DIV class="e"><DIV STYLE="margin-left:1em;text-indent:-2em">
    <SPAN class="b">&#160;</SPAN> <SPAN class="m">&lt;</SPAN><SPAN 
class="t"><xsl:value-of select="name(.)"/></SPAN><xsl:apply-templates 
select="@*"/>
    <SPAN class="m">&gt;</SPAN><SPAN class="tx"><xsl:value-of 
select="."/></SPAN><SPAN class="m">&lt;/</SPAN><SPAN class="t"><xsl:value-of 
select="name(.)"/></SPAN><SPAN class="m">&gt;</SPAN>
    </DIV></DIV>
  </xsl:template>
  
  <!-- Template for elements with element children -->
  <xsl:template match="*[*]">
    <DIV class="e">
    <DIV class="c" STYLE="margin-left:1em;text-indent:-2em"><SPAN 
class="b">-</SPAN><SPAN class="m">&lt;</SPAN><SPAN class="t"><xsl:value-of 
select="name(.)"/></SPAN><xsl:apply-templates select="@*"/> <SPAN 
class="m">&gt;</SPAN></DIV>
    <DIV><xsl:apply-templates/>
    <DIV><SPAN class="b">&#160;</SPAN> <SPAN class="m">&lt;/</SPAN><SPAN 
class="t"><xsl:value-of select="name(.)"/></SPAN><SPAN 
class="m">&gt;</SPAN></DIV>
    </DIV></DIV>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  1.1                  xml-xalan/samples/Servlet/media.properties
  
  Index: media.properties
  ===================================================================
  # This property file is used by com.lotus.xsl.server.DefaultApplyXSL.
  #
  # Each line below specifies a mapping rule between a value contained in the 
HTTP request's user-Agent 
  # field and a value to be scanned for in XSL stylesheet(s) associated with 
the XML data. This mapping 
  # enables relationships to be defined between client capabilities and 
stylesheets capable of acting 
  # on these capabilities.
  #
  # The rules defined below are order-significant.  In other words, if the 
first rule is unsuccessful,
  # the second rule will be tried, etc.  The media value "unknown" will be used 
when no rules are
  # satisfied.
  #
  # Example: 
  #
  # Mapping rules of...
  #
  #   MSIE=explorer
  #   MSPIE=pocketexplorer
  #
  # ...and XML data that contains XSL stylesheet associations of...
  #
  # <?xml-stylesheet                 media="explorer"       href="alldata.xsl"  
type="text/xsl"?>
  # <?xml-stylesheet alternate="yes" media="pocketexplorer" href="somedata.xsl" 
type="text/xsl"?>
  #
  # ...and an HTTP request that contains a user-Agent value of...
  #    
  #   foo MSPIE bar
  #
  # ...will apply the XSL stylesheet somedata.xsl.
  #
  MSIE=explorer
  MSPIE=pocketexplorer
  HandHTTP=handweb
  Mozilla=netscape
  Lynx=lynx
  Opera=opera
  Java=java
  AvantGo=avantgo
  Nokia=nokia
  UP.Browser=up
  DoCoMo=imode
  
  
  
  1.1                  xml-xalan/samples/Servlet/readme.html
  
  Index: readme.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
  <head>
        <title>Xalan Samples</title>
  </head>
  <body>
  <h2>Xalan Samples</h2>
  <p>For information about the samples (what they illustrate and how to run 
them), see <a href="../../docs/samples.html">Samples</a>.</p>
  
  
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/samples/SimpleTransform/SimpleTransform.java
  
  Index: SimpleTransform.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "XSLT4J" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, Lotus
   * Development Corporation., http://www.lotus.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.xml.sax.SAXException;
  import org.apache.xalan.xslt.XSLTProcessorFactory;
  import org.apache.xalan.xslt.XSLTInputSource;
  import org.apache.xalan.xslt.XSLTResultTarget;
  import org.apache.xalan.xslt.XSLTProcessor;
  
  /**
   * Simple sample code to show how to run the XSL processor
   * from the API.
   */
  public class SimpleTransform
  {
        public static void main(String[] args)
      throws java.io.IOException,
             java.net.MalformedURLException,
             org.xml.sax.SAXException
        {
      // Have the XSLTProcessorFactory obtain a interface to a
      // new XSLTProcessor object.
      XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
  
      // Have the XSLTProcessor processor object transform "foo.xml" to
      // System.out, using the XSLT instructions found in "foo.xsl".
      processor.process(new XSLTInputSource("foo.xml"),
                        new XSLTInputSource("foo.xsl"),
                        new XSLTResultTarget(System.out));
        }
  }
  
  
  
  1.1                  xml-xalan/samples/SimpleTransform/foo.xml
  
  Index: foo.xml
  ===================================================================
  <?xml version="1.0"?>
  <doc>Hello</doc>
  
  
  1.1                  xml-xalan/samples/SimpleTransform/foo.xsl
  
  Index: foo.xsl
  ===================================================================
  <?xml version="1.0"?> 
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:template match="doc">
      <out><xsl:value-of select="."/></out>
    </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/samples/SimpleTransform/readme.html
  
  Index: readme.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
  <head>
        <title>Xalan Samples</title>
  </head>
  <body>
  <h2>Xalan Samples</h2>
  <p>For information about the samples (what they illustrate and how to run 
them), see <a href="../../docs/samples.html">Samples</a>.</p>
  
  
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/samples/TransformToDom/TransformToDom.java
  
  Index: TransformToDom.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "XSLT4J" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, Lotus
   * Development Corporation., http://www.lotus.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.xalan.xslt.XSLTProcessor;
  import org.apache.xalan.xslt.XSLTInputSource;
  import org.apache.xalan.xslt.XSLTResultTarget;
  import org.apache.xalan.xslt.XSLTProcessorFactory;
  
  import org.apache.xalan.xpath.xml.TreeWalker;
  import org.apache.xalan.xpath.xml.FormatterToXML;
  
  import java.io.PrintWriter;
  import java.io.FileWriter;
  import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.Reader;
  import org.w3c.dom.Document;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  
  /**
   * Simple sample code to show how to run the XSL processor 
   * from the API, to create a DOM, and then print the DOM 
   * to System.out.
   */
  public class TransformToDom
  {
        public static void main(String[] args)
      throws java.io.IOException, 
             java.net.MalformedURLException, 
             org.xml.sax.SAXException
        {
      XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
      
      XSLTInputSource xmlID = new XSLTInputSource("foo.xml");
      XSLTInputSource stylesheetID = new XSLTInputSource("foo.xsl");
      Document out = new org.apache.xerces.dom.DocumentImpl();
      XSLTResultTarget resultTarget = new XSLTResultTarget(out);
      processor.process(xmlID, stylesheetID, resultTarget);
      
      PrintWriter pw = new PrintWriter( System.out );
      FormatterToXML fl = new FormatterToXML(pw);
      TreeWalker tw = new TreeWalker(fl);
      tw.traverse(out);
      
        }
  }
  
  
  
  1.1                  xml-xalan/samples/TransformToDom/foo.xml
  
  Index: foo.xml
  ===================================================================
  <?xml version="1.0"?>
  <doc>Hello</doc>
  
  
  1.1                  xml-xalan/samples/TransformToDom/foo.xsl
  
  Index: foo.xsl
  ===================================================================
  <?xml version="1.0"?> 
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:template match="doc">
      <out><xsl:value-of select="."/></out>
    </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/samples/TransformToDom/readme.html
  
  Index: readme.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
  <head>
        <title>Xalan Samples</title>
  </head>
  <body>
  <h2>Xalan Samples</h2>
  <p>For information about the samples (what they illustrate and how to run 
them), see <a href="../../docs/samples.html">Samples</a>.</p>
  
  
  </body>
  </html>
  
  
  
  1.1                  
xml-xalan/samples/UseStylesheetParam/UseStylesheetParam.java
  
  Index: UseStylesheetParam.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "XSLT4J" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, Lotus
   * Development Corporation., http://www.lotus.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.xml.sax.SAXException;
  import org.apache.xalan.xpath.XPathException;
  import org.apache.xalan.xslt.XSLTProcessorFactory;
  import org.apache.xalan.xslt.XSLTInputSource;
  import org.apache.xalan.xslt.XSLTResultTarget;
  import org.apache.xalan.xslt.XSLTProcessor;
  import org.apache.xalan.xpath.XString;
  
  import java.io.PrintWriter;
  import java.io.FileWriter;
  
  /**
   * Simple sample code to show how to pass parameters
   * to an XSL stylesheet.
   */
  public class UseStylesheetParam
  {
        public static void main(String[] args)
      throws java.io.IOException,
             java.net.MalformedURLException,
             org.xml.sax.SAXException
        {
      if(args.length != 1)
      {
        System.err.println("Please pass one string to this program");
        return;
      }
  
      // Have the XSLTProcessorFactory obtain a interface to a
      // new XSLTProcessor object.
      XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
  
      // Set a param named "param1", that the stylesheet can obtain.
      processor.setStylesheetParam("param1", processor.createXString(args[0]));
  
      System.out.println("------------------");
      // Have the XSLTProcessor processor object transform "foo.xml" to
      // System.out, using the XSLT instructions found in "foo.xsl".
      processor.process(new XSLTInputSource("foo.xml"),
                        new XSLTInputSource("foo.xsl"),
                        new XSLTResultTarget(System.out));
      System.out.println("\n------------------");
        }
  }
  
  
  
  1.1                  xml-xalan/samples/UseStylesheetParam/foo.xml
  
  Index: foo.xml
  ===================================================================
  <?xml version="1.0"?>
  <doc>Hello</doc>
  
  
  
  1.1                  xml-xalan/samples/UseStylesheetParam/foo.xsl
  
  Index: foo.xsl
  ===================================================================
  <?xml version="1.0"?> 
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:param name="param1" select="'default value'"/>
    <xsl:template match="doc">
      <out><xsl:value-of select="$param1"/></out>
    </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/samples/UseStylesheetParam/readme.html
  
  Index: readme.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
  <head>
        <title>Xalan Samples</title>
  </head>
  <body>
  <h2>Xalan Samples</h2>
  <p>For information about the samples (what they illustrate and how to run 
them), see <a href="../../docs/samples.html">Samples</a>.</p>
  
  
  </body>
  </html>
  
  
  

Reply via email to