Browse Source

2002-06-18 Dwivedi, Ajay kumar <[email protected]>
* XmlSchema: The Read and Write methods are no more [MonoTODO] :)

* XmlSchemaAppInfo: Xml Markup is now being read.

* XmlSchemaDocumentation: Xml Markup is now being read.

* All: Unhandled attributes are being handled properly.

* All: Reordered the properties in all cs files to match with MS
Implementation. This was required since the order is importatnt
for the XmlSerializer.

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

Ajay kumar Dwivedi 23 years ago
parent
commit
b0729d1659
58 changed files with 568 additions and 645 deletions
  1. 2 2
      mcs/class/System.XML/System.Xml.Schema/BUGS.txt
  2. 13 0
      mcs/class/System.XML/System.Xml.Schema/ChangeLog
  3. 89 79
      mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs
  4. 4 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs
  5. 22 9
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs
  6. 26 11
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs
  7. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs
  8. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs
  9. 21 13
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs
  10. 25 23
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs
  11. 10 14
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs
  12. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs
  13. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs
  14. 4 4
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs
  15. 9 13
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs
  16. 13 17
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs
  17. 13 17
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
  18. 32 35
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
  19. 13 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs
  20. 29 42
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs
  21. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs
  22. 26 13
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs
  23. 7 7
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs
  24. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs
  25. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs
  26. 1 0
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs
  27. 7 11
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs
  28. 9 9
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs
  29. 9 13
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaImport.cs
  30. 10 13
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs
  31. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs
  32. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs
  33. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs
  34. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs
  35. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs
  36. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs
  37. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs
  38. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs
  39. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs
  40. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs
  41. 3 1
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs
  42. 27 26
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs
  43. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs
  44. 17 17
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs
  45. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs
  46. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs
  47. 11 14
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs
  48. 17 21
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs
  49. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs
  50. 10 14
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs
  51. 9 13
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
  52. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs
  53. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs
  54. 17 16
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs
  55. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs
  56. 11 10
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs
  57. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs
  58. 2 6
      mcs/class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs

+ 2 - 2
mcs/class/System.XML/System.Xml.Schema/BUGS.txt

@@ -1,5 +1,5 @@
 Bugs in Implementation:
 
 // None of the XmlSchemaObjects except the XmlSchema populate XmlSerializerNamespaces.
-2. Non schema attributes are not being handled. Need an internal XmlAttribute constructor.
-3. Documentation and appInfo's Markup is not being read in the Read() Method.
+//2. Non schema attributes are not being handled. Need an internal XmlAttribute constructor.
+//3. Documentation and appInfo's Markup is not being read in the Read() Method.

+ 13 - 0
mcs/class/System.XML/System.Xml.Schema/ChangeLog

@@ -1,3 +1,16 @@
+2002-06-18  Dwivedi, Ajay kumar <[email protected]>
+	* XmlSchema: The Read and Write methods are no more [MonoTODO] :)
+	
+	* XmlSchemaAppInfo: Xml Markup is now being read.
+	
+	* XmlSchemaDocumentation: Xml Markup is now being read.
+
+	* All: Unhandled attributes are being handled properly.
+	       
+	* All: Reordered the properties in all cs files to match with MS
+	       Implementation. This was required since the order is importatnt
+	       for the XmlSerializer.
+	
 2002-06-14  Dwivedi, Ajay kumar <[email protected]>
 	* General: Fixed a few more Bugs
 

+ 89 - 79
mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs

@@ -1,6 +1,7 @@
 // Author: Dwivedi, Ajay kumar
 //            [email protected]
 using System;
+using System.Collections;
 using System.Xml;
 using System.IO;
 using System.Xml.Serialization;
@@ -15,8 +16,8 @@ namespace System.Xml.Schema
 	public class XmlSchema : XmlSchemaObject
 	{
 		//public constants
-		public const string InstanceNamespace = "http://www.w3.org/2001/XMLSchema-instance";
 		public const string Namespace = "http://www.w3.org/2001/XMLSchema";
+		public const string InstanceNamespace = "http://www.w3.org/2001/XMLSchema-instance";
 
 		//private fields
 		private XmlSchemaForm attributeFormDefault ;
@@ -68,18 +69,6 @@ namespace System.Xml.Schema
 			get{ return attributeFormDefault; }
 			set{ this.attributeFormDefault = value;}
 		}
-
-		[XmlIgnore]
-		public XmlSchemaObjectTable AttributeGroups 
-		{
-			get{ return attributeGroups; }
-		}
-		
-		[XmlIgnore]
-		public XmlSchemaObjectTable Attributes 
-		{
-			get{ return attributes;}
-		}
 		
 		[DefaultValue(XmlSchemaDerivationMethod.None)]
 		[System.Xml.Serialization.XmlAttribute("blockDefault")]
@@ -88,20 +77,6 @@ namespace System.Xml.Schema
 			get{ return blockDefault;}
 			set{ blockDefault = value;}
 		}
-		
-		[DefaultValue(XmlSchemaForm.None)]
-		[System.Xml.Serialization.XmlAttribute("elementFormDefault")]
-		public XmlSchemaForm ElementFormDefault 
-		{
-			get{ return elementFormDefault;}
-			set{ elementFormDefault = value;}
-		}
-
-		[XmlIgnore]
-		public XmlSchemaObjectTable Elements 
-		{
-			get{ return elements;}
-		}
 
 		[DefaultValue(XmlSchemaDerivationMethod.None)]
 		[System.Xml.Serialization.XmlAttribute("finalDefault")]
@@ -110,18 +85,27 @@ namespace System.Xml.Schema
 			get{ return finalDefault;}
 			set{ finalDefault = value;}
 		}
-
-		[XmlIgnore]
-		public XmlSchemaObjectTable Groups 
+		
+		[DefaultValue(XmlSchemaForm.None)]
+		[System.Xml.Serialization.XmlAttribute("elementFormDefault")]
+		public XmlSchemaForm ElementFormDefault 
 		{
-			get{ return groups;}
+			get{ return elementFormDefault;}
+			set{ elementFormDefault = value;}
 		}
-
-		[System.Xml.Serialization.XmlAttribute("id")]
-		public string Id 
+		
+		[System.Xml.Serialization.XmlAttribute("targetNamespace")]
+		public string TargetNamespace 
 		{
-			get{ return id;}
-			set{ id = value;}
+			get{ return targetNamespace;}
+			set{ targetNamespace = value;}
+		}
+		
+		[System.Xml.Serialization.XmlAttribute("version")]
+		public string Version 
+		{
+			get{ return version;}
+			set{ version = value;}
 		}
 		
 		[XmlElement("include",typeof(XmlSchemaInclude),Namespace="http://www.w3.org/2001/XMLSchema")]
@@ -132,12 +116,6 @@ namespace System.Xml.Schema
 			get{ return includes;}
 		}
 		
