| 
 
Subject: Re: Testing for CDATA From: Jeni Tennison <jeni.tennison@xxxxxxxxxxxxxxxx> Date: Thu, 10 Aug 2000 12:42:09 +0100  | 
Mike Brown wrote: >Jeni Tennison wrote: >> >> test="normalize-space(text()) != ''" >> > >It's usually not necessary to compare an unknown string to an empty >string, because if the unknown string is empty, as a boolean it will be >false already. So test="normalize-space(text())" would work just as well. Which is absolutely correct and a great tip. *BUT* before you go blithely deleting all the " != ''" in your tests, remember that if you're testing the value of a variable that has been set using its content, you are testing a *result tree fragment*, not a *string*. 'Empty' result tree fragments are actually node sets containing a single text node with a string-value of ''. As a node set with a node in it, they are always 'true' (no matter that the node is an empty text node). So, if you do: <xsl:variable name="foo"> <!-- something that may or may not give some content --> </xsl:variable> then the test on whether $foo has any content should be: test="string($foo)" and not just: test="$foo" (Doh!) Cheers, Jeni Dr Jeni Tennison Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE Telephone 0115 9061301 ? Fax 0115 9061304 ? Email jeni.tennison@xxxxxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: Testing for CDATA, Mike Brown | Thread | Re: Testing for CDATA, Mike Brown | 
| RE: How dynamic is XSL?, Linda van den Brink | Date | RE: <BR> a problem for XALAN?, Medina, Edward | 
| Month |