2

I need a tool to automatically generate an xsd from an xml file.

Are there tools that do this? How does it work?

Thanks!

nemoo
  • 3,269
  • 4
  • 38
  • 51

2 Answers2

5

Most "big" XML editors boast this feature but in my experience, none can really deliver. The last time I tried (yesterday), Altova XML Spy generated crap.

But there is a deeper problem to automated schema generation from XML. In most cases, your Schema will be tied to the one file it was generated from, as the generator is unaware of all the restrictions and defaults you need to have a usable, flexible and safe schema.

There are some tools that could make the creation of Schema really easy. You can start with a visual editor like Liquid XML Studio -it has the nicest visual Schema editor I have seen.

Disclaimer : I am in no way affiliated to Liquid Technologies :)

kostja
  • 60,521
  • 48
  • 179
  • 224
  • I downvoted before your edit. It provided no solution and just bashed "big" XML editors, now even though you misspelled schema I have returned your vote since you updated your answer. – Joe May 04 '11 at 15:03
  • Yeah, I tend to practice "constant delivery" when answering on SO. The first drafts tend to be quite messy :) – kostja May 04 '11 at 15:05
2

There are several tools such as Altova.

If you would like to do this command line or in code trang is a good option.

Joe
  • 56,979
  • 9
  • 128
  • 135
  • 1
    trang worked nicely for me, thanks! – nemoo May 04 '11 at 17:05
  • 1
    Glad that helped, the latest version is 2008 which can be downloaded from here http://www.thaiopensource.com/relaxng/trang.html the version from that article I posted was the 2003 version. – Joe May 04 '11 at 19:10