Re: DOM and java downcast versus query interface

On Wed, 2003-07-16 at 15:46, Christophe Cornu wrote:
> The w3c dom provides a java binding. Does the DOM specification
> require to suppport model 1 or model 2 below?
> 
> org.w3c.dom.Node node;
> org.w3c.dom.html2.HTMLAnchorElement anchor;
> ...
> anchor  = (HTMLAnchorElement)node.getFirstChild(); /* model 1 */
> or 
> anchor = CustomClass.queryInterface(node.getFirstChild(),
> "HTMLAnchorElement"); /* model 2 */
> 
> Model 1 is more familiar in a java world. However, Model 2 can be more
> natural when the java binding is implemented over a C++ native dom
> library.  Thanks for any pointer on this.

Model 1 is required by the DOM specification, up to DOM Level 3.

DOM Level 3 introduces the getFeature method and the "+" mechanism for
features (see section 1.3.6 of DOM Level 3 Core). In other words, your
CustomClass approach needs to be hidden inside the implementation of
getFeature.

Philippe

Received on Wednesday, 16 July 2003 18:02:11 UTC