-		[XmlIgnore]
-		public bool IsCompiled 
-		{
-			get{ return isCompiled;}
-		}
-		
 		[XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
 		[XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]
 		[XmlElement("group",typeof(XmlSchemaGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
@@ -152,11 +130,23 @@ namespace System.Xml.Schema
 		{
 			get{ return items;}
 		}
-		
+
 		[XmlIgnore]
-		public XmlSchemaObjectTable Notations 
+		public bool IsCompiled 
 		{
-			get{ return notations;}
+			get{ return isCompiled;}
+		}
+
+		[XmlIgnore]
+		public XmlSchemaObjectTable Attributes 
+		{
+			get{ return attributes;}
+		}
+
+		[XmlIgnore]
+		public XmlSchemaObjectTable AttributeGroups 
+		{
+			get{ return attributeGroups; }
 		}
 		
 		[XmlIgnore]
@@ -164,26 +154,49 @@ namespace System.Xml.Schema
 		{
 			get{ return schemaTypes; }
 		}
-		
-		[System.Xml.Serialization.XmlAttribute("targetNamespace")]
-		public string TargetNamespace 
+
+		[XmlIgnore]
+		public XmlSchemaObjectTable Elements 
 		{
-			get{ return targetNamespace;}
-			set{ targetNamespace = value;}
+			get{ return elements;}
+		}
+
+		[System.Xml.Serialization.XmlAttribute("id")]
+		public string Id 
+		{
+			get{ return id;}
+			set{ id = value;}
 		}
 		
 		[XmlAnyAttribute]
 		public XmlAttribute[] UnhandledAttributes 
 		{
-			get{ return unhandledAttributes;}
-			set{ unhandledAttributes = value;}
+			get
+			{
+				if(unhandledAttributeList != null)
+				{
+					unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+					unhandledAttributeList = null;
+				}
+				return unhandledAttributes;
+			}
+			set
+			{ 
+				unhandledAttributes = value; 
+				unhandledAttributeList = null;
+			}
+		}
+
+		[XmlIgnore]
+		public XmlSchemaObjectTable Groups 
+		{
+			get{ return groups;}
 		}
 		
-		[System.Xml.Serialization.XmlAttribute("version")]
-		public string Version 
+		[XmlIgnore]
+		public XmlSchemaObjectTable Notations 
 		{
-			get{ return version;}
-			set{ version = value;}
+			get{ return notations;}
 		}
 
 		// New attribute defined in W3C schema element
@@ -196,6 +209,8 @@ namespace System.Xml.Schema
 
 		#endregion
 
+		#region Compile
+
 		// Methods
 		/// <summary>
 		/// This compile method does two things:
@@ -382,19 +397,11 @@ namespace System.Xml.Schema
 			Validate(handler);
 		}
 
+		#endregion
+
 		[MonoTODO]
-		protected void Validate(ValidationEventHandler handler)
+		private void Validate(ValidationEventHandler handler)
 		{
-
-			foreach(XmlSchemaObject obj in Includes)
-			{
-				
-			}
-
-			//				foreach(XmlSchemaAnnotation ann in ??????)
-			//				{
-			//					ann.Validate(handler);
-			//				}
 			foreach(XmlSchemaAttribute attr in Attributes.Values)
 			{
 				attr.Validate(handler);
@@ -426,6 +433,9 @@ namespace System.Xml.Schema
 			}
 		}
 
+
+		#region Read 
+
 		public static XmlSchema Read(TextReader reader, ValidationEventHandler validationEventHandler)
 		{
 			return Read(new XmlTextReader(reader),validationEventHandler);
@@ -479,8 +489,8 @@ namespace System.Xml.Schema
 
 		private static void ReadAttributes(XmlSchema schema, XmlSchemaReader reader, ValidationEventHandler h)
 		{
-			Exception ex; 
-			
+			Exception ex;
+
 			reader.MoveToElement();
 			while(reader.MoveToNextAttribute())
 			{
@@ -519,15 +529,12 @@ namespace System.Xml.Schema
 						schema.language = reader.Value;
 						break;
 					default:
-						if(reader.Prefix == "xmlns")
-							schema.Namespaces.Add(reader.LocalName, reader.Value);
-						else if(reader.Name == "xmlns")
-							schema.Namespaces.Add("",reader.Value);
-						else if(reader.Prefix == "" || reader.NamespaceURI == XmlSchema.Namespace)
+						if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 							error(h, reader.Name + " attribute is not allowed in schema element",null);
-//					FIXME: There is no public constructor for XmlAttribute. Nor is there a way to access the XmlNode
-//						else
-//							unknown.Add(new XmlAttibute());
+						else
+						{
+							XmlSchemaUtil.ReadUnhandledAttribute(reader,schema);
+						}
 						break;
 				}
 			}
@@ -644,6 +651,9 @@ namespace System.Xml.Schema
 				reader.RaiseInvalidElementError();
 			}
 		}
+		#endregion
+
+		#region write
 
 		public void Write(System.IO.Stream stream)
 		{
@@ -667,7 +677,6 @@ namespace System.Xml.Schema
 			xwriter.Formatting = Formatting.Indented;
 			Write(xwriter,namespaceManager);
 		}
-		[MonoTODO]
 		public void Write(System.Xml.XmlWriter writer, System.Xml.XmlNamespaceManager namespaceManager)
 		{
 			if(Namespaces == null)
@@ -690,5 +699,6 @@ namespace System.Xml.Schema
 			xser.Serialize(writer,this,Namespaces);
 			writer.Flush();
 		}
+		#endregion
 	}
-}
+}

+ 4 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs

@@ -18,11 +18,13 @@ namespace System.Xml.Schema
 		{
 			items = new XmlSchemaObjectCollection();
 		}
+
 		[XmlElement("element",typeof(XmlSchemaElement),Namespace="http://www.w3.org/2001/XMLSchema")]
 		public override XmlSchemaObjectCollection Items 
 		{
 			get{ return items; }
 		}
+
 		/// <remarks>
 		/// 1. MaxOccurs must be one. (default is also one)
 		/// 2. MinOccurs must be zero or one.
@@ -115,17 +117,13 @@ namespace System.Xml.Schema
 						error(h,reader.Value + " is an invalid value for minOccurs",e);
 					}
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for all",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						all.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						all.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,all);
 				}
 			}
 			

+ 22 - 9
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs

@@ -1,6 +1,7 @@
 // Author: Dwivedi, Ajay kumar
 //            [email protected]
 using System;
+using System.Collections;
 using System.Xml;
 using System.Xml.Serialization;
 
@@ -19,13 +20,6 @@ namespace System.Xml.Schema
 		public XmlSchemaAnnotated()
 		{}
 		
-		[XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaAnnotation Annotation 
-		{ 
-			get{ return  annotation; } 
-			set{ annotation = value; } 
-		}
-		
 		[System.Xml.Serialization.XmlAttribute("id")]
 		public string Id 
 		{ 
@@ -33,11 +27,30 @@ namespace System.Xml.Schema
 			set{ id = value; } 
 		}
 		
+		[XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaAnnotation Annotation 
+		{ 
+			get{ return  annotation; } 
+			set{ annotation = value; } 
+		}
+		
 		[XmlAnyAttribute]
 		public XmlAttribute[] UnhandledAttributes 
 		{ 
-			get{ return unhandledAttributes; } 
-			set{ unhandledAttributes = value; } 
+			get
+			{
+				if(unhandledAttributeList != null)
+				{
+					unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+					unhandledAttributeList = null;
+				}
+				return unhandledAttributes;
+			}
+			set
+			{ 
+				unhandledAttributes = value; 
+				unhandledAttributeList = null;
+			}
 		}
 	}
 }

+ 26 - 11
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs

@@ -1,6 +1,7 @@
 // Author: Dwivedi, Ajay kumar
 //            [email protected]
 using System;
+using System.Collections;
 using System.Xml;
 using System.Xml.Serialization;
 
@@ -37,8 +38,20 @@ namespace System.Xml.Schema
 		[XmlAnyAttribute]
 		public XmlAttribute[] UnhandledAttributes 
 		{
-			get{ return  unhandledAttributes; } 
-			set{ unhandledAttributes = value; }
+			get
+			{
+				if(unhandledAttributeList != null)
+				{
+					unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+					unhandledAttributeList = null;
+				}
+				return unhandledAttributes;
+			}
+			set
+			{ 
+				unhandledAttributes = value; 
+				unhandledAttributeList = null;
+			}
 		}
 
 		[MonoTODO]
