Generating XSD from XML

Hello Readers,

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:

  1. trang.jar
  2. cd_catalog.xml
  3. cd_catalog.xsd (generated using trang.jar)


Let me know any questions/feedback.

Your’s Truly.





About Badal Chowdhary

I am a Software Engineer by profession. I have done SCJP and SCWCD certifications. Like working on cutting edge technologies and frameworks. Driven by challenges and fascinated by technology. I love playing and watching sports: Cricket, Ping Pong, Tennis, Badminton, Racket Ball and Gym.
This entry was posted in XML and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s