Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - bug within System.Xml.Serialization? [Thread Next] Re: bug within System.Xml.Serialization?To: NULL Date: 4/5/2006 12:42:00 AM
The innerException says:
- InnerException {"'PROTOCOL-TYPE' is an invalid value for the
XmlElementAttribute.DataType property. The property may only be specified
for primitive types."} System.Exception {System.InvalidOperationException}
According to the documentation for DataType, it is about disambiguating the
xsd type for primitive types only that map to CLR strings or are otherwise
ambiguous. It is not a way to specify CLR enums to XSD simpleType mappings.
But if you are just trying to rename the XSD type from PROTOCOL-TYPE to the
CLR type PROTOCOLTYPEPOLICY, then use the TypeName attribute:
[System.Xml.Serialization.XmlTypeAttribute(TypeName="PROTOCOL-TYPE")]
public enum PROTOCOLTYPE {
hugo,
lulli,
}
And remove the DataType attribute all together.
"ankaiser" <ankaiser@d...> wrote in message
news:16B8F083-F1A5-4546-B2FA-CC73874997B9@m......
> hello - i am just a beginner of xml,
>
> i want to produce the following xml-output:
>
> <PROTOCOL xsi:type="PROTOCOL-TYPE">hugo</PROTOCOL>
>
> with the following c#-source:
>
> public enum PROTOCOLTYPEPOLICY
> {
> hugo,
> lulli
> }
>
> [XmlElement(DataType = "PROTOCOLTYPEPOLICY")]
> public PROTOCOLTYPEPOLICY PROTOCOL;
>
> why does it not work?
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
