cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobia Conforto <tobia.confo...@linux.it>
Subject Re: XSLT Transformation error in C2.2
Date Tue, 11 Sep 2007 09:20:12 GMT
S├ębastien Geindre wrote:
> I try to do this in a xslt stylesheet :
> <xsl:variable name="top" select="if(($type='cb') and ($typeName!='wims:statusweatherproduct'))
then 'max_fub' else 'top'"/>

"if (...) then ... else ..." is not an XPath 1.0 expression!

You have a few options.
One is to use standard XSLT constructs:

<xsl:variable name="top">
  <xsl:choose>
    <xsl:when test="$type='cb' and $typeName!='wims:...'">max_fub</xsl:when>
    <xsl:otherwise>top</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

Another is to define a custom function:

<func:function name="my:if">
  <xsl:param name="test"/>
  <xsl:param name="then"/>
  <xsl:param name="else" select="false()"/>
  <xsl:choose>
    <xsl:when test="$test">
      <func:result select="$then"/>
    </xsl:when>
    <xsl:otherwise>
      <func:result select="$else"/>
    </xsl:otherwise>
  </xsl:choose>
</func:function>

And then use it like this:

<xsl:variable name="top"
    select="my:if($type='cb' and $typeName!='wims:...', 'max_fub', 'top')"/>

See here for custom functions: http://exslt.org/func/index.html


> it works with C2.1

I can't see how.
Maybe it's a custom extension of the XSLT processor you use?


Tobia

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message