2

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?

Philipp
  • 4,645
  • 3
  • 47
  • 80
  • Does your .jar file have the sources for the classes that you extend? – nattyddubbs Apr 24 '13 at 17:30
  • No, unfortunately not. I try to generate the Schema of the class `ADT_A01` from an older java library. Here I have the whole Java project containing all libs and my JAXB test class: https://dl.dropboxusercontent.com/u/1443211/OtdClassToXSD.zip – Philipp Apr 25 '13 at 08:27
  • Have you tried this: http://stackoverflow.com/a/3415423/1154145? – nattyddubbs Apr 25 '13 at 16:49

0 Answers0