xsl-list
[Top] [All Lists]

Re: XSLT: question re testing for possibly empty elements

2004-08-17 02:17:35
Hi,

Consider <foo>   </foo> and <foo/>

"string-length(anElement) > 0" will return true for the first one,
"normalize-space()" will return false for both.

True!

I guess what the original author really meant was to check if the element is "empty or non-white" - because the data stored in anElement would be a car's license number and it makes no sense to return spaces (which are invisible on the print-out) when there's alternative data stored (which he retrieves in the otherwise-branch).

I reckon my test with normalize-space() is more accurate.

Thanks,
Ralph