Missing element methods, missing interface

A bunch of comments:

1. The Element interface is missing some methods that I believe should
definitely be present:

    void removeAttribute(String name) raises NoSuchNodeException;

The semantics should be obvious. With the current interface, there is no way
to remove an attribute from an element. Setting the value to a null string
or to null should not actually remove the attribute.

    void setAttribute(String name, String value);

This is for convenience, but is much simpler than creating a new Attribute
object each time I need to add an attribute to an element. In the vast
majority of cases, an attribute's value list will only contain a single text
node.  Why not make this simpler? (the Attribute interface should also
support a setValue(String value) method).

    Attribute getAttribute(String name);

This is absolutely necessary. Without it, I have to retrieve the attribute
named node list from an element (which may be null), and ask it for the
attribute. And while we're at it:

    String getAttributeValue(String name);

This would return null if the attribute didn't exist (or if it couldn't be
represented as a string). Again this is for convenience.

    NodeEnumerator getAttributes();

Another convenience method, semantics should be obvious...

    StringList getAttributeNames();

This would allow delaying the evaluation of attributes until absolutely
necessary (although the Java package would need an interface defined for
StringList).

2. The DOM desparately needs a factory interface. IDL doesn't support
constructors, which is fine, as long as a factory interface is provided to
actually create the objects provided by a service. I would suggest the
following minimal interface:

interface NodeFactory {
    public Node          newNode(int nodeType);
    public Node          newNode();
    public Element     newElement();
    public Attribute     newAttribute();
    public Comment   newComment();
    public PI                newPI();
    public Text            newText();
    public Document  newDocument();
    public NamedCharacterReference newNamedCharacterReference();
    public NumericCharacterReference newNumericCharacterReference();
}

Without the factory interface, ALL code that adds content to a document has
implementation dependencies.

3. The package name for the DOM Java interfaces should be "org.w3.dom" or
"org.w3c.dom".

-------------------------------------------
Jeff Mackay
Vtopia, Inc.
Plumbing for Online Properties
http://www.vtopia.com/

Received on Tuesday, 28 October 1997 10:16:26 UTC