473,796 Members | 2,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Schema representation of a "bitmask" type?

Hi

I need to represent custom type system (ints, bytes, chars, enums,
bitmasks, arrays and some other types) in xml. It is easy to see how to
represent enums in xml (using xs:enumeration) , the same is true for
numeric types. Even arrays have an obvious description in schema:

<complexType name="IntArray" >
<sequence>
<element name="item" type="int" minOccurs="0" maxOccurs="unbo unded"/>
</sequence>
</complexType>

But how about bitmasks? What's the most beautiful way to represent a
bitmask where values have names? It's just like enumeration but the
value at any time can be a disjunction of any number of valid names.
For example: if we have x = 0x01, y = 0x02 etc then the value may be
either x, or x|y, or y etc.. but it can not be specified with 0x01. I
don't think having "<myAttribute>x |y</myAttribute>" in the xml document
is a good idea. Any suggestions?

Cheers,
Kapitan

Jul 20 '05 #1
1 3222
OK, here is what I come up with:

<xs:simpleTyp e name="MyBitmapT ype">
<xs:choice>
<xs:element name="item" minOccurs="1" maxOccurs="unbo unded">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:enumerati on value="firstVal ue"/>
<xs:enumerati on value="secondVa lue"/>
<xs:enumerati on value="thirdVal ue"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:choice>
</xs:simpleType>
In this case something like:

<?xml version="1.0" encoding="UTF-8"?>
<test>
<item>firstValu e</item>
<item>secondVal ue</item>
</test>

can be validated (which can be understood as "firstValue | secondValue").
Unfortunately, it validates the following thing as well:

<?xml version="1.0" encoding="UTF-8"?>
<test>
<item>firstValu e</item>
<item>firstValu e</item>
</test>

which is not exactly wrong (as you can do "firstValue | firstValue" and
the result will be OK), but it is not pretty... any suggestions?

Andrey Brozhko wrote:
Hi

I need to represent custom type system (ints, bytes, chars, enums,
bitmasks, arrays and some other types) in xml. It is easy to see how to
represent enums in xml (using xs:enumeration) , the same is true for
numeric types. Even arrays have an obvious description in schema:

<complexType name="IntArray" >
<sequence>
<element name="item" type="int" minOccurs="0" maxOccurs="unbo unded"/>
</sequence>
</complexType>

But how about bitmasks? What's the most beautiful way to represent a
bitmask where values have names? It's just like enumeration but the
value at any time can be a disjunction of any number of valid names.
For example: if we have x = 0x01, y = 0x02 etc then the value may be
either x, or x|y, or y etc.. but it can not be specified with 0x01. I
don't think having "<myAttribute>x |y</myAttribute>" in the xml document
is a good idea. Any suggestions?

Cheers,
Kapitan

Jul 20 '05 #2

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

Similar topics

5
724
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash (DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name date) <asp:DataGrid id="RssNewsGrid"
6
6467
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash (DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name date) <asp:DataGrid id="RssNewsGrid"
12
2052
by: spibou | last post by:
Why is a pointer allowed to point to one position past the end of an array but not to one position before the beginning of an array ? Is there any reason why the former is more useful than the later ? Spiros Bousbouras
1
1120
by: SoftwareTester | last post by:
I have following namespace Mine.Bits { public static class Bits {
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10456
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
10230
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...
0
9052
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
6788
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
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.