@@ -81,17 +94,13 @@ namespace System.Xml.Schema
 				{
 					annotation.Id = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for annotation",null);
 				}
 				else
 				{
-											if(reader.Prefix == "xmlns")
-												annotation.Namespaces.Add(reader.LocalName, reader.Value);
-											else if(reader.Name == "xmlns")
-												annotation.Namespaces.Add("",reader.Value);
-						//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,annotation);
 				}
 			}
 			
@@ -100,8 +109,14 @@ namespace System.Xml.Schema
 				return annotation;
 
 			//Content: (appinfo | documentation)*
-			while(reader.ReadNextElement())
+			bool skip = false;
+			while(!reader.EOF)
 			{
+				if(skip) 
+					skip=false;
+				else 
+					reader.ReadNextElement();
+
 				if(reader.NodeType == XmlNodeType.EndElement)
 				{
 					if(reader.LocalName != xmlname)
@@ -110,14 +125,14 @@ namespace System.Xml.Schema
 				}
 				if(reader.LocalName == "appinfo")
 				{
-					XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader,h);
+					XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader,h,out skip);
 					if(appinfo != null)
 						annotation.items.Add(appinfo);
 					continue;
 				}
 				if(reader.LocalName == "documentation")
 				{
-					XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader,h);
+					XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader,h, out skip);
 					if(documentation != null)
 						annotation.items.Add(documentation);
 					continue;

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs

@@ -152,17 +152,13 @@ namespace System.Xml.Schema
 					if(innerex != null)
 						error(h, reader.Value + " is not a valid value for processContents",innerex);
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for any",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						any.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						any.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,any);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs

@@ -129,17 +129,13 @@ namespace System.Xml.Schema
 					if(innerex != null)
 						error(h, reader.Value + " is not a valid value for processContents",innerex);
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for anyAttribute",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						any.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						any.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,any);
 				}
 			}
 			

+ 21 - 13
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs

@@ -18,6 +18,13 @@ namespace System.Xml.Schema
 		{
 		}
 
+		[System.Xml.Serialization.XmlAttribute("source")]
+		public string Source 
+		{
+			get{ return  source; } 
+			set{ source = value; }
+		}
+
 		[XmlAnyElement]
 		[XmlText]
 		public XmlNode[] Markup 
@@ -26,19 +33,13 @@ namespace System.Xml.Schema
 			set{ markup = value; }
 		}
 
-		[System.Xml.Serialization.XmlAttribute("source")]
-		public string Source 
-		{
-			get{ return  source; } 
-			set{ source = value; }
-		}
-
 		//<appinfo
 		//  source = anyURI>
 		//  Content: ({any})*
 		//</appinfo>
-		internal static XmlSchemaAppInfo Read(XmlSchemaReader reader, ValidationEventHandler h)
+		internal static XmlSchemaAppInfo Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip)
 		{
+			skip = false;
 			XmlSchemaAppInfo appinfo = new XmlSchemaAppInfo();
 			reader.MoveToElement();
 
@@ -70,13 +71,20 @@ namespace System.Xml.Schema
 				return appinfo;
 
 			//Content {any}*
-			//FIXME: How to handle {any}* content
-			while(reader.Read())
+			//FIXME: This is a pure Quick Hack; There must be a another method;
+			XmlDocument xmldoc = new XmlDocument();
+			xmldoc.AppendChild(xmldoc.ReadNode(reader));
+			XmlNode root = xmldoc.FirstChild;
+			if(root != null && root.ChildNodes != null)
 			{
-				if(reader.NodeType == XmlNodeType.EndElement && reader.NamespaceURI == XmlSchema.Namespace && 
-					reader.LocalName == "appinfo")
-					break;
+				appinfo.Markup = new XmlNode[root.ChildNodes.Count];
+				for(int i=0;i<root.ChildNodes.Count;i++)
+				{
+					appinfo.Markup[i] = root.ChildNodes[i];
+				}
 			}
+			if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)
+				skip = true;
 			return appinfo;
 		}
 	}

+ 25 - 23
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs

@@ -38,11 +38,7 @@ namespace System.Xml.Schema
 		}
 
 		// Properties
-		[XmlIgnore]
-		public object AttributeType 
-		{ //FIXME: This is not correct. Is it?
-			get{ return attributeType; }
-		}
+		#region Properties
 
 		[DefaultValue(null)]
 		[System.Xml.Serialization.XmlAttribute("default")]
@@ -85,11 +81,6 @@ namespace System.Xml.Schema
 				name  = value;
 			}
 		}
-		[XmlIgnore]
-		public XmlQualifiedName QualifiedName 
-		{
-			get{ return qualifiedName;}
-		}
 
 		[System.Xml.Serialization.XmlAttribute("ref")]
 		public XmlQualifiedName RefName 
@@ -100,13 +91,6 @@ namespace System.Xml.Schema
 				refName = value; 
 			}
 		}
-
-		[XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaSimpleType SchemaType 
-		{
-			get{ return schemaType;}
-			set{ schemaType = value;}
-		}
 		
 		[System.Xml.Serialization.XmlAttribute("type")]
 		public XmlQualifiedName SchemaTypeName 
@@ -115,6 +99,13 @@ namespace System.Xml.Schema
 			set{ schemaTypeName = value;}
 		}
 
+		[XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaSimpleType SchemaType 
+		{
+			get{ return schemaType;}
+			set{ schemaType = value;}
+		}
+
 		[DefaultValue(XmlSchemaUse.None)]
 		[System.Xml.Serialization.XmlAttribute("use")]
 		public XmlSchemaUse Use 
@@ -122,6 +113,21 @@ namespace System.Xml.Schema
 			get{ return use;}
 			set{ use = value;}
 		}
+
+		[XmlIgnore]
+		public XmlQualifiedName QualifiedName 
+		{
+			get{ return qualifiedName;}
+		}
+
+		[XmlIgnore]
+		public object AttributeType 
+		{ //FIXME: This is not correct. Is it?
+			get{ return attributeType; }
+		}
+
+		#endregion
+
 		/// <remarks>
 		/// For an attribute:
 		///  a) If the parent is schema 
@@ -329,17 +335,13 @@ namespace System.Xml.Schema
 					if(innerex != null)
 						error(h, reader.Value + " is not a valid value for use attribute", innerex);
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for attribute",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						attribute.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						attribute.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,attribute);
 				}
 			}
 			

+ 10 - 14
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs

@@ -23,11 +23,11 @@ namespace System.Xml.Schema
 			attributes  = new XmlSchemaObjectCollection();
 		}
 
-		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaAnyAttribute AnyAttribute 
+		[System.Xml.Serialization.XmlAttribute("name")]
+		public string Name 
 		{
-			get{ return any;}
-			set{ any = value;}
+			get{ return name;}
+			set{ name = value;}
 		}
 
 		[XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
@@ -37,11 +37,11 @@ namespace System.Xml.Schema
 			get{ return attributes;}
 		}
 
-		[System.Xml.Serialization.XmlAttribute("name")]
-		public string Name 
+		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaAnyAttribute AnyAttribute 
 		{
-			get{ return name;}
-			set{ name = value;}
+			get{ return any;}
+			set{ any = value;}
 		}
 
 		//Undocumented property
