0

Currently I have a bunch of XML files. Unfortunately, there is no XSD or any other schema file. Within my program (Java) I use JiBX to (un-)marshal XML files from/to POJOs. Consequently, my question is: Is there a way (by using JiBX) to create a XSD based on the structure coming from a sample XML file? I need to do this automatically, because the structure of these XML files is very complex. Btw: I need the XSD in order to create POJOs automatically. This requirement is related to the complexity as well.

Why not using any other solution different to JiBX? Generally, I will accept different solutions, but it would be great doing it with JiBX. That is because the next step would be doing it based on some automatism (e.g. Ant job).

Nevertheless, just for playing around, I already tried Oxygen. It creates some XSD schema based on one sample XML file, without running into errors. The result of this procedure is (some how) not as expected. For instance, when there is a String inside of an element tag, Oxygen creates further XSD sub-element rules. As a result, when unmarshaling the XML file, these Strings disappearing.

Maybe I am on a wrong path to a solution? Please give me assistance/ideas helping to solve the problem.

Thank you very much indeed.

Marco
  • 362
  • 1
  • 3
  • 10

1 Answers1

1

You can not generate a XSD document from a sample XML file with JIBX. You can generate the XSD from code (if you have POJO's) with then Jibx2Wsdl tool or you can generate the code from XSD with the CodeGen tool.

To generate the XSD from XML you have to use other tools, like recommended here. The inst2xsd tool from the Apache XMLBeans project seems to work well.

By the way - don't expect that the tools work on complex structures very well. I suppose the easier the structure is - the better a tool can work. The more complex it get's the more you will be involved personally.

Community
  • 1
  • 1
FrVaBe
  • 47,963
  • 16
  • 124
  • 157