[XML-SIG] Re: foo.bar vs. foo.get_bar()

Thomas B. Passin tpassin@idsonline.com
Tue, 9 Nov 1999 09:01:41 -0500


Ken MacLeod  wrote:

>From those who understand the details of the DOM and CORBA specs it's
>not clear to me yet that using attribute syntax is _not_ also
>conformant (i.e. the Python IDL binding may have been unnecessarily
>restricted).  The spec fragments from DOM and CORBA posted here both
>seem to support and allow attribute syntax, as well as providing a
>convention for languages that don't have attribute syntax or the
>necessary internals.

It is stronger than "seem to support and allow". The DOM rec clearly
illustrates how to represent the interface in both attribute and get/set
ways.  Here are some fragments from the "Node" interface that demonstrate
the point:

In the IDL interface definition for Node:

  readonly attribute  DOMString            nodeName;
  attribute  DOMString            nodeValue;

Notice that we have both read-only and non-read-only attributes.

In the Java binding, this is translated to:

  public String             getNodeName();
  public String             getNodeValue()
                                                 throws DOMException;
  public void               setNodeValue(String nodeValue)
                                                 throws DOMException;

Notice that there is no setNodeName(), since Node is read-only.

In the ECMAScript (Javascript) binding, this is translated to the following:

The Node object has the following properties:
nodeName
    This property is of type String.
nodeValue
    This property is of type String.

Notice that attributes (called properties in the binding) are used here.
There are no get/set functions defined elsewhere in the binding for Node
names or values.

In this particular example, the DOM clearly wants the name of a Node to
never change once the Node is created.  Java can enforce this, ECMAScript
cannot.  Python can't really enforce it either, but it doesn't have to
provide an easy way to get around the read-only intent.

So Ken is correct and the DOM rec does not tie you to any particular way to
translate the IDL in an actual binding.

Regards,

Tom Passin