Ooops I overlooked that in the FAQ. Thanks.
Although I agree that you can emulate visitors with iterators and switch statements, the resulting code is not very robust and maintainable in a large scale implementation. Switch statements with casts of node types are just an inherently risky and, from my point of view, unelegant design. Or to say it in other words, the real problem of the iterator approach is not so much the iterator itself, but the need to use a switch statement based on node type, with object casts.
I am not quite sure that I see the negative consequences of permitting a visitor pattern. Having the ability available does not mean one could not use the iterator approach where it is superior. Would you be able to elaborate a bit on that?
For all it is worth, I would very much want to vote for an inclusion of the ability to use such a pattern in the DOM :-)
I take from your answer that you would not know of any alternative way to do something similar without the need of a switch?
From: Arnaud Le Hors <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: How to traverse a DOM in an object-oriented manner? Without switch{}?
Date: Wed, 21 Feb 2001 11:35:36 -0800
There is currently no support for the visitor pattern in the DOM. See http://www.w3.org/DOM/faq.html#visitor -- Arnaud Le Hors - IBM Cupertino, XML Strategy Group
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
