cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kpiroum...@apache.org
Subject cvs commit: xml-cocoon2/src/webapp/samples/jsp hello.jsp simple-page2html.xsl sitemap.xmap welcome.jsp
Date Tue, 16 Apr 2002 09:35:49 GMT
kpiroumian    02/04/16 02:35:49

  Added:       src/webapp/samples/jsp hello.jsp simple-page2html.xsl
                        sitemap.xmap welcome.jsp
  Log:
  Refactored JSP samples
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/src/webapp/samples/jsp/hello.jsp
  
  Index: hello.jsp
  ===================================================================
  <%@ page language='java' session='false' %>
  <page>
    <title>Hello</title>
    <content>
      <para>This is my first Cocoon2 page!</para>
  <%    
  out.println("\t<para>With help from JSP on " + new java.util.Date() + "</para>");
  %>
    </content>
  </page>
  
  
  
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/jsp/simple-page2html.xsl
  
  Index: simple-page2html.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <xsl:param name="view-source"/>
  
    <xsl:template match="page">
     <html>
      <head>
       <title>
        <xsl:value-of select="title"/>
       </title>
      </head>
      <body bgcolor="white" alink="red" link="blue" vlink="blue">
       <xsl:apply-templates/>
      </body>
     </html>
    </xsl:template>
  
    <xsl:template match="title">
     <h2 style="color: navy; text-align: center">
        <xsl:if test="not($view-source)">
           <xsl:apply-templates/>
        </xsl:if>     
        <xsl:if test="$view-source">
        <A>
           <xsl:attribute name="HREF">../view-source?filename=/<xsl:value-of select="$view-source"/></xsl:attribute>
   		 <xsl:attribute name="TARGET">_blank</xsl:attribute>
           <xsl:apply-templates/>
        </A>
        </xsl:if>     
     </h2>
    </xsl:template>
  
    <xsl:template match="para">
     <p align="left">
      <i><xsl:apply-templates/></i>
     </p>
    </xsl:template>
  
  
    <xsl:template match="@*|node()" priority="-2"><xsl:copy><xsl:apply-templates
select="@*|node()"/></xsl:copy></xsl:template>
    <xsl:template match="text()" priority="-1"><xsl:value-of select="."/></xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/jsp/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  <?xml version="1.0"?>
  <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  	<!-- =========================== Components ================================ -->
  	<map:components>
  		<map:generators default="file">
  			<!-- JspGenerator is used to get result of a JSP page 
  			then output it as XML (SAX events)
  			-->
  			<map:generator logger="sitemap.generator.jsp" name="jsp"
  				src="org.apache.cocoon.generation.JspGenerator"/>
  		</map:generators>
  		<map:transformers default="xslt"/>
  		<map:readers default="resource">
  			<!-- JSPReader is used to serve direct output from 
  			a JSP page. Note, that JSP result can be non XML  -->
  			<map:reader logger="sitemap.reader.jsp" name="jsp" 
  				src="org.apache.cocoon.reading.JSPReader"/>
  		</map:readers>
  		<map:serializers default="html"/>
  		<map:selectors default="browser"/>
  		<map:matchers default="wildcard"/>
  	</map:components>
  	<!-- =========================== Pipelines ================================= -->
  	<map:pipelines>
  		<map:pipeline>
  			<!-- This works only if TreeProcessor is used -->
  			<map:match pattern="">
  				<map:redirect-to uri="cocoon:/welcome.htm" />
  			</map:match>
  
  			<map:match pattern="*.htm">
  				<map:read type="jsp" src="{1}.jsp" mime-type="text/html" />
  			</map:match>
  
  			<!-- Use this to debug your JSPs -->
  			<map:match pattern="*.xml">
  				<map:generate type="jsp" src="{1}.jsp"/>
  				<map:serialize type="xml"/>
  			</map:match>
  
  			<map:match pattern="*.jsp">
  				<map:generate type="jsp" src="{1}.jsp"/>
  				<map:transform src="style/xslt/simple-page2html.xsl"/>
  				<map:serialize type="html"/>
  			</map:match>
  
  		</map:pipeline>
  	</map:pipelines>
  </map:sitemap>
  <!-- end of file -->
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/jsp/welcome.jsp
  
  Index: welcome.jsp
  ===================================================================
  <%@ page import="java.util.*" %>
  <%
  	response.setHeader("Expires", "0");
  %>
  
  <html>
  
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <title>JSPreader test</title>
  <style type="text/css">
  BODY {background-color: #FFFFFF; color: #000066; font-family: Verdana, Helvetica, Arial;
}
  </style>
  </head>
  
  <body>
  <h3>This is a dynamic output from the JSPReader</h3>
  <h4>Current time: <%=new Date()%></h4>
  <hr noshade size="1">
  <br>
  <table width="75%" border="1" cellspacing="0" cellpadding="5">
    <tr bgcolor="#990000"> 
      <th colspan="2" align="left"><font color="#FFFFFF">JSP Usage Samples</font></th>
    </tr>
    <tr> 
      <td width="25%"><a href="hello.jsp">hello.jsp</a></td>
      <td width="56%">Displays a hello page using JspGenerator to get XML from a 
        JSP then transformes it to HTML using a stylesheet.</td>
    </tr>
    <tr> 
      <td width="25%"><a href="hello.xml">hello.xml</a></td>
      <td width="56%">The same page serialized as XML (without transformation).</td>
    </tr>
    <tr> 
      <td width="25%"><a href="hello.htm">hello.htm</a></td>
      <td width="56%"> 
        <p>The same page serialized as HTML and served by sitemap through the JSPReader.</p>
      </td>
    </tr>
    <tr> 
      <td width="25%"><a href="welcome.htm">welcome.htm</a></td>
      <td width="56%">This page. Direct HTML output from a JSP page served by sitemap

        through the JSPReader.</td>
    </tr>
  </table>
  <p><small><a href=".."><br>
    Back to samples</a></small> </p>
  </body>
  </html>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message