W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2001

Re: Type-safe iteration over the DOM in DOM 2 & 3?

From: Peter Meyer <petermeyer99@hotmail.com>
Date: Tue, 20 Mar 2001 21:41:24 -0000
To: jcowan@reutershealth.com
Cc: www-dom@w3.org
Message-ID: <F150pYC98Bi89QtpfTY000063cc@hotmail.com>
This is probably true for HTML, and many web formats. However, XML is 
increasingly used as a canonical format for very complex data in a variety 
of businesses. In such a use the result of the parsed XML file (i.e. an 
in-memory DOM) should directly be usable as an in-memory data model. Such 
data models (think of a 3D animation system, for example) will require 
larger numbers of classes in relatively complex structures. Providing 
visitors will make it much easier to manage such data models without having 
to re-implement a DOM-like in-memory application model and then translate 
from the results of the XML parse.

And, as argued in one of these many mails :-), it is not that it is either 
visitors OR switch statements. It is very simple to have both and let 
developers decide which they like. The changes to the DOM, as outlined in 
the forementioned mail would be minimal.

>From: John Cowan <jcowan@reutershealth.com>
>To: Peter Meyer <petermeyer99@hotmail.com>
>CC: www-dom@w3.org
>Subject: Re: Type-safe iteration over the DOM in DOM 2 & 3?
>Date: Tue, 20 Mar 2001 16:21:15 -0500
>Peter Meyer wrote:
>>I agree that you can implement the same functionality using a switch
>>statement and using a visitor pattern. What I personally dislike about
>>the switch statement is that I have to rely on information stored in a
>>field to switch, instead of type information of the classes I am
>>If I never create my own classes for nodes (i.e. I rely on the basic DOM
>>classes), this works well, but the approach tends to be fragile if I
>>need to have application dependent node subclasses based for example on
>>element types.
>Granted.  But by the same token, if the implementation uses *fewer* classes
>than it has interfaces, then the Visitor pattern becomes 
>In the HTML DOM, for example, the 50+ element interfaces can be represented
>(IIRC) by about 6 classes.  Visitor wouldn't help much; you need to
>have a switch operating over the element name.  Other DOMs may very
>well use fewer classes than interfaces even in the core.
>There is / one art             || John Cowan <jcowan@reutershealth.com>
>no more / no less              || http://www.reutershealth.com
>to do / all things             || http://www.ccil.org/~cowan
>with art- / lessness           \\ -- Piet Hein

Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Received on Tuesday, 20 March 2001 16:41:56 UTC

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