I know it is possible to generate skeleton XSD from XML. For example this post has good answers.
The question is how to generate XSD based on several XMLs. The idea is that each XML might have several different occurences of optional, arrays, choice and the like. From all those examples, I would like to compose the most accurate XSD.
I know there might be collisions and the like but assuming all the XML came from an uknown XSD, it should be theoreticaly possible. But is there such tool?
Thanks
With the desired XML document opened in the active editor tab, choose Tools | XML Actions | Generate XSD Schema from XML File on the main menu. The Generate Schema From Instance Document dialog box opens. and select the desired file in the dialog that opens.
We can use Eclipse IDE to easily generate XML from the XSD file. Just follow the below steps to get XML from XSD. Select XSD File in project, right click for Menu and select Generate > XML File… Provide the XML file Name and XML File location in the popup window.
A possible roundabout way of getting your XSD is to start with a json doc (not the jsonschema) that's pretty complete and conformant to your jsonschema, use any of a multitude of json to xml converters, and convert your xml to xsd (one such tool here).
Trang is just such a tool written in by the notable James Clark. It can translate between different forms of xml definitions such as Relax NG normal and compact syntax, old school DTD and XML schema. It can also infer schema from one or more xml files.
NOTE: The project has moved to Github. http://github.com/relaxng/jing-trang is the new location of the Trang repo
If you run ubuntu trang is packaged in the universe repository but that version seems a bit broken and a clean download from the link above is probably your best option. Assuming trang.jar is in the current directory:
java -jar trang.jar -I xml -O xsd file1.xml file2.xml definition.xsd
should do what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With