Re: DOM - odd absent interface method?

>How come there's no "setNodeName" method?

The nodeName (together with the namespace URI) indicates the semantic role
this node is playing in the document, and different names even of the same
node type may reflect different subclassing of the node. Look at the HTML
DOM for plenty of examples; some Element nodes carry methods that others
may not. Other DOMs may implement similar role-specific extensions. Since
you can't change an object's class once it has been created (in most
languages), we really can't promise that you can change the semantic role
after the object has been created -- and hence both nodeName and
namespaceURI are immutable.

>If you're passing a node to a subroutine to have it filled

If you need to set the node's name/type: Don't. Instead, pass the Document
node into the subroutine, and have the subroutine use the Document's
factory methods create and return a new Node object of the appropriate type
and with the appropriate name.


______________________________________
Joe Kesselman  / IBM Research

Received on Monday, 21 May 2001 08:55:55 UTC