[XML-SIG] SAX: Names with no namespace

Ken MacLeod ken@bitsko.slc.ut.us
21 Feb 2001 09:01:58 -0600


"Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de> writes:

> [Guido van Rossum writes:]
> > Which reminds me.  I've been told that getAttribute() and
> > getAttributeNS() are supposed to return "" for a non-existent
> > attribute, and that if you want to know whether the attribute was
> > really there, you should use getAttributeNode() etc.  Again, that
> > may be a good design for Java or IDL, but is it right for Python?
> > I'd much rather see None used as it was intended!
> 
> I'd have to check again, but I think the current DOM spec is
> painfully clear about null and empty strings, and it also clear that
> a null string ought to be None, and an empty string ought to be
> "". So there is not much choice - except for developing a dislike
> towards the entire DOM (which I wouldn't do just because of that
> problem).

Yes, the only place I see "" should be returned is in the two methods
getAttribute() and getAttributeNS(): "The Attr value as a string, or
the empty string if that attribute does not have a specified or
default value".

That does seem odd, and unfortunate, but this would be one of the
little places I'd rather adhere to the spec and not have any
Python-specific documentation to the contrary, rather than note the
difference and emphasize it wherever it might be an issue.

  -- Ken