W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2003

Re: DOM and java downcast versus query interface

From: Philippe Le Hegaret <plh@w3.org>
Date: 16 Jul 2003 18:02:02 -0400
To: Christophe Cornu <Christophe_Cornu@ca.ibm.com>
Cc: WWW DOM <www-dom@w3.org>
Message-Id: <1058392921.9605.118.camel@chacal>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:57 GMT