Ian, use c#. At least for the classes being generated from the schema. I'm
not in a position to confirm this but I would think the enum is fine in c#
since its case sensitive.

I'm not sure how the default value reference is relevant to this issue.
On Aug 6, 2012 3:58 AM, "Ian Thomas" <[email protected]> wrote:

> I have a problem that arose when generating code from xml schema (XSD
> files) using a tool XSD2Code (Codeplex – like xsd.exe), where the xml
> fragment is – ****
>
> ** **
>
> <xs:element name="casesens">****
>
>   <xs:simpleType>****
>
>     <xs:restriction base="xs:string">****
>
>        <xs:enumeration value="y"/>****
>
>        <xs:enumeration value="Y"/>****
>
>        <xs:enumeration value="n"/>****
>
>        <xs:enumeration value="N"/>****
>
>     </xs:restriction>****
>
>   </xs:simpleType>****
>
> </xs:element>****
>
> ** **
>
> The code that is generated (ignore its ugliness and verbosity) is –****
>
> Public Enum metadataDistinfoStdorderDigformDigtinfoAsciistrCasesens****
>
> ** **
>
>         '''<remarks/>****
>
>         y****
>
> ** **
>
>         '''<remarks/>****
>
>         Y****
>
> ** **
>
>         '''<remarks/>****
>
>         n****
>
> ** **
>
>         '''<remarks/>****
>
>         N****
>
>     End Enum****
>
> ** **
>
> which causes errors in VS2010 because N and Y are generated twice in this
> enum. ****
>
> Of course, the code generator inter-relates partial class, field,
> property, and this enum – and the element casesens  is an essential part
> of the schema.  ****
>
> The Microsoft tool XSD.EXE generates much the same code – ****
>
> '''<remarks/>****
>
> <System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1"),  _*
> ***
>
> System.SerializableAttribute(),  _****
>
> System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true,
> [Namespace]:="http://pc158.nc.fs.fed.us/nbii_std";)>  _****
>
> Public Enum metadataDistinfoStdorderDigformDigtinfoAsciistrCasesens****
>
>     '''<remarks/>****
>
>     y****
>
>     '''<remarks/>****
>
>     Y****
>
>     '''<remarks/>****
>
>     n****
>
>     '''<remarks/>****
>
>     N****
>
> End Enum****
>
> ** **
>
> - and of course causes the same error. Any suggestions how I can get
> around this? ****
>
> MSDN suggests as a part of enumeration best 
> practices<http://msdn.microsoft.com/en-us/library/1zt1ybx4>:
> ****
>
> If there is an obvious default case that your application has to
> represent, consider using an enumerated constant whose value is zero to
> represent it. If there is no default case, consider using an enumerated
> constant whose value is zero to specify the case that is not represented by
> any of the other enumerated constants. ****
>
> How would I implement that suggestion? ****
> ------------------------------
>
> **Ian Thomas**
> Victoria Park, ****Western Australia********
>

Reply via email to