473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Autogenerate enumerations

Hello,

Does xsd.exe support generating .NET enumerations from XSD
enumerations?

That is, if I have

...

<xs:simpleType name="US_STATE">
<xs:restriction base="xs:string">
<xs:enumeration
value="AL"
/>

<xs:enumeration
value="AK"
/>

<xs:enumeration
value="AZ" />

...

</xs:restriction>
</xs:simpleType>

<xs:element name="State" type"US_STATE" >

...

as part of my schema, then as part of my generated dataset, I would like to
see something like the following (in C#):

public enum US_STATE
{
AL,
AK,
AZ,
...
}
...

public WhateverRow AddWhateverRow(
...
US_STATE STATE,
...
)
public US_STATE STATE
{
get
{
return ((US_STATE)
(this[this.tableWhatever.STATEColumn]));
}
set
{
this[this.tableWhatever.STATEColumn] = value;
}
}

The advantage would be to catch validation errors at compile time and the
ability to leverage IntelliSense (i.e. catching errors BEFORE compile time,
at programming-time :).

-Dan

PS: Similar questions apply to other xs:restrictions , such as
xs:maxLength , but I'm really most interested in xs:enumeration.
Sep 19 '06 #1
2 1332

Dan Bron a écrit :
Hello,

Does xsd.exe support generating .NET enumerations from XSD
enumerations?
Hi, I don't know if it might help you but as the ASP.NET XML
WebServices documentation says, the .NET enum type is supported.
When serialized, the enum is transcripted to a string whose value is
the enum item.

However I don't know if the XSD enum type is supported.

Regards,
Olivier.

Sep 25 '06 #2
"olrt" <ol**@ifrance.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...

Dan Bron a écrit :
Hello,

Does xsd.exe support generating .NET enumerations from XSD
enumerations?
Hi, I don't know if it might help you but as the ASP.NET XML
WebServices documentation says, the .NET enum type is supported.
When serialized, the enum is transcripted to a string whose value is
the enum item.

However I don't know if the XSD enum type is supported.

XSD doesn't have an "enum" type. The enumeration facet is simply a way of
constraining the lexical space of a simple type to one of the enumerated
values. The type of the item remains the type being restricted. For
instance:

<xs:simpleType name="SomeType">
<xs:restriction base="xs:int">
<xs:enumeration value="1"/>
<xs:enumeration value="3"/>
</xs:restriction>
</xs:simpleType>
This defines "SomeType" as an xs:int which is restricted by having only 1
and 3 as possible values. It does not define the same sort of thing as a
programming language enum. Notice, for instance, the lack of a name to go
with the value "1".

John
Sep 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Plinkerton | last post by:
I'm making an Base Class that will be inherited. In my base class, I have a public enumeration that defines a list of things I want my class to be able to do. I use it for Method input...
1
by: someone else | last post by:
I have some code that creates dynamic enumerations for use in a PropertyGrid control. This all works perfectly but the memory usage of the program increases quite quicly when viewing the...
1
by: Oleg Ogurok | last post by:
Hi all, I've added a new DataSet (xsd file) to my project in VS.NET 2003. There I create a simple type as an enumeration of values. <xs:simpleType name="MyCustomType"> <xs:restriction...
4
by: ChrisB | last post by:
Hello: I will be creating 50+ enumerations related to a large number of classes that span a number of namespaces. I was wondering if there are any "best practices" when defining enumerations. ...
1
by: ypul | last post by:
Hi , Getting to the point directly, my query output doesnt have fixed columns , so I choosed "autogenerate columns" datagrid. I assign this dataset to my datagrid, but now I want my data should...
2
by: serge calderara | last post by:
Dear all, I have a datagrid which bind to a dataset object Datagrid autogenerate propertie is set to True. I need to create the first column of my grid to be used as an hyperlink and sending...
27
by: Ben Finney | last post by:
Antoon Pardon wrote: > I just downloaded your enum module for python > and played a bit with it. IMO some of the behaviour makes it less > usefull. Feedback is appreciated. I'm hoping to...
77
by: Ben Finney | last post by:
Howdy all, PEP 354: Enumerations in Python has been accepted as a draft PEP. The current version can be viewed online: <URL:http://www.python.org/peps/pep-0354.html> Here is the...
1
by: Dhruba Bandopadhyay | last post by:
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.