@@ -140,17 +140,13 @@ namespace System.Xml.Schema
 				{
 					attrgrp.name = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						attrgrp.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						attrgrp.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs

@@ -87,17 +87,13 @@ namespace System.Xml.Schema
 					if(innerex != null)
 						error(h, reader.Value + " is not a valid value for ref attribute",innerex);
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						attrgrp.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						attrgrp.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs

@@ -120,17 +120,13 @@ namespace System.Xml.Schema
 						error(h,reader.Value + " is an invalid value for minOccurs",e);
 					}
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for choice",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						choice.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						choice.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,choice);
 				}
 			}
 			

+ 4 - 4
mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs

@@ -36,18 +36,18 @@ namespace System.Xml.Schema
 				return this.htable.Count; 
 			}
 		}
-		public XmlSchema this[ string ns ] 
+		public XmlNameTable NameTable 
 		{ 
 			get
 			{
-				return (XmlSchema) this.htable[ns];
+				return this.ntable;
 			}
 		}
-		public XmlNameTable NameTable 
+		public XmlSchema this[ string ns ] 
 		{ 
 			get
 			{
-				return this.ntable;
+				return (XmlSchema) this.htable[ns];
 			}
 		}
 

+ 9 - 13
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs

@@ -18,6 +18,13 @@ namespace System.Xml.Schema
 		public XmlSchemaComplexContent()
 		{}
 
+		[System.Xml.Serialization.XmlAttribute("mixed")]
+		public bool IsMixed 
+		{
+			get{ return  isMixed; } 
+			set{ isMixed = value; }
+		}
+
 		[XmlElement("restriction",typeof(XmlSchemaComplexContentRestriction),Namespace="http://www.w3.org/2001/XMLSchema")]
 		[XmlElement("extension",typeof(XmlSchemaComplexContentExtension),Namespace="http://www.w3.org/2001/XMLSchema")]
 		public override XmlSchemaContent Content 
@@ -26,13 +33,6 @@ namespace System.Xml.Schema
 			set{ content = value; }
 		}
 
-		[System.Xml.Serialization.XmlAttribute("mixed")]
-		public bool IsMixed 
-		{
-			get{ return  isMixed; } 
-			set{ isMixed = value; }
-		}
-
 		/// <remarks>
 		/// 1. Content must be present
 		/// </remarks>
@@ -104,17 +104,13 @@ namespace System.Xml.Schema
 					if(innerex != null)
 						error(h,reader.Value + " is an invalid value for mixed",innerex);
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for complexContent",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						complex.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						complex.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,complex);
 				}
 			}
 			

+ 13 - 17
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs

@@ -30,11 +30,14 @@ namespace System.Xml.Schema
 			set{ baseTypeName = value; }
 		}
 
