cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/webapp/samples/sub/stylesheets dynamic-xsp2xsp.xsl error2html.xsl simple-page2html.xsl simple-page2html.xsp simple-samples2html.xsl
Date Mon, 01 Jul 2002 15:11:08 GMT
cziegeler    2002/07/01 08:11:08

  Added:       src/scratchpad/webapp/samples/editor editor.xmap
               src/webapp/samples/sub/stylesheets dynamic-xsp2xsp.xsl
                        error2html.xsl simple-page2html.xsl
                        simple-page2html.xsp simple-samples2html.xsl
  Log:
  Added missing files
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/src/scratchpad/webapp/samples/editor/editor.xmap
  
  Index: editor.xmap
  ===================================================================
  <?xml version="1.0"?>
  
  <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
    <map:components>
      <map:generators default="file">
  
  			<!-- 
  			
  				Define an XPathDirectoryGenerator
  			
  			-->
  			<map:generator
  				name="xpathdirectory"
  				logger="sitemap.generator.xpathdirectory"
  				src="org.apache.cocoon.generation.XPathDirectoryGenerator"
  			/>    
      </map:generators>
      <map:serializers default="html"/>
      <map:transformers default="xalan">
      </map:transformers>
      <map:readers default="resource"/>
      <map:matchers default="wildcard"/>
      <map:selectors default="browser"/>
    </map:components>
  
  	<map:views>
  		<map:view name="content" from-label="content">
  			<map:serialize type="xml"/>
  		</map:view>	
  		<map:view name="agg" from-label="agg">
  			<map:serialize type="xml"/>
  		</map:view>	
  		<map:view name="source" from-label="source">
  			<map:serialize type="xml"/>
  		</map:view>	
  	</map:views>
  
    <map:pipelines>
  		<map:pipeline internal-only="false">
  
  			<!-- 
  				Validating XSLT generator
  			
  				Generates a Schematron Validating XSLT
  				from your schematron-[doctype].xml file
  			-->
  		
  			<map:match pattern="make-validator(*)">
  				<map:generate src="editor/docs/schematron-{1}.xml"/>
  				<map:transform src="editor/stylesheets/schematron-validator2xsl.xsl"/>
  				<map:serialize type="xml"/>
  			</map:match>
  
  		</map:pipeline>
  
  		<map:pipeline internal-only="true">
  			<!-- 
  			
  				Generation pipelines to collect and format the appropriate content based on the requested
