Is there any way to reference an object by ID, but only have Castor
create the reference for a particular class.

For example:

<basketOfApples>
  <apple>myFruit</apple>
</basketOfApples>

<basketOfPears>
  <pear>myFruit</pear>
</basketOfPears>

<apple name="myFruit"/>
<pear name="myFruit"/>

The subelements in the baskets are mapped as references and the "name"
attributes of the fruit would be mapped as the Castor "id".

In Castor 0.9.5.3, this would cause a serious problem.  Even though it
is obvious to a reader that the basket of apples should be referencing
the <apple> element, Castor treats all IDs as global XML ids.  This
means that Castor does not know whether the pear referenced in the
basket of pears is the apple or the pear.  It seems like it would be
easy to allow castor to differentiate IDs based on the class type, since
we know what class type the references are referring to.

In our application, we use Castor to export and import many different
types of objects to and from XML files.  A lot of the XML IDs can be
user-entered at runtime.  It is impossible (and/or unintuitive) for us
to enforce that two of those identifiers cannot be the same, when they
are two completely separate datatypes/classes.  

If I have an Apple property in my class which is mapped as a Castor
reference "private Apple apple;", it doesn't make any sense for Castor
to try and call setApple( Apple apple ) with an object of type Pear, so
shouldn't the referencing infrastructure take this into account?  

Has any support been added for this?  Is any planned?  What amount of
effort would be involved in adding this support?

Jeremy



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to