473,800 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to deal with empty attributes?

Hi,

I want to know how I can deal with empty attributes, like this example:
<Spiral constant="">
</Spiral>

My Spiral implementation contains this code:
[System::Xml::Se rialization::Xm lIgnoreAttribut e]
bool constantSpecifi ed;
[System::Xml::Se rialization::Xm lAttributeAttri bute]
__property double get_constant();
__property void set_constant(do uble s);

As you can see, I'm using MC++. But when I try to de-serialize a Spiral
with empty constant, I get an exception: ``There is an error in XML
document (16, 120).'' What can I do? I don't want to change data type from
double to String, if I really don't have to. I don't really need the
constant attribute when de-serializing, but I want to write it when I
serialize.
Thanks for any help!

--
Daniel
Nov 12 '05 #1
1 1363
Daniel! We meet again.

If the schema says that the constant attribute is a double, then I think you
have some invalid XML there.
Regardless, I also think it should be possible to do some fancy footwork to
get the serialization to work.

This is an example for dealing with a nil Date.
http://www.winisp.net/cheeso/srcview...=XsiNilDate.cs
Same idea should apply to doubles.

-Dino

--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ OmitThis . m i c r o s o f t . c o m

"Daniel Lidström" <so*****@micros oft.com> wrote in message
news:19******** *************** ******@40tude.n et...
Hi,

I want to know how I can deal with empty attributes, like this example:
<Spiral constant="">
</Spiral>

My Spiral implementation contains this code:
[System::Xml::Se rialization::Xm lIgnoreAttribut e]
bool constantSpecifi ed;
[System::Xml::Se rialization::Xm lAttributeAttri bute]
__property double get_constant();
__property void set_constant(do uble s);

As you can see, I'm using MC++. But when I try to de-serialize a Spiral
with empty constant, I get an exception: ``There is an error in XML
document (16, 120).'' What can I do? I don't want to change data type from
double to String, if I really don't have to. I don't really need the
constant attribute when de-serializing, but I want to write it when I
serialize.
Thanks for any help!

--
Daniel

Nov 12 '05 #2

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

Similar topics

6
15223
by: Tung Wai Yip | last post by:
Can I add empty directory using zipfile? When I try to add a directory it complains that it is not a file. tung
3
1443
by: Jyrki Keisala | last post by:
I have an XML file which looks like this: <command name="Options" phrase="Options"> <key value="z" extended="NONE" qual="L-CTRL" pause="100" repeat="1" duration="200"/> </command> <command name="Command Room" phrase="Command Room"> <key extended="F2" pause="100" repeat="1" duration="200"/> </command>
5
454
by: Doug Holland | last post by:
Often you see code where an empty interface is used to indicate something about the class that realizes it. In the .NET world this can be done with custom attributes too, so which is better: public class SomeClass : IEmptyInterface or
39
4997
by: fleemo17 | last post by:
I'm wondering whether it's better to leave an alt tag blank (alt=" ") or specify something like "alt='spacer'" when referring to objects that merely help the layout of the page? -Fleemo
13
33673
by: could ildg | last post by:
I want to check if a folder named "foldername" is empty. I use os.listdir(foldername)== to do this, but it will be very slow if the folder has a lot of sub-files. Is there any efficient ways to do this? Thanks~
48
3384
by: Frederick Gotham | last post by:
The "toupper" function takes an int as an argument. That's not too irrational given that a character literal is of type "int" in C. (Although why it isn't of type "char" escapes me... ) The "toupper" function imposes a further constrait in that the value passed to it must be representable as a unsigned char. (If C does not require all character values to be positive, then again, this constrait too escapes me... ) Let's say we have the...
8
4794
by: yawnmoth | last post by:
Say I have the following HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <form action="">
0
1978
by: Thomas Wittek | last post by:
Hi! I'm using xsl:attribute-sets to reduce redundancy in my XSLT. An example from a transformation to XHTML (the attribute values are simply copied from input to output): <xsl:attribute-set name="cellhalign"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> </xsl:attribute>
1
2163
by: =?Utf-8?B?T2xpdmllciBNQVRST1Q=?= | last post by:
Hi, I would like the XMLCsvReader to generate XML without emtpy attributes when ColumnsAsAttributes property i set to true and corresponding CSV column is empty. Is it possible ? If not, Can I use an XSLT tranform to remove empty attributes ? TIA.
0
9551
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
10275
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
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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
6811
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
5471
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
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3
2945
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.