I am using Xsd.exe to generate C# classes from an XML schema. My "primary" schema imports a second schema containing simple type declarations in a different namespace than the primary schema. My application requires that the type names declared in both schemas remain as originally defined in their respective schemas. (Legacy code integration)
An issue surfaces when Xsd.exe generates classes for the schema and its imported schema. Both schema contain a similarly named type, only differentiated by their respective namespaces. Xsd.exe, apparently, generates classes only within the namespace provided via the command line argument. Xsd.exe does not carry forward any "original namespace" information from the sourced schemas, so in order to create unique names in the single generated namespace, one of the type names is "mangled" to resolve the collision of the now duplicated type names, e.g. "foo" becomes "foo1" to distinguish it from the other "foo".
I'm looking for confirmation of this behavior from a knowledgeable Xsd.exe guru and any ideas on how to work around this problem. I can not change the names used in the schemas to eliminate the duplicated type name occurrence.
I can offer that code generators from XMLSpy and Liquid Technologies process the schemas without mangling the original type names, each of these tools carry the namespaces used in the schemas into the C# domain when generating the C# classes.
However, I would like to not introduce these tools into our Visual Studio development environment.
Any ideas?
-Chip
An issue surfaces when Xsd.exe generates classes for the schema and its imported schema. Both schema contain a similarly named type, only differentiated by their respective namespaces. Xsd.exe, apparently, generates classes only within the namespace provided via the command line argument. Xsd.exe does not carry forward any "original namespace" information from the sourced schemas, so in order to create unique names in the single generated namespace, one of the type names is "mangled" to resolve the collision of the now duplicated type names, e.g. "foo" becomes "foo1" to distinguish it from the other "foo".
I'm looking for confirmation of this behavior from a knowledgeable Xsd.exe guru and any ideas on how to work around this problem. I can not change the names used in the schemas to eliminate the duplicated type name occurrence.
I can offer that code generators from XMLSpy and Liquid Technologies process the schemas without mangling the original type names, each of these tools carry the namespaces used in the schemas into the C# domain when generating the C# classes.
However, I would like to not introduce these tools into our Visual Studio development environment.
Any ideas?
-Chip