W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2005

Re: [dom3core] getAttribute

From: Elliotte Harold <elharo@metalab.unc.edu>
Date: Thu, 01 Dec 2005 07:59:47 -0500
Message-ID: <438EF3C3.6030106@metalab.unc.edu>
To: Maciej Stachowiak <mjs@apple.com>
CC: DOM mailing list <www-dom@w3.org>, andersca@mac.com

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:58 GMT