behaviour and sub-editor
  				
  				-->
  
  			<!-- 
  				Directory Listing
  				
  				Uses the XPathDirectoryGenerator to extract the 'title' of each document
  				This one removes any filename from the path, (which is a PIA to do in XSL!)
  				Enforces using 'docs' folder of the main project as the root. 
  			-->
  			<map:match pattern="content-dir(*,**/*)">
  				<map:generate type="xpathdirectory" src="docs{2}/#/page/title"/>						
  				<map:transform src="editor/stylesheets/dir2editor.xsl">
  					<map:parameter name="behaviour" value="dir"/>
  					<map:parameter name="sub" value="{1}"/>
  					<map:parameter name="target" value="{2}/"/>
  				</map:transform>
  				<map:serialize type="xml"/>								
  			</map:match>
  
  			<!-- 
  				New
  				
  				Start a new document from a template
  			-->
  			<map:match pattern="content-new(*,**)">
  				<map:generate src="editor/docs/template.xml"/>	<!-- get a template -->
  				<map:transform src="editor/stylesheets/file2editor.xsl">
  					<map:parameter name="behaviour" value="new"/>
  					<map:parameter name="sub" value="{1}"/>
  					<map:parameter name="target" value="{2}"/>
  				</map:transform>
  				<map:serialize type="xml"/>								
  			</map:match>
  		
  			<!-- 
  				Put
  				
  				Create a Document out of a Request
  				save it if ther are no validation errors
  			-->
  			<map:match pattern="content-put(*,**)">
  				<map:generate src="cocoon:/request-put({1})"/>
  				<map:transform src="cocoon:/make-validator(page)"/>
  				<map:transform src="editor/stylesheets/validationFilter.xsl"/>
  				<map:transform src="editor/stylesheets/editor2writer.xsl">
  					<map:parameter name="base" value="docs"/>
  				</map:transform>
  				<map:transform type="write-source"/>
  				<map:serialize type="xml"/>
  			</map:match>
  
  			<!-- 
  				Pre
  				
  				Create a Preview Document out of a Request
  				validate it
  			-->
  			<map:match pattern="content-pre(*,**)">
  				<map:generate src="cocoon:/request-pre({1})"/>
  				<map:transform src="cocoon:/make-validator(page)"/>
  				<map:transform src="editor/stylesheets/validationFilter.xsl"/>
  				<map:serialize type="xml"/>
  			</map:match>
  
  			<!-- 
  				Get or See
  				
  				Makes a Document from Source
  				
  				Enforces using 'docs' folder of the main project as the root. 
  
  				NB. Do not put a slash at the end of the root directory for the generator, 
  				the target-path already has the correct ones 
  			
  			-->
  			<map:match pattern="content-*(*,**)">
  				<map:generate src="docs{3}"/>
  				<map:transform src="editor/stylesheets/file2editor.xsl">
  					<map:parameter name="behaviour" value="{1}"/>
  					<map:parameter name="sub" value="{2}"/>
  					<map:parameter name="target" value="{3}"/>
  				</map:transform>
  				<map:serialize type="xml"/>								
  			</map:match>
  		
  		
  		
  		</map:pipeline>
  
  		<map:pipeline internal-only="true">
  			<!-- 
  			
  				Generation pipelines to create a new Document from Request Data
  				
  				-->
  
  			<!-- 
  			
  				Alpha Editor, using the StreamGenerator
  				
  				-->
  			<map:match pattern="request-*(alpha)">
  				<map:act type="request">
  					<map:parameter name="parameters" value="true"/>
  					<map:generate type="stream">
  						<map:parameter name="form-name" value="xml-field"/>
  					</map:generate>
  					<map:transform src="editor/stylesheets/stream2editor.xsl">
  						<map:parameter name="sub" value="alpha"/>
  						<map:parameter name="target" value="{target}"/>
  						<map:parameter name="behaviour" value="{../1}"/>
  					</map:transform>
  					<map:serialize type="xml"/>
  				</map:act>
  			</map:match>
  
  			<!-- 
  			
  				Bravo Editor, using the RequestGenerator
  				
  				-->
  			<map:match pattern="request-*(bravo)">
  				<map:generate type="request"/>
  				<map:transform src="editor/stylesheets/request2editor.xsl">
  					<map:parameter name="sub" value="bravo"/>
  					<map:parameter name="behaviour" value="{1}"/>
  				</map:transform>
  				<map:serialize type="xml"/>								
  			</map:match>
  
  		</map:pipeline>	
  		
  		<map:pipeline>	
  		
  			<!-- the default page -->
  			<map:match pattern="">
  				<map:redirect-to uri="welcome"/>
  			</map:match>
  			
  			<map:match pattern="/">
  				<map:redirect-to uri="welcome"/>
  			</map:match>
  			
  			<map:match pattern="welcome">
  				<map:generate src="editor/docs/welcome.xml"/>
  				<map:transform src="editor/stylesheets/simple-page2html.xsl"/>
  				<map:serialize type="html"/>					
  			</map:match>
  
  			<!-- directory images -->
  			<map:match pattern="**image/*.gif">
  				<map:read src="editor/images/{2}.gif" mime-type="image/gif"/>
  			</map:match>
  
  			<!-- css -->
  			<map:match pattern="**style">
  				<map:read mime-type="text/css" src="editor/docs/slash-edit.css"/>
  			</map:match>
  
  
  			<!-- 
  				
  				General purpose behaviour pipeline 
      		Retrieves a page as a form or a view, or retrieves a directory listing
      		
      		get(sub-editor-name)/path/to/file						- get a document for editing in a form
      		see(sub-editor-name)/path/to/file						- see a document with the editor
       		new(sub-editor-name)/path/to/file						- create a new document
     			put(sub-editor-name)												- save a modified document from a form submission
     			dir(sub-editor-name)/path/to/directory/			- show a directory listing
     			pre(sub-editor-name)/path/to/file						- preview your changes
      		
      	 -->
  			<map:match pattern="*(*)**">
  				<map:aggregate element="slash-edit" label="agg">
  					<map:part src="editor/docs/{2}-config.xml"/>
  					<map:part src="cocoon:/content-{1}({2},{3})"/>
  				</map:aggregate>
  				<map:transform src="editor/stylesheets/editor-page2html.xsl"/>
  				<map:serialize type="xhtml"/>
  			</map:match>
  
  			<!-- generic error handlers -->
  			<map:handle-errors>
  				<map:transform src="context://stylesheets/system/error2html.xsl"/>
  				<map:serialize status-code="500"/>
  			</map:handle-errors>
  			
  			<map:handle-errors type="404">
  				<map:transform src="context://stylesheets/system/error2html.xsl"/>
  				<map:serialize/>
  			</map:handle-errors>
  		
  		</map:pipeline>
  
    </map:pipelines>
  </map:sitemap>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/sub/stylesheets/dynamic-xsp2xsp.xsl
  
  Index: dynamic-xsp2xsp.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- CVS: $Id: dynamic-xsp2xsp.xsl,v 1.1 2002/07/01 15:11:08 cziegeler Exp $ -->
  
  <xsl:stylesheet version="1.0" 
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns:xsp="http://apache.org/xsp"
                  xmlns:xsp-request="http://apache.org/xsp/request/2.0">
  
    <xsl:template match="*[namespace-uri() = 'urn:xsp']">
      <xsl:element name="xsp:{local-name()}">
        <xsl:for-each select="@*">
          <xsl:attribute name="{name(.)}">
            <xsl:value-of select="."/>
          </xsl:attribute>
        </xsl:for-each>
  
        <xsl:apply-templates select="node()"/>
      </xsl:element>
    </xsl:template>
  
    <xsl:template match="*[namespace-uri() = 'urn:xsp-request']">
      <xsl:element name="xsp-request:{local-name()}">
        <xsl:for-each select="@*">
          <xsl:attribute name="{name(.)}">
            <xsl:value-of select="."/>
          </xsl:attribute>
        </xsl:for-each>
  
        <xsl:apply-templates select="node()"/>
      </xsl:element>
    </xsl:template>
  
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
    </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/sub/stylesheets/error2html.xsl
  
  Index: error2html.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- CVS: $Id: error2html.xsl,v 1.1 2002/07/01 15:11:08 cziegeler Exp $ -->
  
  <html xmlns:error="http://apache.org/cocoon/error/2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xsl:version="1.0">
    <head>
      <title>Requested resource is not found</title>
    </head>
    <body bgcolor="#ffffff">
      <p>
        <font face="Verdana" size="+2">Requested resource is not found</font>
      </p>
      <p>
        <font face="Verdana">
          Error occured during request processing:
          <b><xsl:value-of select="error:notify/error:message"/></b>
        </font>
      </p>
      <br/>
      <font face="Verdana" size="-1">The corresponding exception stacktrace:</font>
      <pre>
        <xsl:value-of select="translate(error:notify/error:extra[2],'&#13;',' ')"/>
      </pre>
      <font face="Verdana" size="-2">
        This special error layout is specified in the sub sitemap.
      </font>
    </body>
  </html>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/sub/stylesheets/simple-page2html.xsl
  
  Index: simple-page2html.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- CVS: $Id: simple-page2html.xsl,v 1.1 2002/07/01 15:11:08 cziegeler Exp $ -->
  
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <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:apply-templates/>
     </h2>
    </xsl:template>
  
    <xsl:template match="para">
     <p align="left">
      <i><xsl:apply-templates/></i>
     </p>
     <xsl:if test="not(following-sibling::para)">
       <p align="left"><i>Notes from the stylesheet:<br/>
         Page above was processed by static XSL stylesheet.<br/>
         My source could be found in the file 
         <b>cocoon/sub/stylesheets/simple-page2html.xsl</b>.<br/>
         I know nothing about the environment which is using me.
         </i>
       </p>
     </xsl:if>
    </xsl:template>
  
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
    </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/sub/stylesheets/simple-page2html.xsp
  
  Index: simple-page2html.xsp
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- CVS: $Id: simple-page2html.xsp,v 1.1 2002/07/01 15:11:08 cziegeler Exp $ -->
  
  <xsp:page language="java"
            xmlns:xsp="http://apache.org/xsp"
            xmlns:xsp-request="http://apache.org/xsp/request/2.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:stylesheet version="1.0">
  
    <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:apply-templates/>
     </h2>
    </xsl:template>
  
    <xsl:template match="para">
     <p align="left">
      <i>
       <xsl:apply-templates/>
      </i>
     </p>
     <xsl:if test="not(following-sibling::para)">
       <p align="left">
         <i>Note from the stylesheet:<br/>
         Page above was processed by dynamic XSL stylesheet
         generated by XSP (eXtensible Server Pages).<br/>
         My source could be found in the file
         <b>cocoon/sub/stylesheets/simple-page2html.xsp</b>.<br/>
         I know that I was executed at <b><xsp:expr>new Date()</xsp:expr></b>
         by <b><xsp:expr>Constants.COMPLETE_NAME</xsp:expr></b>.
         </i>
       </p>
     </xsl:if>
    </xsl:template>
  
    <xsl:template match="@*|node()" priority="-1">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
    </xsl:template>
  </xsl:stylesheet>
  
  </xsp:page>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/sub/stylesheets/simple-samples2html.xsl
  
  Index: simple-samples2html.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- CVS: $Id: simple-samples2html.xsl,v 1.1 2002/07/01 15:11:08 cziegeler Exp $ -->
  
  <!-- Author: Nicola Ken Barozzi "barozzi@nicolaken.com" -->
  <!-- Author: Vadim Gritsenko "vgritsenko@apache.org" -->
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink">
  
   <xsl:template match="/">
    <html>
     <head>
      <title>Apache Cocoon @version@</title>
     </head>
     <body bgcolor="#ffffff" link="#0086b2" vlink="#00698c" alink="#743e75">
      <table border="0" cellspacing="2" cellpadding="2" align="center" width="100%">
       <tr>
        <td colspan="3" align="center"><font face="arial,helvetica,sanserif" color="#000000">The
