Castor looks pretty spiffy, but I'm confused about its binding to a
polymorphic structure, such as a composite pattern. This stems from the
need to hold an object "as" its superclass. In other words, how can I bind
a field in an object, when that field is meant to be one of a collection of
subclasses that upcast to their superclass though an implicit upcast? In
other words, if the xml looks like this:
<query>
<or>
<and>
<eval field="name" op="eq" value="Fred"/>
<eval field="lastLogin" op="gt" value="12/01/01"/>
<and>
<eval field="disabled" op="neq" value="true"/>
</or>
</query>
The classes "Or", "Eval", and "And" are all subclasses of the class
"Condition", and are held as a collection of "Condition" type objects by
"Query", and by "And" and "Or". Since one will not know ahead of time which
are held, I cannot specify a particular binding using <bind-xml/>. Put
another way, the DTD for Query would be:
<!ELEMENT query ((and|or|eval))>
Meaning a query will hold one of these three, but we don't know which ahead
of time. The DTD for And would be:
<!ELEMENT and ((and|or|eval), (and|or|eval))>
Meaning an and holds two things, but each could be another "and", an "or",
or an "eval".
In my Java class, I handle this by having a superclass, "Condition" which
"And", "Or", and "Eval" extend, and then I hold them all as "Condition"
type.
Without knowing which will be held, how can I tell Castor to bind these
fields to these elements?
Thanks!
Scott Bain
Senior Consultant
Net Objectives
425-591-5844
http://www.netobjectives.com
----------------------------
* Sign up for our free newsletter by sending an e-mail to
[EMAIL PROTECTED]
* Learn about and join our design pattern community of practice by going to
www.netobjectives.com/dpexplained
* Alan Shalloway & Jim Trott's - Design Patterns Explained: A New
Perspective on
Object-Oriented Design is now available
* Our new CDROM-based XML training is now available as well
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev