Wrapper of JAXB generated Classes

Hello,

I'm trying to create wrapper classes of JAXB Generated Classes.

Solution which I have is to extend each of the generated classes to a new class in another package. But it doesn't work, because when I try to marshall, it conflict with the schema file.

For example:

generated class:

package generated;

@XmlType(name ="MyClass")

class MyClass

{

int a;

void setA(){}

int getA(){}

}

extending class:

package extension;

//@XmlType(name = "MyClass")

class MyClass extend generated.MyClass

{

//exactly no code here (or later will be added)

}

Here is the XML file marshalled from the generated class:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<MyClass version="1.0.1" Id="P01" >

<name>MyClass</name>

</MyClass>

Here is the XML file marshalled from the Wrapper

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<MyClass xsi:type="myClass" version="1.0.1" Id="P01" >

<name>Class1</name>

</MyClass>

The XML file marshalled contains type="myClass" which is wrong according to the schema.

When I tried to uncomment the @XmlType part of the extension class, there is an error while there is a conflict with 2 same XmlType name.

Is there any better way to implement this wrapper?

While it is so unwise (in my opinion) either to change the @XmlType name of the generated code or to change the schema file to make the XML file from the wrapper valid.

I have tried to look at the Schema customization, but found that I couldn't extending class located on other package.

I have been looking for solution to this problem for day long, but haven't found it yet.

Hope someone can share info about this.

Thanks alot for the help.

Regards,

Heru

[2757 byte] By [herusalima] at [2007-9-25]