I have a bunch of XSD’s from https://github.com/XeroAPI/XeroAPI-Schemas/tree/master/v2.00
I need to do two things:
- Create tables for each type, my first one is for Contact in Contact.xsd.
- When the table is populated then I need to get the XML back out of the table so it can be sent as a REST request.
I can’t get past item 1 🙁
I’ve marked all these XSD’s as embedded resources in my .net C# project
I’m then using reflection to load the XSD using the DataSet.ReadXmlSchema(ContactXsdStream) but this XSD references types specified in BaseTypes.xsd and it throws an error “Undefined complexType ‘DataContractBase’ is used as a base for complex type extension”.
var assembly = Assembly.GetExecutingAssembly();
var dataset = new DataSet();
var manifestResourceStream = assembly.GetManifestResourceStream(schemaName);
if (manifestResourceStream == null)
throw new FileNotFoundException(string.Format("Unable to find schema resource {0}", schemaName));
using (var textStreamReader = new StreamReader(manifestResourceStream))
{
dataset.ReadXmlSchema(textStreamReader);
textStreamReader.Close();
}
return dataset;
All help is appreciated
Additional Considerations
I understand that there is not a contact complex type does not directly map to as a single table, however I may need to embed the complex types such as Address as an XML string in the data table.
The reason I need simple types is that the DataTables are passed to a Data Synchronisation API (Simego DataSync Studio). This sync tool allows me to two way sync to CRM, SharePoint, Excel and other datasource. I will use other sync frameworks if more appropriate any other recommendations welcome.
Kind regards
Si
When your Xsd is including other Xsd files, the files have to exist in the proper location(s) on your disk.
Even when you get the main xsd out of a resource and pass it to ReadXmlSchema as a stream or simple string, the included schemas have to exists as files in the specified location relative to your current working directory.