0

Does anyone know if it possible to create an xsd file from an xml document using the Custom Tool option in Visual Studio.

Simply, I want to place an xml document in my project. Assign it a custom tool. This custom tool will generate the xsd file, which in turn utilises Xsd2CodeGenerator to generate the classes from it.

I want to do this because if I had an xml document that looked something like this one day:

<Root>
  <Classes>
    <Class>
      <Property>Some Value</Property>
    </Class>
  <Classes>
</Root>

But then the next day:

<Root>
  <Classes>
    <Class>
      <Property>Some Value</Property>
      <Property2>Some Value</Property2>
    </Class>
  <Classes>
</Root>

I realise this might look daft, but bear with me. We've got xml files that we get regularly do this, for one reason or another!?

I want it to be able to update the xml file automatically, then have the xml file create an xsd file then have the xsd file create the updated classes...

I've looked at xsd but I guess I would need to assign some kind of parameters to the custom tool to achieve this, which I don't think I can.

Any ideas from you wonderful lot on stackoverflow?

Tony L
  • 43
  • 8
  • If you want to generate new XSD everytime you come up with an XML! then why do you need XSD ?? – Rookie Programmer Aravind Dec 07 '12 at 03:32
  • The XSD converts the xml to C# objects. If there's anything else out there that works better then I would like to know... Hence my question. – Tony L Dec 07 '12 at 09:22
  • I found this on codeproject: http://www.codeproject.com/Articles/133570/XmlToXsd-A-Better-Schema-Generator[link] Seems to create a nice xsd file from xml. Now to see if I can make this in to a custom tool...? – Tony L Dec 07 '12 at 11:01
  • Honestly it's not clear what you are asking!! – Rookie Programmer Aravind Dec 07 '12 at 11:18
  • What he's saying is that he doesn't have control over the XML coming to him, but that an XSD document is required to auto-gen some C# objects that he can then use to write code to consume as a data source. You see this sort of thing a lot when there is a very loosely defined or a poorly defined interface (usually defined by someone else who maybe isn't so great at communication). – Kevin Williams Mar 09 '13 at 17:34

0 Answers0