You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "Scherler, Thorsten" <Th...@weidmueller.de> on 2002/11/21 14:12:36 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<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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: XSL Element testing whether empty, or not!
Posted by Oleg Tkachenko <ol...@multiconn.com>.
Scherler, Thorsten wrote:
> 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<20">
> <xsl:value-of select="./department/text()"/>
> </xsl:when>
> </xsl:choose>
>
> Is there a better way to do it?
What's wrong with this one? Just small modifications:
<fo:block>
<xsl:choose>
<xsl:when test="string-length(department)>19">Abteilung: <xsl:value-of
select="department"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="department"/>
</xsl:otherwise>
</xsl:choose>
--
Oleg Tkachenko
eXperanto team
Multiconn Technologies, Israel
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org