Apache Software Foundation is proud to present...</font></td>
       </tr>
       <tr>
        <td width="30%"></td>
        <td width="40%" align="center"><img border="0" src="../images/cocoon.gif"/></td>
        <td width="30%" align="center"><font face="arial,helvetica,sanserif" color="#000000"><b>version
@version@</b></font></td>
       </tr>
      </table>
  
      <xsl:apply-templates/>
  
      <p align="center">
       <font size="-1">
        Copyright &#169; @year@ <a href="http://www.apache.org">The Apache Software
Foundation</a>.<br/>
        All rights reserved.
       </font>
      </p>
     </body>
    </html>
   </xsl:template>
  
   <xsl:template match="samples">
    <xsl:variable name="all-samples" select="count(group/sample)"/>
    <xsl:variable name="half-samples" select="round($all-samples div 2)"/>
  
    <xsl:variable name="half">
      <xsl:for-each select="group">
        <xsl:if test="position() &lt; last() and position() &gt; 1">
          <xsl:variable name="group-position" select="position()"/>
          <xsl:variable name="prev-sample" select="count(../group[position() &lt;=
$group-position - 1]/sample)"/>
          <xsl:variable name="curr-sample" select="count(../group[position() &lt;=
$group-position]/sample)"/>
          <xsl:variable name="next-sample" select="count(../group[position() &lt;=
