473,385 Members | 1,474 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,385 software developers and data experts.

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::Serialization::XmlIgnoreAttribute]
bool constantSpecified;
[System::Xml::Serialization::XmlAttributeAttribute]
__property double get_constant();
__property void set_constant(double 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 1347
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*****@microsoft.com> wrote in message
news:19*****************************@40tude.net...
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::Serialization::XmlIgnoreAttribute]
bool constantSpecified;
[System::Xml::Serialization::XmlAttributeAttribute]
__property double get_constant();
__property void set_constant(double 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
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
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...
5
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: ...
39
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
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...
48
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...
8
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
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.