Hi Chris,
replies inline.
Werner
chris au wrote:
Hi,
I was wondering whether it is possible to use castor to generate some
java objects from XML.
One of the parts of Castor XML is a code generator that generates Java
classes for an XML schema instance given to it. There's various ways of
invoking this code generator, including e.g. an Ant task definition, a
Maven plugin, etc.
In addition, Castor's code generator creates a second set of Java
classes, which we call 'descriptor' classes. These classes store all the
meta information as present in the XML schema needed for XML data
binding, i.e. marshalling and unmarshalling.
Currently I have been able to create a schema using castor and then
generate the appropriate java files against the schema created. What I
would like to know is whether it is possible to instantiate these
files for binding with my xml file immediately.
Yes, that's not just an option, but the preferred way. When you used the
code generator, you created two set of classes: your Java (domain)
objects, and the descriptor classes. A descriptor class records
information sich as e.g. XML element names, namespaces, etc., preserving
the XML-related informations from your XML schema.
With those two sets of classes, you can now start using the
(Un)Marshaller immediately. Just to get one more point across: as you
started from an XML schema and generated your Java classes and
descriptor classes, there's no need to use a mapping file anymore.
Mapping files are to be used with existing Java classes, which you want
to use during (un)marshalling.
If not what would be
the recommendation.
Thanks
Chris
---------------------------------------------------------------------
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