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 response.xsl
Date Fri, 07 Jan 2000 13:21:11 GMT
ricardo     00/01/07 05:21:11

  Modified:    src/org/apache/cocoon/processor/xsp/library/java
                        response.xsl
  Log:
  1.3:Made compatible with XT XSLT Transformer
  
  Revision  Changes    Path
  1.3       +93 -124   xml-cocoon/src/org/apache/cocoon/processor/xsp/library/java/response.xsl
  
  Index: response.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xsp/library/java/response.xsl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- response.xsl	2000/01/06 17:56:45	1.2
  +++ response.xsl	2000/01/07 13:21:11	1.3
  @@ -1,7 +1,60 @@
   <?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:response="http://apache.org/DTD/XSP/response"
   >
  @@ -9,51 +62,8 @@
   
     <!-- 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>
  -
  -
  -  <!-- response.getCharacterEncoding -->
     <xsl:template match="response:get-character-encoding">
  -    <!-- Ensure attribute "as" has a value -->
       <xsl:variable name="as">
         <xsl:call-template name="value-for-as">
           <xsl:with-param name="default" select="'string'"/>
  @@ -73,9 +83,7 @@
     </xsl:template>
   
   
  -  <!-- response.getLocale -->
     <xsl:template match="response:get-locale">
  -    <!-- Ensure attribute "as" has a value -->
       <xsl:variable name="as">
         <xsl:call-template name="value-for-as">
           <xsl:with-param name="default" select="'object'"/>
  @@ -97,16 +105,11 @@
       </xsp:expr>
     </xsl:template>
   
  -  <!-- response.setContentType -->
     <xsl:template match="response:set-content-type">
  -    <!-- Get "type" parameter as either attribute or nested element -->
       <xsl:variable name="type">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@type">"<xsl:value-of select="@type"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="type">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="type"/>
             </xsl:call-template>
  @@ -123,7 +126,6 @@
       </xsp:logic>
     </xsl:template>
   
  -  <!-- response.setLocale -->
     <xsl:template match="response:set-locale">
       <xsp:logic>
         response.setLocale(
  @@ -135,34 +137,26 @@
     </xsl:template>
   
   
  -  <!-- *** HttpServletResponse *** -->
   
  -  <!-- response.addCookie -->
     <xsl:template match="response:add-cookie">
       <xsp:logic>
         response.addCookie(
           <xsl:call-template name="get-nested-content">
  -          <xsl:with-param name="content" select="*[1]"/>
  +          <xsl:with-param name="content" select="."/>
           </xsl:call-template>
         );
       </xsp:logic>
     </xsl:template>
   
  -  <!-- response.addDateHeader -->
     <xsl:template match="response:add-date-header">
  -    <!-- Get "name" parameter as either attribute or nested element -->
       <xsl:variable name="name">
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
   
  -    <!-- Get "date" parameter as either attribute or nested element -->
       <xsl:variable name="date">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@date">"<xsl:value-of select="@date"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="date">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="date"/>
             </xsl:call-template>
  @@ -170,15 +164,10 @@
         </xsl:choose>
       </xsl:variable>
   
  -    <!-- Get "format" parameter as either attribute or nested element -->
  -    <!-- This optional parameter only applies for dates expressed as String -->
       <xsl:variable name="format">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@format">"<xsl:value-of select="@format"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="format">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="format"/>
             </xsl:call-template>
  @@ -213,21 +202,15 @@
       </xsp:logic>
     </xsl:template>
   
  -  <!-- response.addHeader -->
     <xsl:template match="response:add-header">
  -    <!-- Get "name" parameter as either attribute or nested element -->
       <xsl:variable name="name">
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
   
  -    <!-- Get "value" parameter as either attribute or nested element -->
       <xsl:variable name="value">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="value">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="value"/>
             </xsl:call-template>
  @@ -243,21 +226,15 @@
       </xsp:logic>
     </xsl:template>
   
  -  <!-- response.addIntHeader -->
     <xsl:template match="response:add-header">
  -    <!-- Get "name" parameter as either attribute or nested element -->
       <xsl:variable name="name">
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
   
  -    <!-- Get "value" parameter as either attribute or nested element -->
       <xsl:variable name="value">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="value">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="value"/>
             </xsl:call-template>
  @@ -275,14 +252,11 @@
       </xsp:logic>
     </xsl:template>
   
  -  <!-- response.containsHeader -->
     <xsl:template match="response:contains-header">
  -    <!-- 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="'boolean'"/>
  @@ -314,16 +288,11 @@
       </xsp:expr>
     </xsl:template>
   
  -  <!-- response.encodeRedirectURL -->
     <xsl:template match="response:encode-redirect-url">
  -    <!-- Get "url" parameter as either attribute or nested element -->
       <xsl:variable name="url">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@url">"<xsl:value-of select="@url"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="url">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="url"/>
             </xsl:call-template>
  @@ -331,7 +300,6 @@
         </xsl:choose>
       </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'"/>
  @@ -356,16 +324,11 @@
       </xsp:expr>
     </xsl:template>
   
  -  <!-- response.encodeURL -->
     <xsl:template match="response:encode-url">
  -    <!-- Get "url" parameter as either attribute or nested element -->
       <xsl:variable name="url">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@url">"<xsl:value-of select="@url"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="url">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="url"/>
             </xsl:call-template>
  @@ -373,14 +336,13 @@
         </xsl:choose>
       </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'"/>
         </xsl:call-template>
       </xsl:variable>
   
  -    <xsp:logic>
  +    <xsp:expr>
         <xsl:choose>
           <xsl:when test="$as = 'node'">
             XSPResponseLibrary.encodeURL(
  @@ -391,23 +353,18 @@
           </xsl:when>
           <xsl:when test="$as = 'string'">
             response.encodeURL(
  -            String.valueOf(<xsl:copy-of select="$url"/>),
  +            String.valueOf(<xsl:copy-of select="$url"/>)
             )
           </xsl:when>
         </xsl:choose>
  -    </xsp:logic>
  +    </xsp:expr>
     </xsl:template>
   
  -  <!-- response.sendRedirect -->
     <xsl:template match="response:send-redirect">
  -    <!-- Get "location" parameter as either attribute or nested element -->
       <xsl:variable name="location">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@location">"<xsl:value-of select="@location"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="location">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="location"/>
             </xsl:call-template>
  @@ -422,21 +379,15 @@
       </xsp:logic>
     </xsl:template>
   
  -  <!-- response.setDateHeader -->
     <xsl:template match="response:set-date-header">
  -    <!-- Get "name" parameter as either attribute or nested element -->
       <xsl:variable name="name">
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
   
  -    <!-- Get "date" parameter as either attribute or nested element -->
       <xsl:variable name="date">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@date">"<xsl:value-of select="@date"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="date">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="date"/>
             </xsl:call-template>
  @@ -444,15 +395,10 @@
         </xsl:choose>
       </xsl:variable>
   
  -    <!-- Get "format" parameter as either attribute or nested element -->
  -    <!-- This optional parameter only applies for dates expressed as String -->
       <xsl:variable name="format">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@format">"<xsl:value-of select="@format"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="format">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="format"/>
             </xsl:call-template>
  @@ -487,21 +433,15 @@
       </xsp:logic>
     </xsl:template>
   
  -  <!-- response.setHeader -->
     <xsl:template match="response:set-header">
  -    <!-- Get "name" parameter as either attribute or nested element -->
       <xsl:variable name="name">
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
   
  -    <!-- Get "value" parameter as either attribute or nested element -->
       <xsl:variable name="value">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="value">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="value"/>
             </xsl:call-template>
  @@ -517,21 +457,15 @@
       </xsp:logic>
     </xsl:template>
   
  -  <!-- response.setIntHeader -->
     <xsl:template match="response:set-header">
  -    <!-- Get "name" parameter as either attribute or nested element -->
       <xsl:variable name="name">
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
   
  -    <!-- Get "value" parameter as either attribute or nested element -->
       <xsl:variable name="value">
         <xsl:choose>
  -        <!-- As attribute (String constant) -->
           <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
  -        <!-- As nested (presumably dynamic) element -->
           <xsl:when test="value">
  -          <!-- Recursively evaluate nested expression -->
             <xsl:call-template name="get-nested-content">
               <xsl:with-param name="content" select="value"/>
             </xsl:call-template>
  @@ -547,6 +481,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