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

XmlSerialzer error when multiple nillable elements of userdefined

Hi i am getting the following error while using XMLSerializer
XmlSerializer ser = new XmlSerializer(typeof(Person));

ERROR:
Unable to generate a temporary class (result=1).
error CS0266: Cannot implicitly convert type 'XSD.BiodataGender?' to
'XSD.BiodataRace?'. An explicit conversion exists (are you missing a cast?)

I am getting the above error when my xsd has multiple nillable elements of
userdefined type. If I change the type of either race or gender to String i
am getting any error. temporary class is generated easily

MY XSD :
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema targetNamespace="http://my/ex" xmlns:version1="http://my/ex"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="person" type="version1:Person" />
<xsd:complexType name="Person">
<xsd:sequence>
<xsd:element name="biodata" type="version1:Biodata" minOccurs="1"
maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Biodata">
<xsd:sequence>
<xsd:element name="gender" nillable="true">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="M" />
<xsd:enumeration value="F" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="race" nillable="true">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="AI" />
<xsd:enumeration value="AS" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

Code Generated by xsd.exe:

namespace XSD
{

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("cx sc", "0.57.0.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://my/ex")]
[System.Xml.Serialization.XmlRootAttribute("person" ,
Namespace="http://my/ex", IsNullable=false)]
public partial class Person
{
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
public Biodata biodata;
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("cx sc", "0.57.0.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://my/ex")]
public partial class Biodata
{
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
public System.Nullable<BiodataGendergender;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
public System.Nullable<BiodataRacerace;
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("cx sc", "0.57.0.0")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="http://my/ex")]
public enum BiodataGender
{
/// <remarks/>
M,
/// <remarks/>
F,
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("cx sc", "0.57.0.0")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="http://my/ex")]
public enum BiodataRace
{
/// <remarks/>
AI,
/// <remarks/>
AS,
}
}
Nov 9 '07 #1
0 3039

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

Similar topics

3
by: Marty McDonald | last post by:
If I try to validate this xml... <?xml version="1.0" encoding="utf-8" ?> <a:FuncalcParameters xmlns:a="http://www.somewhere.fun.com/Funcalc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
1
by: tushar | last post by:
Hi I am trying to use XMLSerialzer class to generate serializable class for following schema. <xs:element name="KeyIdentifiers" minOccurs="0" maxOccurs="unbounded"> <xs:complexType>...
3
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb)....
7
by: Jorgen Haukland, Norway | last post by:
Hi, I have created a Java webservice which runs in IBM WebSphere appserver. I take the WSDL-file and create a VS.NET WinForm application and calls the service running on my PC and everything...
1
by: manfred | last post by:
Hi Together, I tried to build a webservice proxy using a wsdl, generated in the sun/java world. I used the .Net 2003 Version, choosing there VC++. The steps I did: 1. Visual C++ Projekte /...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
1
by: Vishuonline | last post by:
Guys, I have had some experience in working with webservices created in .NET but this is the first time I am trying out one made in Java. When I run the wsdl exe to create a proxy class for...
3
by: Jeremy Chapman | last post by:
I've writtin a very simple web service in axis which returns an array of classes. I consume it in a .net app. When receiving the response, my .net app generates an error "Cannot assign object...
0
by: =?Utf-8?B?a3Jpc2huYQ==?= | last post by:
Hi i am getting the following error while using XMLSerializer XmlSerializer ser = new XmlSerializer(typeof(Person)); ERROR: Unable to generate a temporary class (result=1). error CS0266: Cannot...
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:
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
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
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: 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
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...

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.