-		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaAnyAttribute AnyAttribute 
+		[XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+		[XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
+		[XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+		[XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaParticle Particle
 		{
-			get{ return any; }
-			set{ any = value;}
+			get{ return  particle; }
+			set{ particle = value; }
 		}
 
 		[XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
@@ -44,14 +47,11 @@ namespace System.Xml.Schema
 			get{ return attributes; }
 		}
 
-		[XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
-		[XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
-		[XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
-		[XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaParticle Particle
+		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaAnyAttribute AnyAttribute 
 		{
-			get{ return  particle; }
-			set{ particle = value; }
+			get{ return any; }
+			set{ any = value;}
 		}
 
 		/// <remarks>
@@ -152,17 +152,13 @@ namespace System.Xml.Schema
 				{
 					extension.Id = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for extension",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						extension.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						extension.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,extension);
 				}
 			}
 			

+ 13 - 17
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs

@@ -30,11 +30,14 @@ namespace System.Xml.Schema
 			set{ baseTypeName = value; }
 		}
 
-		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaAnyAttribute AnyAttribute 
+		[XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+		[XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
+		[XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+		[XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaParticle Particle 
 		{
-			get{ return  any; }
-			set{ any = value; }
+			get{ return  particle; }
+			set{ particle = value; }
 		}
 
 		[XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
@@ -44,14 +47,11 @@ namespace System.Xml.Schema
 			get{ return attributes; }
 		}
 
-		[XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
-		[XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
-		[XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
-		[XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaParticle Particle 
+		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaAnyAttribute AnyAttribute 
 		{
-			get{ return  particle; }
-			set{ particle = value; }
+			get{ return  any; }
+			set{ any = value; }
 		}
 
 		/// <remarks>
@@ -154,17 +154,13 @@ namespace System.Xml.Schema
 				{
 					restriction.Id = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for restriction",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						restriction.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						restriction.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction);
 				}
 			}
 			

+ 32 - 35
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs

@@ -37,13 +37,6 @@ namespace System.Xml.Schema
 
 		#region Attributes
 
-		[DefaultValue(XmlSchemaDerivationMethod.None)]
-		[System.Xml.Serialization.XmlAttribute("block")]
-		public XmlSchemaDerivationMethod Block
-		{
-			get{ return  block; }
-			set{ block = value; }
-		}
 		[DefaultValue(false)]
 		[System.Xml.Serialization.XmlAttribute("abstract")]
 		public bool IsAbstract 
@@ -51,6 +44,13 @@ namespace System.Xml.Schema
 			get{ return  isAbstract; }
 			set{ isAbstract = value; }
 		}
+		[DefaultValue(XmlSchemaDerivationMethod.None)]
+		[System.Xml.Serialization.XmlAttribute("block")]
+		public XmlSchemaDerivationMethod Block
+		{
+			get{ return  block; }
+			set{ block = value; }
+		}
 		[DefaultValue(false)]
 		[System.Xml.Serialization.XmlAttribute("mixed")]
 		public override bool IsMixed
@@ -62,20 +62,7 @@ namespace System.Xml.Schema
 		#endregion
 		
 		#region Elements
-		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaAnyAttribute AnyAttribute 
-		{
-			get{ return  anyAttribute; }
-			set{ anyAttribute = value; }
-		}
-
-		[XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
-		[XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaObjectCollection Attributes 
-		{
-			get{ return attributes; }
-		}
-		
+				
 		[XmlElement("simpleContent",typeof(XmlSchemaSimpleContent),Namespace="http://www.w3.org/2001/XMLSchema")]
 		[XmlElement("complexContent",typeof(XmlSchemaComplexContent),Namespace="http://www.w3.org/2001/XMLSchema")]
 		public XmlSchemaContentModel ContentModel 
@@ -95,18 +82,32 @@ namespace System.Xml.Schema
 			set{ particle = value; }
 		}
 
+		[XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+		[XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaObjectCollection Attributes 
+		{
+			get{ return attributes; }
+		}
+
+		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaAnyAttribute AnyAttribute 
+		{
+			get{ return  anyAttribute; }
+			set{ anyAttribute = value; }
+		}
+
 		#endregion
 
 		#region XmlIgnore
 		[XmlIgnore]
-		public XmlSchemaObjectTable AttributeUses 
+		public XmlSchemaContentType ContentType 
 		{
-			get{ return attributeUses; }
+			get{ return contentType; }
 		}
 		[XmlIgnore]
-		public XmlSchemaAnyAttribute AttributeWildcard 
+		public XmlSchemaParticle ContentTypeParticle 
 		{
-			get{ return attributeWildcard; }
+			get{ return contentTypeParticle; }
 		}
 		[XmlIgnore]
 		public XmlSchemaDerivationMethod BlockResolved 
@@ -114,14 +115,14 @@ namespace System.Xml.Schema
 			get{ return blockResolved; }
 		}
 		[XmlIgnore]
-		public XmlSchemaContentType ContentType 
+		public XmlSchemaObjectTable AttributeUses 
 		{
-			get{ return contentType; }
+			get{ return attributeUses; }
 		}
 		[XmlIgnore]
-		public XmlSchemaParticle ContentTypeParticle 
+		public XmlSchemaAnyAttribute AttributeWildcard 
 		{
-			get{ return contentTypeParticle; }
+			get{ return attributeWildcard; }
 		}
 		#endregion
 
@@ -339,17 +340,13 @@ namespace System.Xml.Schema
 				{
 					ctype.Name = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for complexType",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						ctype.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						ctype.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,ctype);
 				}
 			}
 			

+ 13 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs

@@ -46,8 +46,9 @@ namespace System.Xml.Schema
 		//  xml:lang = language>
 		//  Content: ({any})*
 		//</documentation>
-		internal static XmlSchemaDocumentation Read(XmlSchemaReader reader, ValidationEventHandler h)
+		internal static XmlSchemaDocumentation Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip)
 		{
+			skip = false;
 			XmlSchemaDocumentation doc = new XmlSchemaDocumentation();
 
 			reader.MoveToElement();
@@ -83,13 +84,19 @@ namespace System.Xml.Schema
 				return doc;
 
 			//Content {any}*
-			//FIXME: How to handle {any}* content
-			while(reader.Read())
+			XmlDocument xmldoc = new XmlDocument();
+			xmldoc.AppendChild(xmldoc.ReadNode(reader));
+			XmlNode root = xmldoc.FirstChild;
+			if(root != null && root.ChildNodes != null)
 			{
-				if(reader.NodeType == XmlNodeType.EndElement && reader.NamespaceURI == XmlSchema.Namespace && 
-					reader.LocalName == "documentation")
-					break;
+				doc.Markup = new XmlNode[root.ChildNodes.Count];
+				for(int i=0;i<root.ChildNodes.Count;i++)
+				{
+					doc.Markup[i] = root.ChildNodes[i];
+				}
 			}
+			if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)
+				skip = true;
 
 			return doc;
 		}

+ 29 - 42
mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs

@@ -44,7 +44,6 @@ namespace System.Xml.Schema
 			refName = XmlQualifiedName.Empty;
 			schemaTypeName = XmlQualifiedName.Empty;
 			substitutionGroup = XmlQualifiedName.Empty;
-			hash = ""+new Random().Next();
 			substitutionGroup = XmlQualifiedName.Empty;
 		}
 
@@ -97,6 +96,14 @@ namespace System.Xml.Schema
 			set{ form = value; }
 		}
 
+		[DefaultValue(null)]
+		[System.Xml.Serialization.XmlAttribute("name")]
+		public string Name 
+		{
+			get{ return  name; }
+			set{ name = value; }
+		}
+
 		[DefaultValue(false)]
 		[System.Xml.Serialization.XmlAttribute("nillable")]
 		public bool IsNillable 
@@ -105,26 +112,12 @@ namespace System.Xml.Schema
 			set{ isNillable = value; }
 		}
 
-		[DefaultValue(null)]
-		[System.Xml.Serialization.XmlAttribute("name")]
-		public string Name 
-		{
-			get{ return  name; }
-			set{ name = value; }
-		}
 		[System.Xml.Serialization.XmlAttribute("ref")]
 		public XmlQualifiedName RefName 
 		{
 			get{ return  refName; }
 			set{ refName = value;}
 		}
-		
-		[System.Xml.Serialization.XmlAttribute("type")]
-		public XmlQualifiedName SchemaTypeName 
-		{
-			get{ return  schemaTypeName; }
-			set{ schemaTypeName = value; }
-		}
 
 		[System.Xml.Serialization.XmlAttribute("substitutionGroup")]
 		public XmlQualifiedName SubstitutionGroup
@@ -132,18 +125,12 @@ namespace System.Xml.Schema
 			get{ return  substitutionGroup; }
 			set{ substitutionGroup = value; }
 		}
-
-
-		#endregion
-
-		#region Elements
 		
-		[XmlElement("unique",typeof(XmlSchemaUnique),Namespace="http://www.w3.org/2001/XMLSchema")]
-		[XmlElement("key",typeof(XmlSchemaKey),Namespace="http://www.w3.org/2001/XMLSchema")]
-		[XmlElement("keyref",typeof(XmlSchemaKeyref),Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaObjectCollection Constraints 
+		[System.Xml.Serialization.XmlAttribute("type")]
+		public XmlQualifiedName SchemaTypeName 
 		{
-			get{ return constraints; }
+			get{ return  schemaTypeName; }
+			set{ schemaTypeName = value; }
 		}
 
 		[XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
@@ -153,14 +140,19 @@ namespace System.Xml.Schema
 			get{ return  schemaType; }
 			set{ schemaType = value; }
 		}
-		
-		#endregion
 
-		#region XmlIgnore
+		[XmlElement("unique",typeof(XmlSchemaUnique),Namespace="http://www.w3.org/2001/XMLSchema")]
+		[XmlElement("key",typeof(XmlSchemaKey),Namespace="http://www.w3.org/2001/XMLSchema")]
+		[XmlElement("keyref",typeof(XmlSchemaKeyref),Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaObjectCollection Constraints 
+		{
+			get{ return constraints; }
+		}
+
 		[XmlIgnore]
-		public XmlSchemaDerivationMethod BlockResolved 
+		public XmlQualifiedName QualifiedName 
 		{
-			get{ return blockResolved; }
+			get{ return qName; }
 		}
 
 		[XmlIgnore]
@@ -170,18 +162,17 @@ namespace System.Xml.Schema
 		}
 		
 		[XmlIgnore]
-		public XmlSchemaDerivationMethod FinalResolved 
+		public XmlSchemaDerivationMethod BlockResolved 
 		{
-			get{ return finalResolved; }
+			get{ return blockResolved; }
 		}
-
+		
 		[XmlIgnore]
-		public XmlQualifiedName QualifiedName 
+		public XmlSchemaDerivationMethod FinalResolved 
 		{
-			get{ return qName; }
+			get{ return finalResolved; }
 		}
 
-
 		#endregion
 
 		/// <remarks>
@@ -544,17 +535,13 @@ namespace System.Xml.Schema
 					if(innerex != null)
 						error(h, reader.Value + " is not a valid value for type attribute",innerex);
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for element",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						element.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						element.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,element);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs

@@ -47,17 +47,13 @@ namespace System.Xml.Schema
 				{
 					enumeration.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						enumeration.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						enumeration.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,enumeration);
 				}
 			}
 			

+ 26 - 13
mcs/class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs

@@ -3,7 +3,7 @@
 using System;
 using System.Xml;
 using System.Xml.Serialization;
-
+using System.Collections;
 namespace System.Xml.Schema
 {
 	/// <summary>
@@ -18,12 +18,12 @@ namespace System.Xml.Schema
 
 		protected XmlSchemaExternal()
 		{}
-
-		[System.Xml.Serialization.XmlAttribute("id")]
-		public string Id 
+		
+		[System.Xml.Serialization.XmlAttribute("schemaLocation")]
+		public string SchemaLocation 
 		{
-			get{ return  id; }
-			set{ id = value; }
+			get{ return  location; } 
+			set{ location = value; }
 		}
 
 		[XmlIgnore]
@@ -32,18 +32,31 @@ namespace System.Xml.Schema
 			get{ return  schema; }
 			set{ schema = value; }
 		}
-		
-		[System.Xml.Serialization.XmlAttribute("schemaLocation")]
-		public string SchemaLocation 
+
+		[System.Xml.Serialization.XmlAttribute("id")]
+		public string Id 
 		{
-			get{ return  location; } 
-			set{ location = value; }
+			get{ return  id; }
+			set{ id = value; }
 		}
+
 		[XmlAnyAttribute]
 		public XmlAttribute[] UnhandledAttributes 
 		{
-			get{ return  unhandledAttributes; }
-			set{ unhandledAttributes = value; }
+			get
+			{
+				if(unhandledAttributeList != null)
+				{
+					unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+					unhandledAttributeList = null;
+				}
+				return unhandledAttributes;
+			}
+			set
+			{ 
+				unhandledAttributes = value; 
+				unhandledAttributeList = null;
+			}
 		}
 	}
 }

+ 7 - 7
mcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs

@@ -18,6 +18,13 @@ namespace System.Xml.Schema
 		protected XmlSchemaFacet()
 		{
 		}
+		
+		[System.Xml.Serialization.XmlAttribute("value")]
+		public string Value
+		{
+			get{ return  val; } 
+			set{ val = value; }
+		}
 
 		[DefaultValue(false)]
 		[System.Xml.Serialization.XmlAttribute("fixed")]
@@ -26,12 +33,5 @@ namespace System.Xml.Schema
 			get{ return  isFixed; }
 			set{ isFixed = value; }
 		}
-		
-		[System.Xml.Serialization.XmlAttribute("value")]
-		public string Value
-		{
-			get{ return  val; } 
-			set{ val = value; }
-		}
 	}
 }

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs

@@ -56,17 +56,13 @@ namespace System.Xml.Schema
 				{
 					fraction.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						fraction.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						fraction.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,fraction);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs

@@ -128,17 +128,13 @@ namespace System.Xml.Schema
 				{
 					group.name = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for group",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						group.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						group.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,group);
 				}
 			}
 			

+ 1 - 0
mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs

@@ -13,6 +13,7 @@ namespace System.Xml.Schema
 		protected XmlSchemaGroupBase()
 		{
 		}
+
 		[XmlIgnore]
 		public abstract XmlSchemaObjectCollection Items { get; }
 	}

+ 7 - 11
mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs

@@ -19,17 +19,17 @@ namespace System.Xml.Schema
 		{
 			refName = XmlQualifiedName.Empty;
 		}
-		[XmlIgnore]
-		public XmlSchemaGroupBase Particle 
-		{
-			get{ return particle; }
-		}
 		[System.Xml.Serialization.XmlAttribute("ref")]
 		public XmlQualifiedName RefName 
 		{
 			get{ return  refName; } 
 			set{ refName = value; }
 		}
+		[XmlIgnore]
+		public XmlSchemaGroupBase Particle 
+		{
+			get{ return particle; }
+		}
 		/// <remarks>
 		/// 1. RefName must be present
 		/// </remarks>
@@ -116,17 +116,13 @@ namespace System.Xml.Schema
 						error(h,reader.Value + " is an invalid value for minOccurs", e);
 					}
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for group",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						groupref.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						groupref.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,groupref);
 				}
 			}
 			

