I am new to Castor and I am sure this a very basic question, but it wasn't
immediately clear to me how this may be effected, nor could I find anything
in the docs or archives that relate to this.  The problem is as follows:

I wish to use the XML Schema based form of data binding with source
generation and therefore have no requirement for an XML binding file.

A client will pass an 'XML instance' for one of the classes that is defined
in the schema, my code (more accurately, Castor) will automatically
unmarshal this into a Java object that can then be further manipulated.
I have a base class, DataObject from which all classes defined in the schema
will derive.
The examples indicate that I would need to call <DataObject>.unmarshal() in
order to get an instance of a <DataObject>, however without peeking into the
XML instance I cannot know on what class of <DataObject> to call
unmarshal().
An alternative would be to construct a Unmarshaller with an instance of a
Mapping class. However, this requires that a mapping file be provided.  Am I
correct in saying that the XML Schema used for source generation cannot be
used to construct a Mapping instance?

So, it would appear that my only options are:
1. To partially process the XML instance to determine the class and then to
call Unmarshaller.unmarshal(<DataObject>.class, reader), or

2. To generate an XML binding file in addition to the XML Schema and
construct a Mapping instance using the XML binding file.

Am I missing something? My obvious preference would be for the framework to
determine the class using the XML Schema and process it accordingly, e.g.

{
    ...
    Unmarshaller um = new Unmarshaller("MyXmlSchema.xml");
    DataObject o = (DataObject)um.unmarshall(reader);
    ...
}


Thanks in advance for any help you can provide,

Scott.

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

Reply via email to