Currently, JAXB is creating a point class from the xml schema I have specified. However, I would prefer it to use the existing java.awt.Point class. And for any other types I have defined to use and import java.awt.Point too.
Here is my point code:
<xs:complexType name="point">
<xs:sequence>
<xs:element name="x" type="xs:int" />
<xs:element name="y" type="xs:int" />
</xs:sequence>
</xs:complexType>
Is this possible?
I don’t know if my solution is very elegant but I believe it works as you demand.
Consider class
Testwith a propertypof typejava.awt.Point:The class
PointAdapteris as follows:If you don’t create your Java classes by hand but let them generate by
xjcthere is a possibility to specify theXmlAdapterin the schema too; either through a seperate binding file that you can specify with the-boption ofxjcor embedded in your XSD. Personally I prefer the first solution as this keeps the schema clean. Since it has been a while since I played with this I refer you to the JAXB documentation (look for MyDatatypeConverter; this should be the most relevant part).