I've got a class that was generated from an xsd file which was originally generated from an xml file. The only issue is when I compile the project I get "Duplicate [atttibute] attribute" errors on the root class. The class attributes look like so:
/// <summary>
///Represents a strongly typed in-memory cache of data.
///</summary>
[global::System.Serializable()]
[global::System.ComponentModel.DesignerCategoryAttribute("code")]
[global::System.ComponentModel.ToolboxItem(true)]
[global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema")]
[global::System.Xml.Serialization.XmlRootAttribute("Maps")]
[global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")]
public partial class Maps : global::System.Data.DataSet {
The duplicate errors are on System.Serializable, System.Xml.Serialization.XmlRootAttribute("Maps") and System.ComponentModel.DesignerCategoryAttribute("code"). If I remove them I then can't access the xml file via the class.
drazic19
Member
529 Points
128 Posts
duplicate attributes error after xsd tool
May 07, 2010 10:09 AM|LINK
Hi,
I've got a class that was generated from an xsd file which was originally generated from an xml file. The only issue is when I compile the project I get "Duplicate [atttibute] attribute" errors on the root class. The class attributes look like so:
/// <summary> ///Represents a strongly typed in-memory cache of data. ///</summary> [global::System.Serializable()] [global::System.ComponentModel.DesignerCategoryAttribute("code")] [global::System.ComponentModel.ToolboxItem(true)] [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema")] [global::System.Xml.Serialization.XmlRootAttribute("Maps")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")] public partial class Maps : global::System.Data.DataSet {The duplicate errors are on System.Serializable, System.Xml.Serialization.XmlRootAttribute("Maps") and System.ComponentModel.DesignerCategoryAttribute("code"). If I remove them I then can't access the xml file via the class.
Any help would be greatly appreciated.
Thanks in advance.
Michael
kavita_khand...
Star
9767 Points
1930 Posts
Re: duplicate attributes error after xsd tool
May 07, 2010 02:17 PM|LINK
Can you show us your xsd?
I would love to change the world, but they wont give me the source code.
drazic19
Member
529 Points
128 Posts
Re: duplicate attributes error after xsd tool
May 07, 2010 02:57 PM|LINK
Hi,
Thanks for the reply. Here you go:
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.1 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ // // This source code was auto-generated by xsd, Version=4.0.30319.1. // namespace Company.Web.xml { using System.Xml.Serialization; /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] public partial class Maps { private MapsMap[] itemsField; /// <remarks/> [System.Xml.Serialization.XmlElementAttribute("Map", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public MapsMap[] Items { get { return this.itemsField; } set { this.itemsField = value; } } } /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class MapsMap { private MapsMapLicenseText[] licenseTextField; private MapsMapTilesTileSet[] tilesField; private string virtualDirectoryField; private string displayNameField; /// <remarks/> [System.Xml.Serialization.XmlElementAttribute("LicenseText", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)] public MapsMapLicenseText[] LicenseText { get { return this.licenseTextField; } set { this.licenseTextField = value; } } /// <remarks/> [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlArrayItemAttribute("TileSet", typeof(MapsMapTilesTileSet), Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)] public MapsMapTilesTileSet[] Tiles { get { return this.tilesField; } set { this.tilesField = value; } } /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string VirtualDirectory { get { return this.virtualDirectoryField; } set { this.virtualDirectoryField = value; } } /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string DisplayName { get { return this.displayNameField; } set { this.displayNameField = value; } } } /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class MapsMapLicenseText { private string imageField; private string valueField; /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string Image { get { return this.imageField; } set { this.imageField = value; } } /// <remarks/> [System.Xml.Serialization.XmlTextAttribute()] public string Value { get { return this.valueField; } set { this.valueField = value; } } } /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class MapsMapTilesTileSet { private string minZoomField; private string maxZoomField; private string locationField; /// <remarks/> [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string MinZoom { get { return this.minZoomField; } set { this.minZoomField = value; } } /// <remarks/> [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string MaxZoom { get { return this.maxZoomField; } set { this.maxZoomField = value; } } /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string Location { get { return this.locationField; } set { this.locationField = value; } } } }Thanks Michael.
drazic19
Member
529 Points
128 Posts
Re: duplicate attributes error after xsd tool
May 07, 2010 03:04 PM|LINK
Hi,
Sorry. Just realised I posted the class. The xsd is:
<?xml version="1.0" encoding="utf-8"?> <xs:schema id="Maps" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="Maps" msdata:IsDataSet="true" msdata:Locale="en-US"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="Map"> <xs:complexType> <xs:sequence> <xs:element name="LicenseText" nillable="true" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:simpleContent msdata:ColumnName="LicenseText_Text" msdata:Ordinal="1"> <xs:extension base="xs:string"> <xs:attribute name="Image" type="xs:string" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name="Tiles" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="TileSet" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="MinZoom" type="xs:string" minOccurs="0" msdata:Ordinal="0" /> <xs:element name="MaxZoom" type="xs:string" minOccurs="0" msdata:Ordinal="1" /> </xs:sequence> <xs:attribute name="Location" type="xs:string" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="VirtualDirectory" type="xs:string" /> <xs:attribute name="DisplayName" type="xs:string" /> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema>Thanks,
Michael
udayasankar
Member
17 Points
69 Posts
Re: duplicate attributes error after xsd tool
May 26, 2010 01:28 AM|LINK
Hai michael,
how to get the auto generated CS file for XSD file. i had created XSD file,but i was unable to create CS file.
is there any procedure to create it. please help on this.
Thanks in advance. Happy coding.
Agaran Sankar.
Blog: http://myasphelp.wordpress.com/ http://myyellowcity.blogspot.com/
drazic19
Member
529 Points
128 Posts
Re: duplicate attributes error after xsd tool
May 26, 2010 07:50 AM|LINK
Hi,
This microsoft page shows you how to use the xsd tool to generate a class:
http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.71).aspx
Thanks,
Michael
MrWhite79
Member
2 Points
1 Post
Re: duplicate attributes error after xsd tool
Nov 10, 2010 05:39 PM|LINK
Hi Michael,
I've got the exact same error... Did you ever found the cause?
Thanks,
Joren
ath2world
Member
6 Points
7 Posts
Re: duplicate attributes error after xsd tool
Feb 02, 2013 07:25 PM|LINK
I got the same issue, solved it by moving the xsd file outside "APP_Code" directory in my website.