users@jaxb.java.net

How to bind existing class into schema generation?

From: Florian Bachmann <f.bachmann_at_micromata.de>
Date: Tue, 21 Apr 2009 10:58:19 +0200

Hi, it’s me again (-:

How could I integrate an existing class into my generated classes?
(I’m tied to use a given schema and could not change it.)

The schema compiler produces this class:

public class PointType extends AbstractGeometryType {

   @XmlList

   protected List<String> coordinates;

}





Could I, or how could I tell the schema compiler, that I rather like
to have a List of coordinates with my own (and already existing) class?

protected List<MYOwnAndAlreadyExistingClass> coordinates;



The relevant parts of my schema are:

<simpleType name="coordinatesType">

   <list itemType="string" />

</simpleType>

<element name="coordinates" type="kml:coordinatesType" />



<element name="Point" type="kml:PointType"
substitutionGroup="kml:AbstractGeometryGroup" />

<complexType name="PointType" final="#all">

   <complexContent>

     <extension base="kml:AbstractGeometryType">

       <sequence>

         <element ref="kml:coordinates" minOccurs="0" />

       </sequence>

     </extension>

   </complexContent>

</complexType>

I tried a mapping like:

<jaxb:javaType xmlType="kml:coordinatesType"
name="de.myClass.MyOwnAndAlreadyExistingClass"

   parseMethod="de.myadapter.KmlCoordinatesConverter.parse"

   parseMethod="de.myadapter.KmlCoordinatesConverter.print"

/>

but then the List disappeared:

protected MYOwnAndAlreadyExistingClass coordinates;



So how could I bind an existing class into my generated class files
and don’t destroy the creations of the list. I hope you understand my
explanations and could hopefully help me.



regards

Flori