+ 9 - 9
mcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs

@@ -21,11 +21,12 @@ namespace System.Xml.Schema
 			fields = new XmlSchemaObjectCollection();
 			qName = XmlQualifiedName.Empty;
 		}
-
-		[XmlElement("field",typeof(XmlSchemaXPath),Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaObjectCollection Fields 
+		
+		[System.Xml.Serialization.XmlAttribute("name")]
+		public string Name 
 		{
-			get{ return fields; }
+			get{ return  name; } 
+			set{ name = value; }
 		}
 
 		[XmlElement("selector",typeof(XmlSchemaXPath),Namespace="http://www.w3.org/2001/XMLSchema")]
@@ -34,12 +35,11 @@ namespace System.Xml.Schema
 			get{ return  selector; } 
 			set{ selector = value; }
 		}
-		
-		[System.Xml.Serialization.XmlAttribute("name")]
-		public string Name 
+
+		[XmlElement("field",typeof(XmlSchemaXPath),Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaObjectCollection Fields 
 		{
-			get{ return  name; } 
-			set{ name = value; }
+			get{ return fields; }
 		}
 		
 		[XmlIgnore]

+ 9 - 13
mcs/class/System.XML/System.Xml.Schema/XmlSchemaImport.cs

@@ -18,13 +18,6 @@ namespace System.Xml.Schema
 		public XmlSchemaImport()
 		{
 		}
-
-		[XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaAnnotation Annotation 
-		{
-			get{ return  annotation; } 
-			set{ annotation = value; }
-		}
 		
 		[System.Xml.Serialization.XmlAttribute("namespace")]
 		public string Namespace 
@@ -32,6 +25,13 @@ namespace System.Xml.Schema
 			get{ return  nameSpace; } 
 			set{ nameSpace = value; }
 		}
+
+		[XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaAnnotation Annotation 
+		{
+			get{ return  annotation; } 
+			set{ annotation = value; }
+		}
 		//<import 
 		//  id = ID 
 		//  namespace = anyURI 
@@ -69,17 +69,13 @@ namespace System.Xml.Schema
 				{
 					import.SchemaLocation = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for import",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						import.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						import.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,import);
 				}
 			}
 

+ 10 - 13
mcs/class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs

@@ -12,7 +12,7 @@ namespace System.Xml.Schema
 	public class XmlSchemaInclude : XmlSchemaExternal
 	{
 		private XmlSchemaAnnotation annotation;
-		public static string xmlname = "include";
+		private static string xmlname = "include";
 
 		public XmlSchemaInclude()
 		{
@@ -23,12 +23,13 @@ namespace System.Xml.Schema
 			get{ return  annotation; } 
 			set{ annotation = value; }
 		}
-//<include 
-//  id = ID 
-//  schemaLocation = anyURI 
-//  {any attributes with non-schema namespace . . .}>
-//  Content: (annotation?)
-//</include>
+
+		//<include 
+		//  id = ID 
+		//  schemaLocation = anyURI 
+		//  {any attributes with non-schema namespace . . .}>
+		//  Content: (annotation?)
+		//</include>
 		internal static XmlSchemaInclude Read(XmlSchemaReader reader, ValidationEventHandler h)
 		{
 			XmlSchemaInclude include = new XmlSchemaInclude();
@@ -55,17 +56,13 @@ namespace System.Xml.Schema
 				{
 					include.SchemaLocation = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for include",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						include.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						include.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,include);
 				}
 			}
 

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs

@@ -69,17 +69,13 @@ namespace System.Xml.Schema
 				{
 					key.Name = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for key",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						key.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						key.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,key);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs

@@ -93,17 +93,13 @@ namespace System.Xml.Schema
 					if(innerex != null)
 						error(h, reader.Value + " is not a valid value for refer attribute",innerex);
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for keyref",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						keyref.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						keyref.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,keyref);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs

@@ -56,17 +56,13 @@ namespace System.Xml.Schema
 				{
 					length.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for group",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						length.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						length.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,length);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs

@@ -56,17 +56,13 @@ namespace System.Xml.Schema
 				{
 					maxex.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						maxex.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						maxex.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,maxex);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs

@@ -56,17 +56,13 @@ namespace System.Xml.Schema
 				{
 					maxi.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						maxi.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						maxi.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,maxi);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs

@@ -56,17 +56,13 @@ namespace System.Xml.Schema
 				{
 					length.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for group",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						length.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						length.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,length);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs

@@ -56,17 +56,13 @@ namespace System.Xml.Schema
 				{
 					minex.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						minex.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						minex.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,minex);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs

@@ -55,17 +55,13 @@ namespace System.Xml.Schema
 				{
 					mini.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						mini.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						mini.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,mini);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs

@@ -56,17 +56,13 @@ namespace System.Xml.Schema
 				{
 					length.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						length.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						length.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,length);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs

@@ -118,17 +118,13 @@ namespace System.Xml.Schema
 				{
 					notation.system = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for notation",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						notation.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						notation.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,notation);
 				}
 			}
 

+ 3 - 1
mcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs

@@ -1,6 +1,7 @@
 // Author: Dwivedi, Ajay kumar
 //            [email protected]
 using System;
+using System.Collections;
 using System.Xml.Serialization;
 using System.Xml;
 
@@ -15,8 +16,9 @@ namespace System.Xml.Schema
 		private int linePosition;
 		private string sourceUri;
 		private XmlSerializerNamespaces namespaces;
+		internal ArrayList unhandledAttributeList ;
 
-		internal protected int errorCount = 0;
+		internal int errorCount = 0;
 
 		protected XmlSchemaObject()
 		{

+ 27 - 26
mcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs

@@ -21,6 +21,26 @@ namespace System.Xml.Schema
 
 		#region Attributes
 
+		[System.Xml.Serialization.XmlAttribute("minOccurs")]
+		public string MinOccursString
+		{
+			get{ return minstr; }
+			set
+			{
+				decimal val = decimal.Parse(value);
+				if(val >= 0 && (val == Decimal.Truncate(val)))
+				{
+					minOccurs = val;
+					minstr	 = val.ToString();
+				}
+				else
+				{
+					throw new XmlSchemaException
+						("MinOccursString must be a non-negative number",null); 					
+				}
+			}
+		}
+
 		[System.Xml.Serialization.XmlAttribute("maxOccurs")]
 		public string MaxOccursString
 		{
@@ -49,49 +69,30 @@ namespace System.Xml.Schema
 			}
 		}
 
-		[System.Xml.Serialization.XmlAttribute("minOccurs")]
-		public string MinOccursString
-		{
-			get{ return minstr; }
-			set
-			{
-				decimal val = decimal.Parse(value);
-				if(val >= 0 && (val == Decimal.Truncate(val)))
-				{
-					minOccurs = val;
-					minstr	 = val.ToString();
-				}
-				else
-				{
-					throw new XmlSchemaException
-						("MinOccursString must be a non-negative number",null); 					
-				}
-			}
-		}
-
 		#endregion
 
 		#region XmlIgnore
 
 		[XmlIgnore]
-		public decimal MaxOccurs 
+		public decimal MinOccurs
 		{
-			get{ return  maxOccurs; } 
+			get{ return  minOccurs; }
 			set
 			{
-				MaxOccursString = value.ToString();
+				MinOccursString = value.ToString();
 			}
 		}
 
 		[XmlIgnore]
-		public decimal MinOccurs
+		public decimal MaxOccurs 
 		{
-			get{ return  minOccurs; }
+			get{ return  maxOccurs; } 
 			set
 			{
-				MinOccursString = value.ToString();
+				MaxOccursString = value.ToString();
 			}
 		}
+
 		#endregion
 	}
 }

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs

@@ -47,17 +47,13 @@ namespace System.Xml.Schema
 				{
 					pattern.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						pattern.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						pattern.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,pattern);
 				}
 			}
 			

+ 17 - 17
mcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs

@@ -24,31 +24,35 @@ namespace System.Xml.Schema
 			items = new XmlSchemaObjectCollection(this);
 			schemaTypes = new XmlSchemaObjectTable();
 		}
-		[XmlIgnore]
-		public XmlSchemaObjectTable AttributeGroups 
-		{
-			get{ return attributeGroups; }
-		}
-		[XmlIgnore]
-		public XmlSchemaObjectTable Groups 
-		{
-			get{ return groups; }
-		}
+		
 		[XmlElement("annotation",typeof(XmlSchemaAnnotation),Namespace="http://www.w3.org/2001/XMLSchema")]
 		[XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
 		[XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]
 		[XmlElement("group",typeof(XmlSchemaGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
-		//NOTE: AttributeGroup and not AttributeGroupRef
+			//NOTE: AttributeGroup and not AttributeGroupRef
 		[XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
 		public XmlSchemaObjectCollection Items 
 		{
 			get{ return items; }
 		}
+
+		[XmlIgnore]
+		public XmlSchemaObjectTable AttributeGroups 
+		{
+			get{ return attributeGroups; }
+		}
+		
 		[XmlIgnore]
 		public XmlSchemaObjectTable SchemaTypes 
 		{
 			get{ return schemaTypes; }
 		}
+
+		[XmlIgnore]
+		public XmlSchemaObjectTable Groups 
+		{
+			get{ return groups; }
+		}
 //<redefine 
 //  id = ID 
 //  schemaLocation = anyURI 
@@ -81,17 +85,13 @@ namespace System.Xml.Schema
 				{
 					redefine.SchemaLocation = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for redefine",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						redefine.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						redefine.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,redefine);
 				}
 			}
 

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs

@@ -119,17 +119,13 @@ namespace System.Xml.Schema
 						error(h,reader.Value + " is an invalid value for minOccurs",e);
 					}
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for sequence",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						sequence.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						sequence.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,sequence);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs

@@ -87,17 +87,13 @@ namespace System.Xml.Schema
 				{
 					simple.Id = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for simpleContent",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						simple.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						simple.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,simple);
 				}
 			}
 			

+ 11 - 14
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs

@@ -23,11 +23,11 @@ namespace System.Xml.Schema
 			attributes	 = new XmlSchemaObjectCollection();
 		}
 
-		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaAnyAttribute AnyAttribute 
+		[System.Xml.Serialization.XmlAttribute("base")]
+		public XmlQualifiedName BaseTypeName 
 		{
-			get{ return  any; }
-			set{ any = value; }
+			get{ return  baseTypeName; }
+			set{ baseTypeName = value; }
 		}
 
 		[XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
@@ -37,12 +37,13 @@ namespace System.Xml.Schema
 			get{ return attributes; }
 		}
 
-		[System.Xml.Serialization.XmlAttribute("base")]
-		public XmlQualifiedName BaseTypeName 
+		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaAnyAttribute AnyAttribute 
 		{
-			get{ return  baseTypeName; }
-			set{ baseTypeName = value; }
+			get{ return  any; }
+			set{ any = value; }
 		}
+
 		///<remarks>
 		/// 1. Base must be present and a QName
 		///</remarks>
@@ -122,17 +123,13 @@ namespace System.Xml.Schema
 				{
 					extension.Id = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for extension in this context",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						extension.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						extension.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,extension);
 				}
 			}
 			

+ 17 - 21
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs

@@ -33,20 +33,6 @@ namespace System.Xml.Schema
 			set{ baseTypeName = value; }
 		}
 
