You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by dl...@locus.apache.org on 2000/08/02 20:56:17 UTC

cvs commit: xml-xalan/java/samples/AppletXMLtoHTML README.html appletXMLtoHTML.html client.html foo-s1.xml lts3611beac.jpg rabbitwhorn.jpg s1ToHTML.xsl target.html

dleslie     00/08/02 11:56:17

  Added:       java/samples/AppletXMLtoHTML README.html
                        appletXMLtoHTML.html client.html foo-s1.xml
                        lts3611beac.jpg rabbitwhorn.jpg s1ToHTML.xsl
                        target.html
  Log:
  xalan-j 2.0 sample app.
  
  Revision  Changes    Path
  1.1                  xml-xalan/java/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/java/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/java/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.client.XSLTProcessorApplet.class"
        archive="xerces.jar, xalan.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/java/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/java/samples/AppletXMLtoHTML/lts3611beac.jpg
  
  	<<Binary file>>
  
  
  1.1                  xml-xalan/java/samples/AppletXMLtoHTML/rabbitwhorn.jpg
  
  	<<Binary file>>
  
  
  1.1                  xml-xalan/java/samples/AppletXMLtoHTML/s1ToHTML.xsl
  
  Index: s1ToHTML.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <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="{@href}" target="_top"><xsl:apply-templates/></a>
    </xsl:template>  
  
    <xsl:template match="anchor">
      <a name="{@id}"> </a>
    </xsl:template>
  
    <xsl:template match="img">
      <img src="{@src}" align="right" border="0" vspace="4" hspace="4"/>
    </xsl:template>
    
  </xsl:stylesheet>
  
  
  1.1                  xml-xalan/java/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>