I need to build a XML Schema for a bunch of Java classes. I tried with JAXB (schemagen) and with JIBX (bindgen). My java class extends froma class in a library and contains several inheritances and subclasses.
Failure 1 with JAXB: I get the exception JAXB can't handle interfaces
. My class does not have any annotations nor the extended class from a .jar file.
public class MySchemaOutputResolver extends SchemaOutputResolver {
public static void main(String[] args) throws IOException, JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(MYCLASS.class);
jaxbContext.generateSchema(new MySchemaOutputResolver(filepath));
}
String filepath = null;
public MySchemaOutputResolver(String filepath) {
this.filepath = filepath;
}
@Override
public Result createOutput(String namespaceURI, String suggestedFileName) throws IOException {
File file = new File(filepath);
StreamResult result = new StreamResult(file);
result.setSystemId(file.toURI().toURL().toString());
return result;
}
}
Failure 2: Then I tried with JIBX (bindgen). But here the output only contains the values from current class. All variables from the extended classes are not created.
So maybe I ask the question very basically:
How can I create a XML Schema containing all attributes from a Java class extending another class from a .jar?