-		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaAnyAttribute AnyAttribute 
-		{
-			get{ return  any; }
-			set{ any = value; }
-		}
-
-		[XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
-		[XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaObjectCollection Attributes 
-		{
-			get{ return attributes; }
-		}
-
 		[XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
 		public XmlSchemaSimpleType BaseType 
 		{ 
@@ -54,7 +40,6 @@ namespace System.Xml.Schema
 			set{ baseType = value; } 
 		}
 		
-		
 		[XmlElement("minExclusive",typeof(XmlSchemaMinExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
 		[XmlElement("minInclusive",typeof(XmlSchemaMinInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")] 
 		[XmlElement("maxExclusive",typeof(XmlSchemaMaxExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
@@ -71,6 +56,21 @@ namespace System.Xml.Schema
 		{ 
 			get{ return facets; } 
 		}
+
+		[XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+		[XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaObjectCollection Attributes 
+		{
+			get{ return attributes; }
+		}
+
+		[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaAnyAttribute AnyAttribute 
+		{
+			get{ return  any; }
+			set{ any = value; }
+		}
+		
 		///<remarks>
 		/// 1. Base must be present and a QName
 		///</remarks>
@@ -158,17 +158,13 @@ namespace System.Xml.Schema
 				{
 					restriction.Id = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for restriction",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						restriction.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						restriction.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs

@@ -165,17 +165,13 @@ namespace System.Xml.Schema
 				{
 					stype.Name = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for simpleType",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						stype.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						stype.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,stype);
 				}
 			}
 			

+ 10 - 14
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs

@@ -21,23 +21,23 @@ namespace System.Xml.Schema
 			this.ItemTypeName = XmlQualifiedName.Empty;
 		}
 
-		[XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaSimpleType ItemType 
+		[System.Xml.Serialization.XmlAttribute("itemType")]
+		public XmlQualifiedName ItemTypeName
 		{
-			get{ return itemType; } 
+			get{ return itemTypeName; } 
 			set
 			{
-				itemType = value;
+				itemTypeName = value;
 			}
 		}
 
-		[System.Xml.Serialization.XmlAttribute("itemType")]
-		public XmlQualifiedName ItemTypeName
+		[XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaSimpleType ItemType 
 		{
-			get{ return itemTypeName; } 
+			get{ return itemType; } 
 			set
 			{
-				itemTypeName = value;
+				itemType = value;
 			}
 		}
 		/// <remarks>
@@ -105,17 +105,13 @@ namespace System.Xml.Schema
 					if(innerex != null)
 						error(h, reader.Value + " is not a valid value for itemType attribute",innerex);
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for list",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						list.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						list.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,list);
 				}
 			}
 			

+ 9 - 13
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs

@@ -23,13 +23,6 @@ namespace System.Xml.Schema
 			facets = new XmlSchemaObjectCollection();
 		}
 
-		[XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
-		public XmlSchemaSimpleType BaseType 
-		{
-			get{ return  baseType; } 
-			set{ baseType = value; }
-		}
-
 		[System.Xml.Serialization.XmlAttribute("base")]
 		public XmlQualifiedName BaseTypeName 
 		{
@@ -37,6 +30,13 @@ namespace System.Xml.Schema
 			set{ baseTypeName = value; }
 		}
 
+		[XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+		public XmlSchemaSimpleType BaseType 
+		{
+			get{ return  baseType; } 
+			set{ baseType = value; }
+		}
+
 		[XmlElement("minExclusive",typeof(XmlSchemaMinExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
 		[XmlElement("minInclusive",typeof(XmlSchemaMinInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")] 
 		[XmlElement("maxExclusive",typeof(XmlSchemaMaxExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
@@ -120,17 +120,13 @@ namespace System.Xml.Schema
 					if(innerex != null)
 						error(h, reader.Value + " is not a valid value for base attribute",innerex);
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for restriction",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						restriction.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						restriction.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs

@@ -126,17 +126,13 @@ namespace System.Xml.Schema
 							error(h,"'"+names[i] + "' is not a valid memberType",innerEx);
 					}
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for union",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						union.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						union.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,union);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs

@@ -55,17 +55,13 @@ namespace System.Xml.Schema
 				{
 					td.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						td.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						td.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,td);
 				}
 			}
 			

+ 17 - 16
mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs

@@ -16,10 +16,10 @@ namespace System.Xml.Schema
 		private XmlSchemaDatatype datatype;
 		private XmlSchemaDerivationMethod derivedBy;
 		private XmlSchemaDerivationMethod final;
-		protected XmlSchemaDerivationMethod finalResolved;
+		internal XmlSchemaDerivationMethod finalResolved;
 		private bool isMixed;
 		private string name;
-		protected XmlQualifiedName qName;
+		internal XmlQualifiedName qName;
 
 		public XmlSchemaType()
 		{
@@ -41,18 +41,20 @@ namespace System.Xml.Schema
 			get{ return  final; }
 			set{ final = value; }
 		}
-		#endregion
-
-		#region XmlIgnore
 		[XmlIgnore]
-		public object BaseSchemaType 
+		public XmlQualifiedName QualifiedName 
 		{
-			get{ return  baseSchemaType; }
+			get{ return qName; }
 		}
 		[XmlIgnore]
-		public XmlSchemaDatatype Datatype 
+		public XmlSchemaDerivationMethod FinalResolved 
 		{
-			get{ return datatype; }
+			get{ return finalResolved; }
+		}
+		[XmlIgnore]
+		public object BaseSchemaType 
+		{
+			get{ return  baseSchemaType; }
 		}
 		[XmlIgnore]
 		public XmlSchemaDerivationMethod DerivedBy 
@@ -60,21 +62,20 @@ namespace System.Xml.Schema
 			get{ return derivedBy; }
 		}
 		[XmlIgnore]
-		public XmlSchemaDerivationMethod FinalResolved 
+		public XmlSchemaDatatype Datatype 
 		{
-			get{ return finalResolved; }
+			get{ return datatype; }
 		}
+		#endregion
+
+		#region XmlIgnore
 		[XmlIgnore]
 		public virtual bool IsMixed 
 		{  
 			get{ return  isMixed; }
 			set{ isMixed = value; } 
 		}
-		[XmlIgnore]
-		public XmlQualifiedName QualifiedName 
-		{
-			get{ return qName; }
-		}
 		#endregion
+
 	}
 }

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs

@@ -68,17 +68,13 @@ namespace System.Xml.Schema
 				{
 					unique.Name = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for unique",null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						unique.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						unique.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,unique);
 				}
 			}
 			

+ 11 - 10
mcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs

@@ -103,18 +103,19 @@ namespace System.Xml.Schema
 			return retarr;
 		}
 
-		public static bool ReadIntAttribute(XmlReader reader, ref int val, out Exception innerExcpetion)
+		public static void ReadUnhandledAttribute(XmlReader reader, XmlSchemaObject xso)
 		{
-			innerExcpetion = null;
-			try
-			{
-				val = int.Parse(reader.Value);
-				return true;
-			}
-			catch(Exception ex)
+			if(reader.Prefix == "xmlns")
+				xso.Namespaces.Add(reader.LocalName, reader.Value);
+			else if(reader.Name == "xmlns")
+				xso.Namespaces.Add("",reader.Value);
+			else
 			{
-				innerExcpetion = ex;
-				return false;
+				if(xso.unhandledAttributeList == null)
+					xso.unhandledAttributeList = new System.Collections.ArrayList();
+				XmlAttribute attr = new XmlDocument().CreateAttribute(reader.LocalName,reader.NamespaceURI);
+				attr.Value = reader.Value;
+				xso.unhandledAttributeList.Add(attr);
 			}
 		}
 

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs

@@ -55,17 +55,13 @@ namespace System.Xml.Schema
 				{
 					ws.Value = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						ws.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						ws.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,ws);
 				}
 			}
 			

+ 2 - 6
mcs/class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs

@@ -63,17 +63,13 @@ namespace System.Xml.Schema
 				{
 					path.xpath = reader.Value;
 				}
-				else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
+				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
 				{
 					error(h,reader.Name + " is not a valid attribute for "+name,null);
 				}
 				else
 				{
-					if(reader.Prefix == "xmlns")
-						path.Namespaces.Add(reader.LocalName, reader.Value);
-					else if(reader.Name == "xmlns")
-						path.Namespaces.Add("",reader.Value);
-					//TODO: Add to Unhandled attributes
+					XmlSchemaUtil.ReadUnhandledAttribute(reader,path);
 				}
 			}