I think that working from an XML schema is to be preferred if you
have that option. The advantages are
1) you can do a good design for your XML;
2) you can reuse any standards which might be available.
Since data tends to hang around much longer than programs (and get
processed by more than one language), I'd spend more time making sure
the data was as well organised as possible.
Steve
On 9 Jan 2007, at 10:33, Sandeep wrote:
Hi
Which is better:
1. Define a schema for a java bean, auto-generate the source code and
get the validation done by castor while populating the bean from a xml
instance.
2. Hand code the java bean. Define a mapping file. Populate the java
bean from a xml instance through castor. I don't think I need to
define a schema here (correct me, if I am wrong)
Advantage for 1) is validation of data types and values can be
performed by castor.
Advantages for 2) are flexibility to add application specific helper
methods to the bean, or when you cannot touch the source for the
bean.
Obviously, advantage of one is the disadvantage for the other.
So, how can I get the best of both worlds? I want to hand code my bean
class (not use SourceCodegenerator). I want to define the schema apart
from the mapping so that castor can validate the xml instance against
the schema for both data types and some values.
TIA
~Sandeep
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email