You’d think it should be straightforward to create XSD from XML using Eclipse but it ain’t. I was faced with this task few months back and got stumped for couple of hours.
There is this nice utility trang that does a pretty good job. See usage below:
java -jar <path_of_trang.jar> <path_of_xml> <path_of_xsd>
See below example:
All you have to do is run above command and you should have the XSD 90% ready. I say 90% because you’d have to open up generated XSD and verify the datatypes. I had to replace occurrences of type=”xs:NCName” with type=”xs:string”.
You can download the files used in this post at: trang_files.
You’d have to rename the downloaded file from .pdf to .zip. It contains below files:
- cd_catalog.xsd (generated using trang.jar)
Let me know any questions/feedback.