3

Possible Duplicate:

Here's the scenario: I've created an application that hooks into a commercial CRM product using their web service API, which unfortunately has a different schema for every installation, based on how the users create their custom fields. This schema can also be modified at any time. This application will be installed at the customer location, and will need to function even when they change their field structure.

In order to insert or update a record, I first call their Project.GetSchema() method, which returns the XSD file based on the current set of fields, and then I can call the Project.AddProject() method, passing in an XML file containing the project data.

My question is: What's the best way to generate the XML from the XSD file at runtime? I need to be able to check for the existence of fields, and fill them out only if they exist (for instance, if the customer deleted or renamed some fields).

I really don't want to have the application attempting to recompile classes on the fly using xsd.exe. There simply must be a better way.

[update] My current solution, that I'm working on, is to basically parse out the XSD file myself, since the majority of the schema is going to be the same for each installation. It's just an ugly solution, and I was hoping there was a better way. The biggest problem I have is that their schema uses xsd:sequence, so putting things in a different order always breaks validation.

Community
  • 1
  • 1
The How-To Geek
  • 1,105
  • 9
  • 13
  • How will you even know what data to put into the fields? – John Saunders Jan 31 '10 at 05:15
  • Essentially, I am filling out a secondary set of fields with (mostly) pre-defined names. The problem is that if they rename or remove a field, the entire integration breaks... and even worse, if they change the position of the field, their crappy integration breaks. – The How-To Geek Jan 31 '10 at 05:36
  • I've solved the issue by manually parsing out the schema and building the XML document that way. I'm sad that there's not a better solution, but at least it works. – The How-To Geek Jan 31 '10 at 19:16
  • Possible duplicate of [Programmatically Create XML File From XSD](https://stackoverflow.com/questions/2140828/programmatically-create-xml-file-from-xsd) – Cœur Jul 10 '18 at 13:10

0 Answers0