When using "element" binding, not only will classes be generated for the
complex types, but they will be generated for the elements as well. This
allows the object model to have a 1-1 mapping with XML instance
document. Each element maps directly to a class. In the "type" binding,
only complex types or elements that contain anonymous types will have
classes generated. This allows the object model to closely reflect the
complex type model described in your schema, but may not provide a 1-1
mapping with the instance document.
For example if you have an element named "foo" of type "fooType" as
such:
<xsd:element name="foo" type="fooType"/>
<xsd:complexType name="fooType">
...
</xsd:complexType>
In the "element" binding a class and descriptor class will be generated
for both foo and fooType resulting in 4 classes total.
When unmarshalling the following document:
<?xml version="1.0"?>
<foo>
...
</foo>
the "<foo>" element will get mapped to the Foo class.
In the "type" binding only two classes will be generated, a class +
descriptor for the fooType.
When unmarshalling the above, the user must pass in the FooType class to
the unmarshaller and the foo element will get mapped to the FooType
class.
--Keith
> Bryan Field-Elliot wrote:
>
> Actually I just discovered that the behavior is caused by the
> "javaclassmapping" option in "castorbuilder.properties". Changing it
> to "type", from the default of "element", causes the source generated
> to create two classes, rather than four.
>
> However, in the 2-class scenario, the project doesn't compile any
> longer...
>
> I'm satisfied to leave things as-is for a while with the 4 classes
> (the extra two, being abstract classes which the concrete ones
> extend).
>
> Thanks for offering to help,
>
> Bryan
>
> On Sat, 2003-01-04 at 14:45, Ozgur Balsoy wrote:
>
> Can you send the Schema snippet for Widget definitions?
> -ozgur
>
> Bryan Field-Elliot wrote:
> > I'm using the source generator to build classes from
> schemas. I can't
> > find in the documentation an explanation for why each
> <complexType>
> > results in the generation of four classes, rather than
> two.
> >
> > For example, if I have a complexType called "Widget", then
> I get these
> > classes generated:
> >
> > Widget.java
> > WidgetDescriptor.java
> > WidgetType.java
> > WidgetTypeDescriptor.java
> >
> > Can someone please point me in the right place to
> understand why I need
> > all four classes?
> >
> > Thank you,
> >
> > Bryan
> >
> >
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev