Re: Contents present? Apparently simple but ...

Subject: Re: Contents present? Apparently simple but ...
From: MARK.WROTH@xxxxxxxxxxx (Wroth, Mark)
Date: Wed, 15 Dec 1999 07:39:08 -0800
In response to my question
> I'm trying to test for the existence of element content so that I can do
> conditional processing on an element.
> 
> I would have said 
> 
> 	(if (data (current-node)
> 	  ( -- branch 1 --)
> 	  ( -- branch 2 --))
> 
> would do what I want.  However, branch 1 always gets executed, whether the
> element is empty or not.

Matthias Clasen <clasen@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> pointed out

MC>If there is no data, (data ...) returns an empty string. But every object
MC>except #f counts as a true value in DSSSL. 

and Jany Quintard <quintard.j@xxxxxx> further commented that

JQ>data returns a string, so if there is no data, it should return an empty
JQ>string. But this is not equal to #f
JQ>I would try try something like :
JQ>
JQ> 	(if (equal? (data (current-node)) "")
JQ> 	  ( -- branch 2 --)
JQ>	  ( -- branch 1 --))
JQ>
JQ>I am not sure that "" is a correct expression for empty string.


Between these comments, I think I see how to get to where I want to be.
Thank you both.

Mark


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread