Re: [dom3core] getAttribute

Maciej Stachowiak wrote:

> Both "" and null are reasonable things to return for a nonexistent 
> attribute, there is no deep principle at stake here. 

I disagree. I think there's an obvious difference between null and "". 
It allows one to distinguish between <img alt="" /> and <img />. This 
has semantic value. The former indicates that an explicit choice was 
made not to provide an alt attribute, and that therefore the image is 
purely presentational. The latter indicates that the author didn't 
consider the alt text to provide. The former is the empty string. The 
latter is null.

There are many other cases one could construct where the difference 
between having an attribute with an empty string value and not having an 
attribute at all is significant. Of course, it would be possible to use 
hasAttribute to make this distinction if necessary.

is it necessary? The issue of languages without any nulls is compelling, 
provided examples of such languages can be provided. Off the top of my 
head the only one I can think of is XSLT, but there's no DOM 
implementation for XSLT. Which languages someone might actually want to 
use inside a browser do not have a null value?

-- 
Elliotte Rusty Harold  elharo@metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim

Received on Thursday, 1 December 2005 13:00:05 UTC