cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rica...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/processor/xsp/library/java session.xsl
Date Fri, 07 Jan 2000 13:21:14 GMT
ricardo     00/01/07 05:21:14

  Modified:    src/org/apache/cocoon/processor/xsp/library/java session.xsl
  Log:
  1.3:Made compatible with XT XSLT Transformer
  
  Revision  Changes    Path
  1.3       +93 -73    xml-cocoon/src/org/apache/cocoon/processor/xsp/library/java/session.xsl
  
  Index: session.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xsp/library/java/session.xsl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- session.xsl	2000/01/06 17:56:45	1.2
  +++ session.xsl	2000/01/07 13:21:14	1.3
  @@ -1,64 +1,73 @@
   <?xml version="1.0"?>
  +<!--
   
  + ============================================================================
  +                   The Apache Software License, Version 1.1
  + ============================================================================
  +
  +    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  +
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  +
  + 1. Redistributions of  source code must  retain the above copyright  notice,
  +    this list of conditions and the following disclaimer.
  +
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +    this list of conditions and the following disclaimer in the documentation
  +    and/or other materials provided with the distribution.
  +
  + 3. The end-user documentation included with the redistribution, if any, must
  +    include  the following  acknowledgment:  "This product includes  software
  +    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +    Alternately, this  acknowledgment may  appear in the software itself,  if
  +    and wherever such third-party acknowledgments normally appear.
  +
  + 4. The names "Cocoon" and  "Apache Software Foundation"  must not be used to
  +    endorse  or promote  products derived  from this  software without  prior
  +    written permission. For written permission, please contact
  +    apache@apache.org.
  +
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +    "Apache" appear  in their name,  without prior written permission  of the
  +    Apache Software Foundation.
  +
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  +
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software  Foundation and was  originally created by
  + Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
  + Software Foundation, please see <http://www.apache.org/>.
  +
  +-->
  +
  +<!-- written by Ricardo Rocha "ricardo@apache.org" -->
  +
  +
   <xsl:stylesheet
  -  xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
  +  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xsp="http://apache.org/DTD/XSP/Layer1"
     xmlns:session="http://apache.org/DTD/XSP/session"
   >
  -  <!-- *** ServletSession Templates *** -->
  +  <!-- *** ServletResponse Templates *** -->
   
     <!-- Import Global XSP Templates -->
     <!-- <xsl:import href="base-library.xsl"/> -->
  -  <!-- Default copy-over's -->
  -  <xsl:template match="@*|node()" priority="-1">
  -    <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
  -  </xsl:template>
  -
  -  <!-- *** Utility Templates *** -->
  -  <!-- Retrieve "name" parameter as either attribute or element -->
  -  <xsl:template name="value-for-name">
  -    <xsl:choose>
  -      <!-- As attribute (String constant) -->
  -      <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
  -      <!-- As nested (presumably dynamic) element -->
  -      <xsl:when test="name">
  -        <!-- Recursively evaluate nested expression -->
  -        <xsl:call-template name="get-nested-content">
  -          <xsl:with-param name="content" select="name"/>
  -        </xsl:call-template>
  -      </xsl:when>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <!-- Return nested element content as expression or constant -->
  -  <xsl:template name="get-nested-content">
  -    <xsl:choose>
  -      <!-- Nested element -->
  -      <xsl:when test="$content/*">
  -        <xsl:apply-templates select="$content/*"/>
  -      </xsl:when>
  -      <!-- Plain Text -->
  -      <xsl:otherwise>"<xsl:value-of select="normalize($content)"/>"</xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <!-- Ensure attribute "as" has a value -->
  -  <xsl:template name="value-for-as">
  -    <xsl:choose>
  -      <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
  -      <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
   
  -
  -  <!-- session.getAttribute -->
     <xsl:template match="session:get-attribute">
  -    <!-- Get "name" parameter as either attribute or nested element -->
       <xsl:variable name="name">
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
   
  -    <!-- Ensure attribute "as" has a value -->
       <xsl:variable name="as">
         <xsl:call-template name="value-for-as">
           <xsl:with-param name="default" select="'string'"/>
  @@ -84,9 +93,7 @@
       </xsp:expr>
     </xsl:template>
   
  -  <!-- session.getAttributeNames -->
     <xsl:template match="session:get-attribute-names">
  -    <!-- Ensure attribute "as" has a value -->
       <xsl:variable name="as">
         <xsl:call-template name="value-for-as">
           <xsl:with-param name="default" select="'array'"/>
  @@ -105,9 +112,7 @@
       </xsp:expr>
     </xsl:template>
   
  -  <!-- session.getCreationTime -->
     <xsl:template match="session:get-creation-time">
  -    <!-- Ensure attribute "as" has a value -->
       <xsl:variable name="as">
         <xsl:call-template name="value-for-as">
           <xsl:with-param name="default" select="'long'"/>
  @@ -132,9 +137,7 @@
       </xsp:expr>
     </xsl:template>
   
  -  <!-- session.getId -->
     <xsl:template match="session:get-id">
  -    <!-- Ensure attribute "as" has a value -->
       <xsl:variable name="as">
         <xsl:call-template name="value-for-as">
           <xsl:with-param name="default" select="'string'"/>
  @@ -156,9 +159,7 @@
       </xsp:expr>
     </xsl:template>
   
  -  <!-- session.getLastAccessedTime -->
     <xsl:template match="session:get-last-accessed-time">
  -    <!-- Ensure attribute "as" has a value -->
       <xsl:variable name="as">
         <xsl:call-template name="value-for-as">
           <xsl:with-param name="default" select="'long'"/>
  @@ -183,9 +184,7 @@
       </xsp:expr>
     </xsl:template>
   
  -  <!-- session.getMaxInactiveInterval -->
     <xsl:template match="session:get-max-inactive-interval">
  -    <!-- Ensure attribute "as" has a value -->
       <xsl:variable name="as">
         <xsl:call-template name="value-for-as">
           <xsl:with-param name="default" select="'int'"/>
  @@ -210,16 +209,13 @@
       </xsp:expr>
     </xsl:template>
   
  -  <!-- session.invalidate -->
     <xsl:template match="session:invalidate">
       <xsp:logic>
         session.invalidate()
       </xsp:logic>
     </xsl:template>
   
  -  <!-- session.isNew -->
     <xsl:template match="session:is-new">
  -    <!-- Ensure attribute "as" has a value -->
       <xsl:variable name="as">
         <xsl:call-template name="value-for-as">
           <xsl:with-param name="default" select="'boolean'"/>
  @@ -244,9 +240,7 @@
       </xsp:expr>
     </xsl:template>
   
  -  <!-- session.removeAttribute -->
     <xsl:template match="session:remove-attribute">
  -    <!-- Get "name" parameter as either attribute or nested element -->
       <xsl:variable name="name">
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
  @@ -258,40 +252,30 @@
       </xsp:logic>
     </xsl:template>
   
  -  <!-- session.setAttribute -->
     <xsl:template match="session:set-attribute">
  -    <!-- Get "name" parameter as either attribute or nested element -->
       <xsl:variable name="name">
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
   
  -    <!-- Recursively evaluate nested attribute value -->
       <xsl:variable name="content">
         <xsl:call-template name="get-nested-content">
  -        <xsl:with-param name="content">
  -          <content><xsl:apply-templates/></content>
  -        </xsl:with-param>
  +        <xsl:with-param name="content" select="."/>
         </xsl:call-template>
       </xsl:variable>
   
       <xsp:logic>
  -      session.setAttribute(
  +      session.putValue(
           String.valueOf(<xsl:copy-of select="$name"/>),
           <xsl:copy-of select="$content"/>
         );
       </xsp:logic>
     </xsl:template>
   
  -  <!-- session.setInactiveInterval -->
     <xsl:template match="session:set-max-inactive-interval">
  -    <!-- Get "interval" parameter as either attribute or nested element -->
       <xsl:variable name="interval">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@interval">"<xsl:value-of select="@interval"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="interval">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="interval"/>
             </xsl:call-template>
  @@ -309,5 +293,41 @@
         );
       </xsp:logic>
     </xsl:template>
  +
  +  <xsl:template name="value-for-name">
  +    <xsl:choose>
  +      <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
  +      <xsl:when test="name">
  +        <xsl:call-template name="get-nested-content">
  +          <xsl:with-param name="content" select="name"/>
  +        </xsl:call-template>
  +      </xsl:when>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template name="get-nested-content">
  +    <xsl:param name="content"/>
  +    <xsl:choose>
  +      <xsl:when test="$content/*">
  +        <xsl:apply-templates select="$content/*"/>
  +      </xsl:when>
  +      <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template name="value-for-as">
  +    <xsl:param name="default"/>
  +    <xsl:choose>
  +      <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
  +      <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template match="@*|*|text()|processing-instruction()">
  +    <xsl:copy>
  +      <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
  +    </xsl:copy>
  +  </xsl:template>
  +
   
   </xsl:stylesheet>
  
  
  

Mime
View raw message