You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Christian Barth <co...@barth-zone.de> on 2006/01/16 15:41:36 UTC

How to test if XSL-variable is empty??

Hi again!
 
Now I have the following Code-snippet for you:
 
<xsl:variable name="stock" select="@stockwerk"></xsl:variable>

<xsl:choose>

<xsl:when test="$stock != '' ">

<td><xsl:value-of select="@typ" /> in Stockwerk "$stock" von Gebaeude
"<xsl:value-of select="gebaeude" />" in Bauvorhaben "<xsl:value-of
select="bauvorhaben" />"</td>

<td align="center"><b><xsl:value-of select="gesamtSim" /></b></td>

</xsl:when>

<xsl:otherwise>

<td>Gebaeude "<xsl:value-of select="gebaeude" />" in Bauvorhaben
"<xsl:value-of select="bauvorhaben" />"</td>

<td align="center"><b><xsl:value-of select="gesamtSim" /></b></td>

</xsl:otherwise>

</xsl:choose>

 

In the bold line I want to test, if the variable "stock" contains an empty
string or anything else. But with the code above, Cocoon always jumps into
the Otherwise-part.

What's wrong there?

 

 

Thanks,

Barthi


Re: How to test if XSL-variable is empty??

Posted by Luca Morandini <lm...@ieee.org>.
Christian Barth wrote:

> In the bold line I want to test, if the variable "stock" contains an 
> empty string or anything else. But with the code above, Cocoon always 
> jumps into the Otherwise-part.

What about applying boolean() [1] to the "stock" variable ?

Regards,

[1] http://www.zvon.org/xxl/XSLTreference/Output/function_boolean.html

--------------------
    Luca Morandini
www.lucamorandini.it
--------------------


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


RE: How to test if XSL-variable is empty??

Posted by Christian Barth <co...@barth-zone.de>.
It worked the way I had it:

<xsl:when test="$stock != ''">

The problem was that I assigned the wrong value to the variable. So it
couldn't work

Thanks anyway,

Barthi

> -----Original Message-----
> From: Jeroen Reijn [mailto:j.reijn@hippo.nl] 
> Sent: Monday, January 16, 2006 6:40 PM
> To: users@cocoon.apache.org
> Subject: Re: How to test if XSL-variable is empty??
> 
> Hi!
> 
> I guess you could also try
> 
> <xsl:when test="string-length($stock)&gt;0">
> </xsl:when>
> 
> Regards
> 
> Reijn
> 
> 
> Christian Barth wrote:
> > Hi again!
> >  
> > Now I have the following Code-snippet for you:
> >  
> > 
> > <xsl:variable name="stock" select="@stockwerk"></xsl:variable>
> > 
> > <xsl:choose>
> > 
> > *<xsl:when test="$stock != '' ">*
> > 
> > <td><xsl:value-of select="@typ" /> in Stockwerk "$stock" 
> von Gebaeude 
> > "<xsl:value-of select="gebaeude" />" in Bauvorhaben "<xsl:value-of 
> > select="bauvorhaben" />"</td>
> > 
> > <td align="center"><b><xsl:value-of select="gesamtSim" /></b></td>
> > 
> > </xsl:when>
> > 
> > <xsl:otherwise>
> > 
> > <td>Gebaeude "<xsl:value-of select="gebaeude" />" in Bauvorhaben 
> > "<xsl:value-of select="bauvorhaben" />"</td>
> > 
> > <td align="center"><b><xsl:value-of select="gesamtSim" /></b></td>
> > 
> > </xsl:otherwise>
> > 
> > </xsl:choose>
> > 
> >  
> > 
> > In the bold line I want to test, if the variable "stock" 
> contains an 
> > empty string or anything else. But with the code above, 
> Cocoon always 
> > jumps into the Otherwise-part.
> > 
> > What's wrong there?
> > 
> >  
> > 
> >  
> > 
> > Thanks,
> > 
> > Barthi
> > 
> 
> --
> Met vriendelijke groet,
> 
> Jeroen Reijn
> 
> Hippo
> 
> Oosteinde 11
> 1017WT Amsterdam
> The Netherlands
> Tel  +31 (0)20 5224466
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


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


Re: How to test if XSL-variable is empty??

Posted by Jeroen Reijn <j....@hippo.nl>.
Hi!

I guess you could also try

<xsl:when test="string-length($stock)&gt;0">
</xsl:when>

Regards

Reijn


Christian Barth wrote:
> Hi again!
>  
> Now I have the following Code-snippet for you:
>  
> 
> <xsl:variable name="stock" select="@stockwerk"></xsl:variable>
> 
> <xsl:choose>
> 
> *<xsl:when test="$stock != '' ">*
> 
> <td><xsl:value-of select="@typ" /> in Stockwerk "$stock" von Gebaeude 
> "<xsl:value-of select="gebaeude" />" in Bauvorhaben "<xsl:value-of 
> select="bauvorhaben" />"</td>
> 
> <td align="center"><b><xsl:value-of select="gesamtSim" /></b></td>
> 
> </xsl:when>
> 
> <xsl:otherwise>
> 
> <td>Gebaeude "<xsl:value-of select="gebaeude" />" in Bauvorhaben 
> "<xsl:value-of select="bauvorhaben" />"</td>
> 
> <td align="center"><b><xsl:value-of select="gesamtSim" /></b></td>
> 
> </xsl:otherwise>
> 
> </xsl:choose>
> 
>  
> 
> In the bold line I want to test, if the variable "stock" contains an 
> empty string or anything else. But with the code above, Cocoon always 
> jumps into the Otherwise-part.
> 
> What's wrong there?
> 
>  
> 
>  
> 
> Thanks,
> 
> Barthi
> 

-- 
Met vriendelijke groet,

Jeroen Reijn

Hippo

Oosteinde 11
1017WT Amsterdam
The Netherlands
Tel  +31 (0)20 5224466

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