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

  Modified:    src/org/apache/cocoon/processor/xsp/library/java global.xsl
  Log:
  1.2:Made compatible with XT XSLT Transformer
  
  Revision  Changes    Path
  1.2       +145 -27   xml-cocoon/src/org/apache/cocoon/processor/xsp/library/java/global.xsl
  
  Index: global.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xsp/library/java/global.xsl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- global.xsl	2000/01/05 19:38:40	1.1
  +++ global.xsl	2000/01/07 13:21:03	1.2
  @@ -1,23 +1,152 @@
   <?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:global="http://apache.org/DTD/XSP/global"
   >
  -  <!-- Default copy-over's -->
  -  <xsl:template match="@*|node()" priority="-1">
  -    <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
  +  <!-- *** ServletResponse Templates *** -->
  +
  +  <!-- Import Global XSP Templates -->
  +  <!-- <xsl:import href="base-library.xsl"/> -->
  +
  +  <xsl:template match="global:get-attribute">
  +    <xsl:variable name="name">
  +      <xsl:call-template name="value-for-name"/>
  +    </xsl:variable>
  +
  +    <xsl:variable name="as">
  +      <xsl:call-template name="value-for-as">
  +        <xsl:with-param name="default" select="'string'"/>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsp:expr>
  +      <xsl:choose>
  +        <xsl:when test="$as = 'node'">
  +          XSPGlobalLibrary.getAttribute(
  +            global,
  +            String.valueOf(<xsl:copy-of select="$name"/>),
  +            document
  +          )
  +        </xsl:when>
  +        <xsl:when test="$as = 'string'">
  +          XSPGlobalLibrary.getAttribute(
  +            global,
  +            String.valueOf(<xsl:copy-of select="$name"/>)
  +          )
  +        </xsl:when>
  +      </xsl:choose>
  +    </xsp:expr>
  +  </xsl:template>
  +
  +  <xsl:template match="global:get-attribute-names">
  +    <xsl:variable name="as">
  +      <xsl:call-template name="value-for-as">
  +        <xsl:with-param name="default" select="'array'"/>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsp:expr>
  +      <xsl:choose>
  +        <xsl:when test="$as = 'node'">
  +          XSPGlobalLibrary.getAttributeNames(global, document)
  +        </xsl:when>
  +        <xsl:when test="$as = 'array'">
  +          XSPGlobalLibrary.getAttributeNames(global)
  +        </xsl:when>
  +      </xsl:choose>
  +    </xsp:expr>
     </xsl:template>
   
  -  <!-- *** Utility Templates *** -->
  -  <!-- Retrieve "name" parameter as either attribute or element -->
  +  <xsl:template match="global:remove-attribute">
  +    <xsl:variable name="name">
  +      <xsl:call-template name="value-for-name"/>
  +    </xsl:variable>
  +
  +    <xsp:logic>
  +      global.removeAttribute(
  +        String.valueOf(<xsl:copy-of select="$name"/>)
  +      );
  +    </xsp:logic>
  +  </xsl:template>
  +
  +  <xsl:template match="global:set-attribute">
  +    <xsl:variable name="name">
  +      <xsl:call-template name="value-for-name"/>
  +    </xsl:variable>
  +
  +    <xsl:variable name="content">
  +      <xsl:call-template name="get-nested-content">
  +        <xsl:with-param name="content" select="."/>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsp:logic>
  +      global.setAttribute(
  +        String.valueOf(<xsl:copy-of select="$name"/>),
  +        <xsl:copy-of select="$content"/>
  +      );
  +    </xsp:logic>
  +  </xsl:template>
  +
     <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>
  @@ -25,39 +154,28 @@
       </xsl:choose>
     </xsl:template>
   
  -  <!-- Return nested element content as expression or constant -->
     <xsl:template name="get-nested-content">
  +    <xsl:param name="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:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
       </xsl:choose>
     </xsl:template>
   
  -  <!-- Ensure attribute "as" has a value -->
     <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>
  -
  -
  -  <!-- Default xsp:page preprocessing -->
  -  <!--
  -  <xsl:template match="xsp:page">
  -    <xsp:page>
  -      <xsl:copy>
  -        <xsl:apply-templates select="@*"/>
  -      </xsl:copy>
  -
  -      <xsl:apply-templates/>
   
  -    </xsp:page>
  +  <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