Re: [castor-dev] References by class type

2005-03-21 Thread Ralf Joachim
Hi Jeremy,
I'm not an expert for Castor XML but as far as I understand it should be 
possible for you to write a FieldHandler that can be used to 
marshal/unmarshal objects by their classname and identity.

Regards
Ralf
Jeremy Haile schrieb:
Is there any way to reference an object by ID, but only have Castor
create the reference for a particular class.
For example:
basketOfApples
  applemyFruit/apple
/basketOfApples
basketOfPears
  pearmyFruit/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
--
Syscon Ingenieurbüro für
Meß- und Datentechnik GmbH
Ralf Joachim
Raiffeisenstraße 11
D-72127 Kusterdingen
Germany
Tel.   +49 7071 3690 52
Mobil: +49 173 9630135
Fax+49 7071 3690 98
Email: [EMAIL PROTECTED]
Web:   www.syscon-world.de

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


Re: [castor-dev] References by class type

2005-03-21 Thread Bruce Snyder

On Mon, 21 Mar 2005 09:53:50 -0500, Jeremy Haile [EMAIL PROTECTED] wrote:
 
 Is there any way to reference an object by ID, but only have Castor
 create the reference for a particular class.
 
 For example:
 
 basketOfApples
   applemyFruit/apple
 /basketOfApples
 
 basketOfPears
   pearmyFruit/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, 

Castor XML supports the use of the ID and IDREF XML Schema types. But
remember that XML/XML Schema requires that IDs must be unique within
the document:

http://www.w3.org/TR/2000/WD-xml-2e-2814#id

So the use of myFruit in your example above is not a valid identifier.
Castor XML is simply enforcing the rules set forth by XML and XML
Schema. I have actually used the ID/IDREF types with Castor XML and
they do work correctly.

Bruce 
-- 
perl -e 'print unpack(u30,D0G)[EMAIL 
PROTECTED]5R\F)R=6-E+G-N61ED\!G;6%I;\YC;VT*
);'
The Castor Project
http://www.castor.org/

Apache Geronimo
http://geronimo.apache.org/



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