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

Any reason that the Level 2 interfaces have the EXACT SAME NAME a s the Level 1 interfaces?

From: Box, Don <dbox@develop.com>
Date: Sun, 24 Oct 1999 05:31:27 -0400 (EDT)
Message-ID: <28910F983996D2118B320060082E970E7E6BCB@mail.develop.com>
To: "'www-dom@w3.org'" <www-dom@w3.org>
Cc: "Box, Don" <dbox@develop.com>
This makes it extremely hard to write Java code that:

a) Allows users to link in their own XML parser that implements org.w3c.*


b) Mixes Level 1 and Level 2 XML parsers in the same VM.

Yes, I know about DOMImplementation.supports, but I am sorry, this is a
hack. I strongly suggest you hoist the new Level 2 methods into new
interrfaces that extend the Level 1 versions. This could be done as simply
as spawning off another package name, as follows:

// note package name
package org.w3c.dom.level2;

public interface Attr 
        extends org.w3c.dom.level2.Node, org.w3c.dom.Attr
    public org.w3c.dom.level2.Element getOwnerElement();

This allows me to do the more Java-esque test for extended functionality:

public void f(org.w3c.dom.Attr attr)
    if (attr instanceof org.w3c.dom.level2.Attr) {
  // use level 2 functionality here
   // fall back on Level 1 functionality here

For someone implementing a Level 2 parser, one can simply ignore the level 1
names as folows:

import org.w3c.dom.level2.Element;
public class MyElement implements Element
// implement union of Level 1 and Level 2 methods

I really really feel this is an important issue. I have personally written
code that loads multiple XML parsers and in the face of Level 1 and Level 2
parsers, I see trouble. It is also not that far fetched to come up with
scenarios where this can happen (a web server that loads independently
developed servlets that each use a different XML parser).

Received on Sunday, 24 October 1999 13:21:50 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:06 UTC