1

if I make an XML Schema; I would physically define that schema correct? Or is there a program somewhere that would create a schema for my XML file automatically? Maybe I am confused on Schemas I'm not sure.

Howdy_McGee
  • 10,422
  • 29
  • 111
  • 186

2 Answers2

1

We've used this tool to generate XSD's from example XML files: http://www.thaiopensource.com/relaxng/trang.html. Just remember that it can only be as good as the example XML, so you might have to tweak the generated schema a bit (adding repetition, etc.).

Mac
  • 1,632
  • 9
  • 15
  • Such tools frequently generate horrible XML schemas. Your examples must illustrate all of the possibilities before a tool can even begin to create a good schema for it. – John Saunders Sep 16 '11 at 17:34
  • I'm not a fan of code generation myself, but in our case, we had some XML examples from a vendor/partner that refused to provide schemas. But we gave that tool a shot and it's worked out pretty well. At the very least, it gives you a starting point, if you have large documents or a lot of different types. – Mac Sep 16 '11 at 17:40
  • All in all though XML Schemas are usually* user generated correct? – Howdy_McGee Sep 17 '11 at 02:17
0

If you already have an XML file created and want to create a schema based off of it, VS 2010 can create one for you based off of the contents of an XML file by opening your XML file in VS and clicking the "Create Schema" button. You can read more here:

http://msdn.microsoft.com/en-us/library/ms255829.aspx

Edit: XML Schemas can be written by hand or generated off of an XML file (which you can then modify by hand if you feel the need to do so)

Josh T.
  • 151
  • 2
  • 10