$group-position + 1]/sample)"/>
          <xsl:variable name="prev-deviation">
            <xsl:choose>
              <xsl:when test="$prev-sample &gt; $half-samples">
                <xsl:value-of select="$prev-sample - $half-samples"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$half-samples - $prev-sample"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:variable name="curr-deviation">
            <xsl:choose>
              <xsl:when test="$curr-sample &gt; $half-samples">
                <xsl:value-of select="$curr-sample - $half-samples"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$half-samples - $curr-sample"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:variable name="next-deviation">
            <xsl:choose>
              <xsl:when test="$next-sample &gt; $half-samples">
                <xsl:value-of select="$next-sample - $half-samples"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$half-samples - $next-sample"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:if test="$prev-deviation &gt;= $curr-deviation and $curr-deviation &lt;=
$next-deviation">
            <xsl:value-of select="$group-position"/>
          </xsl:if>
        </xsl:if>
      </xsl:for-each>
    </xsl:variable>
  
    <table width="100%">
     <tr>
      <td width="50%" valign="top">
       <xsl:for-each select="group">  
        <xsl:variable name="group-position" select="position()"/>
  
        <xsl:choose>
         <xsl:when test="$group-position &lt;= $half">
         <table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0" width="97%">
          <tbody>
           <tr>
            <td>
  
          <table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2" align="center"
