Title pretty much says it all. VS xsd.exe creates classes in camel case. Is there a way of generating the classes in pascal case?
If not does anyone know of a good tool to convert a load of class names from camel case to pascal case.
Thanks
EDIT:
xsd.exe doesn't generate class names in camel case as standard - it just follows the convention of the schema - however, I am interested in overriding this behaviour so the XmlElement name attribute will still follow the conventions defined by the schema, but the class name is pascal case.
The XML Schema Definition (Xsd.exe) tool generates XML schema or common language runtime classes from XDR, XML, and XSD files, or from classes in a runtime assembly.
XSD can easily define parent-child relationship and basic type restrictions needed to define tables - so can be used as database schema. "MSDataSetGenerator" is the "custom tool" that builds whatever files/binaries are needed from the XSD whenever XSD is saved.
I wasn't aware that xsd.exe did that, are you sure the types in the schema are not defined in camelCase also?
My suggestion would be to use xsd2code, which is far superior to xsd.exe in every way..
Check out XmlSchemaClassGenerator, an open source console application that includes PascalCasing among its features. (I found this after the 15-day trial of xsd2code expired.)
- Map XML namespaces to C# namespaces, either explicitly or through a (configurable) function
- Generate C# XML comments from schema annotations
- Generate DataAnnotations attributes from schema restrictions
- Use
Collection<T>
properties (initialized in constructor and with private setter)- Use either int, long, decimal, or string for xs:integer and derived types
- Automatic properties
- Pascal case for classes and properties
- Generate nullable adapter properties for optional elements and attributes without default values (see below)
- Optional support for PCL
- Optional support for
INotifyPropertyChanged
In my case, before I could get the console app to work, I had to modify the xsd document to include a targetNamespace
field as follows:
Original:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1">
Modified:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="gateway" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1">
My final usage looked something like this:
XmlSchemaClassGenerator.Console -n "http://www.w3.org/2001/XMLSchema=gateway" -o "C:\{output-folder}" {xsd-file-name}.xsd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With