473,746 Members | 2,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flags style enum?

Is there a way to represent a [Flags] style enum in XML Schema? Say I have
a flags enum like so:

[Flags]
public enum dayOfWeek {
Mon,
Tue,
Wed,
All = Mon | Tue | Wed;
}

I'd like to have my XML be able to use an element attribute like so:

<SomeElement dayOfWeek="Mon| Wed" />

Is this possible with xsd:enumeration ? If not, I can fall back to making
this attribute type xsd:string it's just that I don't get the benefits of
schema validation on the values anymore. Or can I? Is there a way to hook
schema validation for a particular attribute value?

--
Keith
Nov 12 '05 #1
4 6746
Keith Hill wrote:
Is there a way to represent a [Flags] style enum in XML Schema? Say I have
a flags enum like so:

[Flags]
public enum dayOfWeek {
Mon,
Tue,
Wed,
All = Mon | Tue | Wed;
}

I'd like to have my XML be able to use an element attribute like so:

<SomeElement dayOfWeek="Mon| Wed" />


Is it important to have | as separator? List values in XSD are separated
by space. Here is an example:

<xs:simpleTyp e name="dayOfWeek Type">
<xs:restricti on base="xs:string ">
<xs:enumerati on value="Mon"/>
<xs:enumerati on value="Wed"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="SomeEleme nt">
<xs:complexType >
<xs:attribute name="dayOfWeek " use="required">
<xs:simpleTyp e>
<xs:list itemType="dayOf WeekType"/>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>

Then you can list enumerated values:

<SomeElement dayOfWeek="Mon Wed"/>

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
Keith Hill wrote:
Is there a way to represent a [Flags] style enum in XML Schema? Say I have
a flags enum like so:

[Flags]
public enum dayOfWeek {
Mon,
Tue,
Wed,
All = Mon | Tue | Wed;
}

I'd like to have my XML be able to use an element attribute like so:

<SomeElement dayOfWeek="Mon| Wed" />


Is it important to have | as separator? List values in XSD are separated
by space. Here is an example:

<xs:simpleTyp e name="dayOfWeek Type">
<xs:restricti on base="xs:string ">
<xs:enumerati on value="Mon"/>
<xs:enumerati on value="Wed"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="SomeEleme nt">
<xs:complexType >
<xs:attribute name="dayOfWeek " use="required">
<xs:simpleTyp e>
<xs:list itemType="dayOf WeekType"/>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>

Then you can list enumerated values:

<SomeElement dayOfWeek="Mon Wed"/>

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #3
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message
news:es******** ******@TK2MSFTN GP12.phx.gbl...
Is it important to have | as separator? List values in XSD are separated
by space. Here is an example:


Nope. I can live with a space. Thanks!

--
Keith
Nov 12 '05 #4
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message
news:es******** ******@TK2MSFTN GP12.phx.gbl...
Is it important to have | as separator? List values in XSD are separated
by space. Here is an example:


Nope. I can live with a space. Thanks!

--
Keith
Nov 12 '05 #5

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

Similar topics

0
936
by: Keith Hill | last post by:
Is there a way to represent a style enum in XML Schema? Say I have a flags enum like so: public enum dayOfWeek { Mon, Tue, Wed, All = Mon | Tue | Wed; }
1
1609
by: | last post by:
Would be nice to specify an incremenet or decremenet as an attribute in an enum so I can for example have the following... enum SomeEnum { A = 0, B, // 2 C, // 4 D /6
3
2553
by: Ignacio X. Domínguez | last post by:
Hi. I'm using the | operator to use multiple flags in a variable. For example: const int flag1 = 0x00000001; const int flag2 = 0x00000002; const int flag3 = 0x00000004; int Flags = flag2 | flag4 | flag1; Now I would like to remove flag2 from Flags without having to assign the
1
10518
by: Dwight.Dexter | last post by:
I have an enum variable. Is there some way to cast an int or BitArray and get my enum value? I have to communicate with an old C-style sever so I get an array of bits("0","1"). But I'm using an enum variable to store the data. public enum LaneCapabilities { MLT = 0, ACM = 1,
4
6685
by: Paul E Collins | last post by:
The help file says that "bit fields can be combined using a bitwise OR operation, whereas enumerated constants cannot", and yet this code works: enum Blah { a, b, c }; // without .... Blah x = Blah.a | Blah.b; So what is the purpose of the Flags attribute? I understand it's potentially useful for reflection, so that (for example) the IDE's IntelliSense knows which enums are meant to be combined, but does it
6
3423
by: Charles Law | last post by:
I have the following structure (for example) that I wish to convert for use in VB.NET. What would be the best way to do it? Ideally, it would convert directly to allow access to the bit fields in the same way as in C++, but I cannot see any mention of bit field declarations in VB.NET. <structure> typedef struct _DCB { DWORD DCBlength; DWORD BaudRate; DWORD fBinary :1;
2
2433
by: Chad | last post by:
I've used bitwise enums before (powers of 2) and have used AND and OR operator to determine which individual flags have been set, but I have never used the <Flags()> _ attribute What advantage does this give me? Thankoo
2
7413
by: Jigar.Patel | last post by:
Hi, I have following enum definition. public enum OperationTypes { All = 1, New = 2, View = 4,
2
3518
by: JB | last post by:
Hi All, I'm pulling my hair over this and could really do with a bit of help. I'm using various different enums as bit fields and I'd like to create a set of generic Functions or Subs to manipulate the bitfields. For instance: <Flags()_ Enum ActionFlags As Byte
0
8974
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9500
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9349
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8227
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6060
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4575
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.