Re: [xsl] test if null

Subject: Re: [xsl] test if null
From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx>
Date: Wed, 29 Jun 2005 02:42:18 +0200
Hi Jay,

The solution that David Carlisle gave you first works. If you did not
get it to work, you should rather ask yourself (or the list) why it
didn't work for you.

What we where discussing was not checking whether <sample> element was
present but whether it had a text() child. That is, the scope was
within the <sample> element.

In this scope, using DC's solution is the most efficient way of
solving your problem.

In short:
<xsl:if test="*">....</xsl:if>
does not distinguish between <sample/> and <sample>some text</sample>

<xsl:if test="string-length(.)=0">....</xsl:if>
does not distinguish between <sample/> and <sample><sub/></sample>

<xsl:if test="node()">....</xsl:if>
does distinguish between <sample/> and all variations of
<sample>....</sample>

I hope that you can see the difference.

Regards,
Ragulf Pickaxe :-)


On 6/28/05, -= jay =- <deepsweech@xxxxxxxxx> wrote:
> Hi Ragulf,
> The node is always present, but im checking if it returns empty string or
not
> like:
> <sample /> -->this is empty
> <sample>not empty</sample>  ->not empty
>
> thanks guys!

Current Thread