Add new namespaces to an existing XmlDocument
I am writing a translator for a vertical market application. The old format is a CSV variant, the new format is XML. For the most part it's working very well.
The old format is well defined with about 70+ "tables". The new format has a rich schema defined to provide for validation, something the old format couldn't handle very well.
The old format includes the capability of specifying "user defined tables", and I can successfully translate them, including writing a custom schema for each UDT. The process that I'm using is to populate a dataset with the CSV data, use WriteXml to a temp file and append each custom table as I encounter it, reload the custom table data at end of the conversion into another DS, and use WriteXmlSchema to generate a default schema for the combined custom tables. So far, that seems to work pretty well.
The problem is that I need to add some additional attributes to the root tag specifying some additional namespaces for the geotech industry. It seems straight forward to try something like
dim oXmlDoc as XmlDocument = new blah blah
dim oAttrib as XmlAttribute = oXmlDoc.CreateAttribute("xmlns:gml", "http://www.opengis.net/gml")
oXmlDoc.DocumentElement.AppendChild(oAttrib)
oXmlDoc.Save(schemaFileName)
Unfortunately, this fails on the save with an error
The namespace declaration attribute has an incorrect URI: "..."
What am I doing wrong?
Thanks!
Sean

