dleslie     99/12/14 08:41:41

  Added:       samples/applet appletXMLtoXML.html client.html foo-s1.xml
                        lts3611beac.jpg rabbitwhorn.jpg README.txt
                        s1ToHTML.xsl target.html testOut.html
                        xalanApplets.xml
  Log:
  Simple applet that transforms 2 XML documents to HTML.
  Applet displays the XML source, the XSL stylesheet,
  and the HTML output.
  
  Revision  Changes    Path
  1.1                  xml-xalan/samples/applet/appletXMLtoXML.html
  
  Index: appletXMLtoXML.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/applet/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 escString ="";
      var target ="";
      function writeSource()
      {
        var sourceString = xslControl.getSourceTreeAsText();
        escString = xslControl.escapeString(sourceString);
        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();
        escString = document.xslControl.escapeString(styleString);
        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(target)
      {
        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
        {
          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();
        writeSource();
        writeStylesheet();
        writeTarget(target);
      }
    </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 codebase and archive attributes set
           so the applet can find xalan.jar and xerces.jar -->  
      <applet  
        name="xslControl"
        code="org.apache.xalan.xslt.client.XSLTProcessorApplet.class"
        codebase="../../"
        archive ="xalan.jar,../xml-xerces/xerces.jar"
        height="0"
        width"0">
        <param name="documentURL" value="aboutXalanApplets.xml"/>  <!--default 
setting-->
        <param name="styleURL" value="s1ToHTML.xsl"/> <!--doesn't change-->
      </applet>
    </body>
  </html>
  
  
  
  1.1                  xml-xalan/samples/applet/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/applet/lts3611beac.jpg
  
        <<Binary file>>
  
  
  1.1                  xml-xalan/samples/applet/rabbitwhorn.jpg
  
        <<Binary file>>
  
  
  1.1                  xml-xalan/samples/applet/README.txt
  
  Index: README.txt
  ===================================================================
  This applet transforms XML into HTML. 
  
  It assumes the following:
  
       * xalan.jar is in the Xalan root directory
  
       * xerces.jar is in Xerces root directory 
  
       * The xerces root directory is named xml-xerces and is 
         parallel to the Xalan root).
  
  If these jar files are located elsewhere, you must edit the
  codebase and archive attributes for the applet.
  
  To run the applet, open appletXMLtoHTML.html in IE or Netscape.
  
  
  1.1                  xml-xalan/samples/applet/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/applet/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/applet/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/applet/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 transformToHTML() method, which performs
          the transformation and returns the new document as a
          String.</p>
        </li>
      </ol>
    </s2>
  </s1>
  
  

Reply via email to