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...@apache.org on 2001/02/12 17:41:46 UTC

cvs commit: xml-xalan/c/samples/ApacheModuleXSLT/xslt apachemod.xml apachemod.xsl foo.xml foo.xsl

dleslie     01/02/12 08:41:46

  Added:       c/samples/ApacheModuleXSLT/xslt apachemod.xml apachemod.xsl
                        foo.xml foo.xsl
  Log:
  xml/xsl file pairs used by the sample Apache module.
  
  Revision  Changes    Path
  1.1                  xml-xalan/c/samples/ApacheModuleXSLT/xslt/apachemod.xml
  
  Index: apachemod.xml
  ===================================================================
  <?xml version="1.0"?>
  <s1 title="About ApacheModuleXSLT">
   <s2 title="Using ApacheModuleXSLT to perform XSL transfomrations">
    <p>ApacheModuleXSLT is an Apache Web server module that responds to appropriate URLs by performing transformations and returning the output
    to the client Web browser. The module responds to a request for a given output file (html or txt as configured below) by applying an xsl
    stylesheet file with that name to an xml document with the same name. The requested "output file" is created on the fly and returned as a 
    text stream to the client.</p>
    <p>To use this module, do the following:</p>
    <ol>
      <li>Add LoadModule and (UNIX only) AddModule entries to the Apache configuration file: httpd.conf.<br/><br/>
      Windows: <code>LoadModule mod_xslt xml-xalan\c\Build\Win32\VC6\Release\ApacheModuleXSLT.dll</code><br/><br/>
      UNIX: <code>AddModule mod_xslt.c</code><br/>
      &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;and<br/>
      &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>LoadModule mod_xslt usr/lib/mod_xslt.<ref>xx</ref></code><br/><br/>
      where <ref>xx</ref> is the appropriate library suffix for the UNIX platform.<br/><br/></li>
      <li>Add a &lt;Location&gt; entry to httpd.conf that indicates where xml/xsl file pairs are to be found, and what target file extensions
      to recognize. We suggest the following:<br/><br/>
      <code>&lt;Location /xslt&gt;</code><br/>
      &#160;&#160;<code>AddHandler .html</code><br/>
      &#160;&#160;<code>AddHandler .txt</code><br/>
      <code>&lt;/Location&gt;</code><br/><br/>
      This &lt;Location&gt; element instructs the module to respond to requests for <ref>xxx</ref>.html and <ref>xxx</ref>.txt files in the 
      in the xslt subdirectory (under the document root; see next item) by applying the <ref>xxx</ref>.xsl stylesheet to <ref>xxx</ref>.xml 
      (both in that directory) and returning the transformation result to the browser.<br/><br/>
      Note: It is up to the stylesheet to apply the appropriate xsl:output method to the output. Whether the user specifies html or txt is, of
      itself, immaterial.<br/><br/></li>
      <li>Put xml/xsl file pairs in the &lt;Location&gt; subdirectory (xslt in the example)) under the document root directory specified in httpd.conf by the 
      DocumentRoot and &lt;Directory&gt; settings. Alternatively, you can modify these settings to point to xml-xalan/c/samples/ApacheModuleXSLT,
      which includes an xslt subdirectory with xml/xsl file pairs.<br/><br/></li>
      <li>Start the Apache server.<br/><br/></li>
      <li>From a Web browser, call the module with a URL as follows:<br/>
      <code>http://<ref>serverName</ref>/xslt/<ref>xxx</ref>.html</code><br/>
      where <ref>serverName</ref> is the Apache server (such as www.myServer.com) and <ref>xxx</ref> is the name of an xml/xsl pair of files 
      (such as foo.xml and foo.xsl) in the xslt subdirectory under the DocumentRoot directory.<br/><br/>
      For example,<br/>
      <code>http://www.myServer.com/xslt/foo.html</code><br/>
      instructs ApacheModuleXSLT to apply the foo.xsl stylesheet to the foo.xml XML document (both files in the xslt directory under the 
      Apache DocumentRoot directory) and return the transformation result to the browser.</li>
    </ol>
   </s2>  
  </s1>
  
  
  1.1                  xml-xalan/c/samples/ApacheModuleXSLT/xslt/apachemod.xsl
  
  Index: apachemod.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/c/samples/ApacheModuleXSLT/xslt/foo.xml
  
  Index: foo.xml
  ===================================================================
  <?xml version="1.0"?>
  <s1 title="s1 foo">
    <s2 title="Foo">
      <p>Hello</p>
    </s2>
  </s1>
  
  
  1.1                  xml-xalan/c/samples/ApacheModuleXSLT/xslt/foo.xsl
  
  Index: foo.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:stylesheet>