Hi Angelina,

This happens because you are marshalling the class that corresponds to
the complexType. Since it's the complexType class, it doesn't correlate
to a specific element. The XML name could really be anything, Castor
automatically creates an XML name for you during the marshalling and
simply uses the class name to do this.

It would probably be good if Castor added some possible correlation to
all top-level elements declared of that type. In the case of only one
element, it could simply choose that name, if more than one element,
then it would choose the first one it found.

In any case, you can specify the "root" element name you want in the
Marshaller.

Marshaller m = new Marshaller(writer);
m.setRootElement("APLTask");
m.marshal(myAPLTaskType);

During unmarshalling, the root element name doesn't matter, just pass in
the complexType for unmarshalling:

Unmarshaller u = new Unmarshaller(APLTaskType.class);
u.unmarshal(reader);

--Keith


> [EMAIL PROTECTED] wrote:
> 
> I'm confused as to why I'm getting certain XML unmarshaled from my
> generated Castor classes.
> 
> For some reason I have a schema snippet (below) that eventually
> generates XML (also below) where the name of the element is the type
> name rather than the element name as specified in the schema.
> 
> Schema snippet:
> 
> <schema
>     xmlns="http://www.w3.org/2001/XMLSchema";
>     targetNamespace="http://www.emc.com/schemas/celerra/apl_1.0";
>     xmlns:apl="http://www.emc.com/schemas/celerra/apl_1.0";
>     xmlns:meta="http://www.emc.com/schemas/celerra/xsd_meta_1.0";
>     xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"; jaxb:version="1.0">
> 
>   <element name="APLTask" type="apl:APLTaskType"/>
> 
>   <complexType name="APLTaskType">
>     <sequence minOccurs="0" maxOccurs="unbounded">
>       <element name="List" type="apl:ListType" minOccurs="0"
> maxOccurs="unbounded"/>
>     </sequence>
>   </complexType>
> 
> </schema>
> 
> (obviously there's more than that, but...)
> 
> XML unmarshaled:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <APLTaskType description="Query capabilities share list."
> originator="[EMAIL PROTECTED]">
>   <List properties="capable,">
>     <Capabilitys object="share" action="list"/>
>   </List>
> </APLTaskType>
> 
> It's the APLTaskType that's really got me confused. Why is it not
> APLTask? We do generate the classes with the
> org.exolab.castor.builder.javaclassmapping option in
> castorbuilder.properties set to "type".
> 
> Thanks in advance to anyone who can shed some light on this!
> 
> -Angelina Talley
> 
>     ---------------------------------------------------------------
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user



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

Reply via email to