cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/java logicsheet-util.xsl
Date Thu, 17 Apr 2003 20:08:49 GMT
haul        2003/04/17 13:08:49

  Modified:    src/java/org/apache/cocoon/components/language/markup/xsp/java
                        logicsheet-util.xsl
  Log:
  add new named template for nested parameter
  	attribute -> String,
  	:param -> as is,
  	absent -> null
  
  Revision  Changes    Path
  1.2       +51 -2     cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/java/logicsheet-util.xsl
  
  Index: logicsheet-util.xsl
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/java/logicsheet-util.xsl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- logicsheet-util.xsl	9 Mar 2003 00:08:57 -0000	1.1
  +++ logicsheet-util.xsl	17 Apr 2003 20:08:48 -0000	1.2
  @@ -63,6 +63,7 @@
    * be set in the including logicsheet to its namespace URI.
    *
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
  + * @author <a href="mailto:haul@apache.org">Christian Haul</a>
    * @version CVS $Revision$ $Date$
   -->
   
  @@ -274,6 +275,54 @@
           <xsl:apply-templates select="$content/*"/>
         </xsl:when>
         <xsl:otherwise><xsl:value-of select="$content"/></xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +<!--
  +  Get a primitive object when :param is used, for @ a String is returned. Default is also
String.
  +  Without default, primitive value 'null' is returned
  +  @name the name of the parameter
  +  @default the default value
  +  @required true if the parameter is required
  +-->
  +  <xsl:template name="get-ls-parameter">
  +    <xsl:param name="name"/>
  +    <xsl:param name="default"/>
  +    <xsl:param name="required">false</xsl:param>
  +
  +    <!-- for some unknown reason this needs to be called every time,
  +         otherwise only the first invocation uses a correct namespace
  +         prefix. -->
  +    <xsl:variable name="namespace-prefix"><xsl:call-template name="get-namespace-prefix"/></xsl:variable>
  +
  +    <xsl:variable name="qname">
  +      <xsl:value-of select="concat($namespace-prefix, ':param')"/>
  +    </xsl:variable>
  +
  +    <xsl:choose>
  +      <xsl:when test="@*[name(.) = $name]">"<xsl:value-of select="@*[name(.) =
$name]"/>"</xsl:when>
  +      <xsl:when test="(*[name(.) = $qname])[@name = $name]">
  +        <xsl:call-template name="get-nested-content">
  +          <xsl:with-param name="content" select="(*[name(.) = $qname])[@name = $name]"/>
  +        </xsl:call-template>
  +      </xsl:when>
  +      <xsl:otherwise>
  +        <xsl:choose>
  +          <xsl:when test="string-length($default) = 0">
  +            <xsl:choose>
  +              <xsl:when test="$required = 'true'">
  +                <xsl:call-template name="error">
  +                  <xsl:with-param name="message">[Logicsheet processor]
  +Parameter '<xsl:value-of select="$name"/>' missing in dynamic tag &lt;<xsl:value-of
select="name(.)"/>&gt;
  +                  </xsl:with-param>
  +                </xsl:call-template>
  +              </xsl:when>
  +              <xsl:otherwise>null</xsl:otherwise>
  +            </xsl:choose>
  +          </xsl:when>
  +          <xsl:otherwise>"<xsl:copy-of select="$default"/>"</xsl:otherwise>
  +        </xsl:choose>
  +      </xsl:otherwise>
       </xsl:choose>
     </xsl:template>
   
  
  
  

Mime
View raw message