Просмотр исходного кода

* XmlSchemaExporter.cs: Don't create referenced element if it has already
been created (two types could be referencing the same schema element).

svn path=/trunk/mcs/; revision=22300

Lluis Sanchez 22 лет назад
Родитель
Сommit
6aa4b73c4e

+ 5 - 0
mcs/class/System.XML/System.Xml.Serialization/ChangeLog

@@ -1,3 +1,8 @@
+2004-01-20  Lluis Sanchez Gual  <[email protected]>
+
+	* XmlSchemaExporter.cs: Don't create referenced element if it has already
+	  been created (two types could be referencing the same schema element).
+
 2004-01-19  Lluis Sanchez Gual  <[email protected]>
 
 	* XmlReflectionImporter.cs: Read IsNullable flag from XmlArrayAttribute.

+ 8 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlSchemaExporter.cs

@@ -307,6 +307,10 @@ namespace System.Xml.Serialization {
 			else
 			{
 				sat.RefName = new XmlQualifiedName (attinfo.AttributeName, attinfo.Namespace);
+				foreach (XmlSchemaObject ob in memberSchema.Items)
+					if (ob is XmlSchemaAttribute && ((XmlSchemaAttribute)ob).Name == attinfo.AttributeName)
+						return sat;
+						
 				memberSchema.Items.Add (GetSchemaAttribute (memberSchema, attinfo));
 			}
 			return sat;
@@ -400,6 +404,10 @@ namespace System.Xml.Serialization {
 			else
 			{
 				selem.RefName = new XmlQualifiedName (einfo.ElementName, einfo.Namespace);
+				foreach (XmlSchemaObject ob in memberSchema.Items)
+					if (ob is XmlSchemaElement && ((XmlSchemaElement)ob).Name == einfo.ElementName)
+						return selem;
+						
 				AddSchemaElement (memberSchema.Items, memberSchema, einfo, defaultValue, false);
 			}
 			return selem;