You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sébastien Geindre <se...@meteo.fr> on 2007/09/11 10:55:07 UTC

XSLT Transformation error in C2.2

Hi all,

I use C2.2.
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'"></xsl:variable>

but cocoon refuses, and says :
Caused by: javax.xml.transform.TransformerException: Impossible de 
trouver la fonction : if
        at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:608)

it works with C2.1

Any idea ?

Thanks Grzegorz, ;-) !

-- 
Sébastien Geindre
DPREVI/AERO/DEV
sebastien.geindre __at__ meteo.fr




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


Re: XSLT Transformation error in C2.2

Posted by Sébastien Geindre <se...@meteo.fr>.
Thanks Tobia,
I thought about these solution but i really wonder why it do not work
I think it is possible with xslt version 2.0 
http://zvon.org/xxl/XSL-Ref/Tutorials/Conditional-Expressions/ce1.html

so what i need is a xslt 2.0 transformer.
the question is now, how can i set it with C2.2 ??

Tobia Conforto a écrit :
> 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
>
>
>   


-- 
Sébastien Geindre
DPREVI/AERO/DEV
sebastien.geindre __at__ meteo.fr




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


Re: XSLT Transformation error in C2.2

Posted by Tobia Conforto <to...@linux.it>.
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