Re: Document.createTextNode(null) and CharacterData.setData(null)

WARNING: Unsanitized content follows.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 14 October 2002 3:01 pm, Sander Bos inspired the electrons to say:
> Hi there,
>
> My question is whether
> 	Document.createTextNode(null)
> is allowed (the same goes for CharacterData.setData(null)).
>
> I could not find anything in the specification that disallows it.
> If it is allowed, what should happen when I do (in the Java-binding)
> 	Text someText = document.createTextNode(null);
> 	System.out.println(someText.getLength());
> 	System.out.println(someText.getData());
> 	someText.appendData("bar");
> 	System.out.println(someText.getData());
> And what do I do on serialization in load/ save?

the escaped c-string output would be: "0\n\nbar\n"

Okay, I implemented it expecting that it is allowed. That means,
invoking setData(null) or createTextNode(null) will create an empty stream, a 
string that exists but with length zero.
This make handling easier for, e.g. later possible concatation 
(appendData("bar") etc.)
If you'll implement it to be a null string, that means, that this does not 
exist, you should ensure that returning someText.getLength() really 0, and 
getData() an empty string (to reduce further possible bugs)

> If it isn't allowed, what exception should I throw?

NOT_SUPPORTED_ERR, INVALID_ACCESS_ERR, DOMSTRING_SIZE_ERR,
INVALID_MODIFICATION_ERR, VALIDATION_ERR

All types I mentioned about makes sense in MY opinion. However, everybody may 
interpret it'self.

> (currently, we simply allow it to be null, although appendData dies)

Not good, not good, really ;)

> Kind regards,
>
> --Sander.

Greets,
Christian Parpart.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9q1I2Ppa2GmDVhK0RAkexAJ0ZbB3yudxci3QPB11492Y8W7STJwCeMWG7
TyC9xbozPQtEWHJ0TOa5aDY=
=0BVL
-----END PGP SIGNATURE-----

Received on Monday, 14 October 2002 19:25:19 UTC