You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Scherler, Thorsten" <Th...@weidmueller.de> on 2002/11/21 14:56:38 UTC

XSL Element testing whether empty, or not!

Hello group,

newbie question:
How can you test whether a Element contain information or not? I mean something like the DB command "is not Null" // "is null".

Example:
data.xml
case 1) <department>Elektro</department> 
case 2) <department /> 

I want to have the word Department in front of the value as soon as the <department>is not empty</department>.
I figured out that the string-length(./department/text()) is 19 as soon <department />. If  <department>is not empty</department> is > 19.
So I have written the following xsl (knowing that is a work around but not a solution).
<xsl:variable name="xtest">
<xsl:value-of select="string-length(./department/text())"/>
</xsl:variable>
<fo:block>
<xsl:choose>
<xsl:when test="$xtest>19">Abteilung: <xsl:value-of select="./department/text()"/>
</xsl:when>
<xsl:when test="$xtest&lt;20">
<xsl:value-of select="./department/text()"/>
</xsl:when>
</xsl:choose>

Is there a better way to do it?

> Mit freundlichem Gruss,
> 
> Thorsten Scherler
> Marketing / Telefonmarketing
> 
> Weidmüller GmbH & Co.
> P.O. Box 2807
> 33058 Paderborn
> Tel.:+ 49 - 5252-960-350
> Fax:+ 49 - 5252-960-116
> eMail: thorsten.scherler@weidmueller.de
> http://www.weidmueller.de
> 
> 

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>