[xsd-users] Enumerated types that serialize as numbers

Ray Lischner rlischner at proteuseng.com
Wed Jun 19 17:27:50 EDT 2013


We use Code Synthesis most often as an IDL tool, and use serialization a lot. Efficiency is important, but so is clarity of the schemas. We want to use enumerations for clarity, but serializing with the numeric values instead of strings.

We can use --custom-type and customize classes easily enough, but we would need to customize each enumerated type individually. That means every developer would need to know how to customize Code Synthesis classes. All the enumerations follow the same pattern, so we shouldn't need to customize each class. We want to isolate the common code, but we need access to the number of literals, the literals array, and the indexes array in a manner that does not require customizing the type.

Currently, we define a custom Enumeration class and modified the xsd compiler to recognize any type that ultimately derives from Enumeration, and insert extra code to support our needs.

I plan to get away from the magic type by adding an --enumerated-type option to xsd. Requiring the developer to add an option to the xsd command line is much easier than teaching them how to customize a type.

Is there a better way?

Ray Lischner,
Distinguished Member of Technical Staff
133 National Business Pkwy, Ste 150     t. 443.539.3448
Annapolis Junction, MD 20701            c. 410.854.9787
rlischner at proteuseng.com                f. 443.539.3370


More information about the xsd-users mailing list