Hi All,

I have a relatively simple XML schema that I want to use as a basis for
marshalling and unmarshalling corresponding Castor-generated objects. I'd
like to avoid using any mappings, i.e. I'd like Castor to use its default
and automated marshalling framework. I ran into difficulties with the
unmarshalling.

I did the following:

1. Generated Castor source files (one for each element + descriptor + one
for each complex type).
2. Used them in my code to marshal to and unmarshal from XML documents as
explained on your web site (on the Person example).

First, unmarshaller wasn't able to find the Castor-generated class despite
its being in the classpath. The following message was contained in the
exception: "The class for the root element ... could not be found". From
this I inferred that the unmarshaller does not look in the classpath for
classes with the same name as the given element, so I decided to specify the
class name using a mapping file (I wanted to avoid this, but it seemed
impossible).

I created a mapping file with the following class information:

<class name="<class name>" auto-complete="true" >
     <map-to xml="<element name>" ns-uri="<ns uri>"/>
</class>

The class name, element name and namespace URI were correct, as the same
information worked fine in the complete mapping configuration that I was
eventually forced to try out.  In the code, I wrote as follows:

Unmarshaller unm = new Unmarshaller();
unm.setMapping(allMappings);
castorMessage = unm.unmarshal(sourceDoc);

This resulted in the following error message:
"Unable to find FieldDescriptor for 'localChildElement' in ClassDescriptor
of 'MyCastorObject'"

The same happens with or without the auto-complete attribute. The child
element that Castor complains about is just a string field. The
FieldDescriptor is present in MyCastorObject's ClassDescriptor, but the
unmarshaller doesn't find it. What can the reason be for its inability to
find the FieldDescriptor?

The only way I managed to get this to work is by specifying a complete
mapping for each class, but this is exactly what I wanted to avoid. Please
help.

I looked at the information on the web site, but often this information
doesn't emphasize whether a piece of information applies to only marshalling
or unmarshalling, or both at the same time. I tried out different
combinations that should work according to the web site, but nothing worked
except the complete-mapping approach.

Alex



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

Reply via email to