Re: EOC/SOX: element<->class mapping

james anderson (James.Anderson@mecomnet.de)
Mon, 05 Oct 1998 20:26:42 +0200


David Brownell wrote:
>
> james anderson wrote:
> ...
>
> > For this purpose [1st stage] it
> > suffices to declare a relation between java packages and xml
> > namespaces and to use introspection to map from element name
> > to class. One would have standard java packages appropriate
> > for and associated with standard elements.
>
> Of course with this sort of solution you prevent many-to-one
> mappings. Those can be convenient to work with. If one must
> take well formed XML and emit an HTML vocabulary, the ability
> to have one class handle all of HTML's empty-element printing
> syntax (e.g. <BR> or <BR /> but never <BR/>) is a time saver,
> certainly at the "encoding" level and possibly higher up too.
>
> Many other solutions for this exist. For now, I'm assuming
> a factory method createElement(uri,tag) that can have many
> implementations, including the one james sketched above.
>

I would agree, in principal, on the need for the above method for a factory instance.

(In prior posts re namespaces I have argued that there is no use in separating
the URI from the tag name, but I neglect that issue for the moment.)

I advocate further, that the number of additional calls and the amount of
anscilliary data be kept at a minimum. If I were to program in java, I would
be concerned with the bulk and complexity of calls to specify the location of,
and the need to administer the content of external mapping files and or other
external specifications. Not to mention the need to distribute and maintain
this meta-data with applets. This when, with judicious application of existing
meta-object capabilities, the only call needed is one to match an xml
namespace with a java package.

While there may be EOC-requirements which extend beyond the need to specify an
arbitrary class <-> element mapping, the namespace-based mechanism is
sufficient for that, and therefore also sufficient for the problem which Mr.
Brownell described. The application need only specify appropriate type
relations between classes specific to HTML-elements and a parent class which
comprises the desired behaviour and/or storage. One may well need to define
interface classes and a package for this purpose. 1-N relations in the other
direction are (as discussed earlier) a problem which extends beyond EOC.