width="100%">
           <tr>
            <td bgcolor="#0086b2" width="100%" align="left">
             <font size="+1" face="arial,helvetica,sanserif" color="#ffffff"><xsl:value-of
select="@name"/></font>
            </td>
           </tr>
           <tr>
            <td width="100%" bgcolor="#ffffff" align="left">
             <table bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="2"  width="100%"
align="center">
              <xsl:apply-templates/>
             </table>
            </td>
           </tr>
          </table>
          
            </td>
           </tr>        
           </tbody>
          </table>
          
          <br/>
         </xsl:when>
         <xsl:otherwise></xsl:otherwise>
        </xsl:choose>
       </xsl:for-each>
      </td>
      <td valign="top">
       <xsl:for-each select="group">  <!-- [position()<=$half] -->
        <xsl:variable name="group-position" select="position()"/>
  
        <xsl:choose>
         <xsl:when test="$group-position &gt; $half">
         <table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0" width="97%">
          <tbody>
           <tr>
            <td>       
          <table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2" align="center"
width="100%">
           <tr>
            <td bgcolor="#0086b2" width="100%" align="left">
             <font size="+1" face="arial,helvetica,sanserif" color="#ffffff"><xsl:value-of
select="@name"/></font>
            </td>
           </tr>
           <tr>
            <td width="100%" bgcolor="#ffffff" align="left">
             <table bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="2"  width="100%"
align="center">
              <xsl:apply-templates/>
             </table>
            </td>
           </tr>
          </table>
           </td>
           </tr>        
           </tbody>
          </table>
          <br/>
         </xsl:when>
         <xsl:otherwise></xsl:otherwise>
        </xsl:choose>
       </xsl:for-each>
      </td>
     </tr>
    </table>
   </xsl:template>
   
   <xsl:template match="sample">
    <tr>
     <td width="100%" bgcolor="#ffffff" align="left">
      <font size="+0" face="arial,helvetica,sanserif" color="#000000">    
        <a href="{@href}"><xsl:value-of select="@name"/></a><xsl:text>
- </xsl:text>
        <xsl:value-of select="."/>
      </font>
     </td>
    </tr>
   </xsl:template>
   
  </xsl:stylesheet>
  
  
  

----------------------------------------------------------------------
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