[xsd-users] XSD C++/Parser and enumerations

Boris Kolpackov boris at codesynthesis.com
Mon Oct 6 04:06:40 EDT 2008


Hi Leonid,

Leonid Gershanovich <gleonid at yahoo.com> writes:

> Is there any particular reason why xsd generator in "C++/Parser" mode 
> does not creates C++ enums for
>
> <xs:restriction base="xs:string">
>   <xs:enumeration value="XXX"/>
>   ..
> </xs:restriction> 
>
> xsd construct?

I agree this sounds like a natural thing to do but conceptually the
C++/Parser mapping does not produce "data" types that corresponds 
to the XML Schema types. Instead it produces parser skeleton types
and custom "data" types, if any, are provided by the application.

We cannot assume that everyone wants enums returned for types like
above. Some people might need a string.


> In my opinion it might benefit developers to have "enum" construct 
> and stringToEnum conversion functions generated automatically, even 
> if all other generated components remains the same.

That actually might be a good idea. That is, there could be an option
that triggers generation of a utility enum and a conversion function
but the parser return types stay the same. There won't be any way to
specify this enum value in the type map but I think this shouldn't be
a problem (in most cases application enums and generated enums can 
simply be cast back and forth).

I've added this to the TODO list. Thanks for the suggestion!

Boris




More information about the xsd-users mailing list