Преглед изворни кода

2003-10-23 Atsushi Enomoto <[email protected]>

	* XmlSchemaAll.cs,
	  XmlSchemaChoice.cs,
	  XmlSchemaGroupBase.cs,
	  XmlSchemaSequence.cs : Now CompiledItems went to XmlSchemaGroupBase.
	* XmlSchemaAny.cs,
	  XmlSchemaElement.cs,
	  XmlSchemaGroupBase.cs,
	  XmlSchemaGroupRef.cs,
	  XmlSchemaParticle.cs,
	  XmlSchemaSequence.cs : Added ParticleEquals() method to compare
	  whether the particles are equal in the context of WXS part 1 - 3.9.6.
	* XmlSchemaAny.cs : Implemented ValidateDerivationByRestriction().
	* XmlSchemaAnyAttribute.cs : Removed extraneous lines and added my
	  responsibility on this class.
	  Added ValidateWildcardAllowsNamespaceName().
	* XmlSchemaAttribute.cs : Added ValidatedUse which holds post-
	  compilation value of "Use".
	* XmlSchemaAttributeGroup.cs,
	  XmlSchemaAttributeGroupRef.cs : Removed MonoTODO (same as some other
	  classes) since there is no more errors on attribute stuff ;-)
	* XmlSchemaComplexType.cs : complex content extension must block
	  derivation from any built-in primitive types.
	  Fixed wildcard derivation by restriction.
	  ValidateDerivationByRestriction() now checks attribute related
	  validity of DBR (derivation by restriction).
	  Now uses ParticleEquals() for particle DBR check.
	* XmlSchemaSequence.cs : Fixed to use CompiledItems instead of Items.

svn path=/trunk/mcs/; revision=19347
Atsushi Eno пре 22 година
родитељ
комит
3131a7917e

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

@@ -1,3 +1,33 @@
+2003-10-23  Atsushi Enomoto  <[email protected]>
+
+	* XmlSchemaAll.cs,
+	  XmlSchemaChoice.cs,
+	  XmlSchemaGroupBase.cs,
+	  XmlSchemaSequence.cs : Now CompiledItems went to XmlSchemaGroupBase.
+	* XmlSchemaAny.cs,
+	  XmlSchemaElement.cs,
+	  XmlSchemaGroupBase.cs,
+	  XmlSchemaGroupRef.cs,
+	  XmlSchemaParticle.cs,
+	  XmlSchemaSequence.cs : Added ParticleEquals() method to compare 
+	  whether the particles are equal in the context of WXS part 1 - 3.9.6.
+	* XmlSchemaAny.cs : Implemented ValidateDerivationByRestriction().
+	* XmlSchemaAnyAttribute.cs : Removed extraneous lines and added my
+	  responsibility on this class.
+	  Added ValidateWildcardAllowsNamespaceName().
+	* XmlSchemaAttribute.cs : Added ValidatedUse which holds post-
+	  compilation value of "Use".
+	* XmlSchemaAttributeGroup.cs,
+	  XmlSchemaAttributeGroupRef.cs : Removed MonoTODO (same as some other
+	  classes) since there is no more errors on attribute stuff ;-)
+	* XmlSchemaComplexType.cs : complex content extension must block 
+	  derivation from any built-in primitive types.
+	  Fixed wildcard derivation by restriction.
+	  ValidateDerivationByRestriction() now checks attribute related
+	  validity of DBR (derivation by restriction).
+	  Now uses ParticleEquals() for particle DBR check.
+	* XmlSchemaSequence.cs : Fixed to use CompiledItems instead of Items.
+
 2003-10-21  Atsushi Enomoto  <[email protected]>
 
 	* XmlSchema.cs,

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

@@ -18,7 +18,6 @@ namespace System.Xml.Schema
 	public class XmlSchemaAll : XmlSchemaGroupBase
 	{
 		private XmlSchemaObjectCollection items;
-		private XmlSchemaObjectCollection compiledItems;
 		private static string xmlname = "all";
 		private bool emptiable;
 
@@ -32,10 +31,7 @@ namespace System.Xml.Schema
 		{
 			get{ return items; }
 		}
-		internal XmlSchemaObjectCollection CompiledItems 
-		{
-			get{ return compiledItems; }
-		}
+
 		internal bool Emptiable
 		{
 			get { return emptiable; }
@@ -94,13 +90,13 @@ namespace System.Xml.Schema
 				error (h, "-all- group is limited to be content of a model group, or that of a complex type with maxOccurs to be 1.");
 
 			emptiable = true;
-			compiledItems = new XmlSchemaObjectCollection ();
+			CompiledItems.Clear ();
 			foreach (XmlSchemaElement obj in Items) {
 				errorCount += obj.Validate (h, schema);
 				if (obj.ValidatedMaxOccurs != 0 &&
 					obj.ValidatedMaxOccurs != 1)
 					error (h, "MaxOccurs of a particle inside -all- compositor must be either 0 or 1.");
-				compiledItems.Add (obj);
+				CompiledItems.Add (obj);
 				if (obj.MinOccurs > 0)
 					emptiable = false;
 			}

+ 29 - 1
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs

@@ -133,6 +133,27 @@ namespace System.Xml.Schema
 			return errorCount;
 		}
 
+		internal override bool ParticleEquals (XmlSchemaParticle other)
+		{
+			XmlSchemaAny any = other as XmlSchemaAny;
+			if (any == null)
+				return false;
+			if (this.HasValueAny != any.HasValueAny ||
+				this.HasValueLocal != any.HasValueLocal ||
+				this.HasValueOther != any.HasValueOther ||
+				this.HasValueTargetNamespace != any.HasValueTargetNamespace ||
+				this.ResolvedProcessContents != any.ResolvedProcessContents ||
+				this.ValidatedMaxOccurs != any.ValidatedMaxOccurs ||
+				this.ValidatedMinOccurs != any.ValidatedMinOccurs ||
+				this.ResolvedNamespaces.Count != any.ResolvedNamespaces.Count)
+				return false;
+			for (int i = 0; i < ResolvedNamespaces.Count; i++)
+				if (ResolvedNamespaces [i] != any.ResolvedNamespaces [i])
+					return false;
+			return true;
+		}
+
+
 		// 3.8.6. Attribute Wildcard Intersection
 		// Only try to examine if their intersection is expressible, and
 		// returns if the result is empty.
@@ -145,7 +166,14 @@ namespace System.Xml.Schema
 		internal override void ValidateDerivationByRestriction (XmlSchemaParticle baseParticle, 
 			ValidationEventHandler h, XmlSchema schema)
 		{
-			// TODO
+			XmlSchemaAny baseAny = baseParticle as XmlSchemaAny;
+			if (baseAny == null) {
+				error (h, "Invalid particle derivation by restriction was found.");
+				return;
+			}
+			// 3.9.6 Particle Derivation OK (Any:Any - NSSubset)
+			this.ValidateOccurenceRangeOK (baseParticle, h, schema);
+			wildcard.ValidateWildcardSubset (baseAny.wildcard, h, schema);
 		}
 
 

+ 14 - 43
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs

@@ -1,5 +1,10 @@
-// Author: Dwivedi, Ajay kumar
-//            [email protected]
+//
+// System.Xml.Schema.XmlSchemaAnyAttribute.cs
+//
+// Author:
+//	Dwivedi, Ajay kumar  [email protected]
+//	Atsushi Enomoto  [email protected]
+//
 using System;
 using System.Collections;
 using System.Collections.Specialized;
@@ -77,7 +82,6 @@ namespace System.Xml.Schema
 		///		a) ##any or ##other
 		///		b) list of anyURI and ##targetNamespace and ##local
 		/// </remarks>
-		[MonoTODO]
 		internal override int Compile(ValidationEventHandler h, XmlSchema schema)
 		{
 			// If this is already compiled this time, simply skip.
@@ -103,7 +107,6 @@ namespace System.Xml.Schema
 			return errorCount;
 		}
 		
-		[MonoTODO]
 		internal override int Validate(ValidationEventHandler h, XmlSchema schema)
 		{
 			return errorCount;
@@ -113,45 +116,13 @@ namespace System.Xml.Schema
 		internal void ValidateWildcardSubset (XmlSchemaAnyAttribute other,
 			ValidationEventHandler h, XmlSchema schema)
 		{
-			wildcard.ValidateWildcardSubset (other, h, schema);
-
-			/*
-			// 1.
-			if (this.hasValueAny)
-				return;
-			if (this.hasValueOther) {
-				if (other.hasValueOther) {
-					// 2.1 and 2.2
-					if (this.targetNamespace == other.targetNamespace ||
-						other.targetNamespace == null || other.targetNamespace == "")
-						return;
-				}
-				// 3.2.2
-				else if (this.targetNamespace == null || targetNamespace == String.Empty)
-					return;
-				else {
-					foreach (string ns in other.resolvedNamespaces)
-						if (ns == this.targetNamespace) {
-							error (h, "Invalid wildcard subset was found.");
-							return;
-						}
-				}
-			} else {
-				// 3.1
-				if (!this.hasValueLocal && other.hasValueLocal) {
-					error (h, "Invalid wildcard subset was found.");
-				} else if (other.resolvedNamespaces.Count == 0)
-					return;
-				else {
-					ArrayList al = new ArrayList (this.resolvedNamespaces);
-					foreach (string ns in other.resolvedNamespaces)
-						if (!al.Contains (ns)) {
-							error (h, "Invalid wildcard subset was found.");
-							return;
-						}
-				}
-			}
-			*/
+			wildcard.ValidateWildcardSubset (other.wildcard, h, schema);
+
+		}
+
+		internal bool ValidateWildcardAllowsNamespaceName (string ns, XmlSchema schema)
+		{
+			return wildcard.ValidateWildcardAllowsNamespaceName (ns, null, schema, false);
 		}
 
 		//<anyAttribute

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

@@ -30,6 +30,7 @@ namespace System.Xml.Schema
 		private XmlSchemaSimpleType schemaType;
 		private XmlQualifiedName schemaTypeName;
 		private XmlSchemaUse use;
+		private XmlSchemaUse validatedUse;
 		//Compilation fields
 		internal bool ParentIsSchema = false;
 		private XmlSchemaAttribute referencedAttribute;
@@ -153,6 +154,10 @@ namespace System.Xml.Schema
 			// FixedValue can be overriden in case of ref.
 			get { return validatedFixedValue; }
 		}
+		internal XmlSchemaUse ValidatedUse
+		{
+			get { return validatedUse; }
+		}
 
 		#endregion
 
@@ -382,6 +387,10 @@ namespace System.Xml.Schema
 					}
 				}
 			}
+			if (Use == XmlSchemaUse.None)
+				validatedUse = XmlSchemaUse.Optional;
+			else
+				validatedUse = Use;
 
 			ValidationId = schema.ValidationId;
 			return errorCount;

+ 0 - 2
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs

@@ -79,7 +79,6 @@ namespace System.Xml.Schema
 		/// The other attributeGroup has type XmlSchemaAttributeGroupRef.
 		///  1. Name must be present
 		/// </remarks>
-		[MonoTODO]
 		internal override int Compile(ValidationEventHandler h, XmlSchema schema)
 		{
 			// FIXME: Even if it was already compiled, it should check recursion.
@@ -130,7 +129,6 @@ namespace System.Xml.Schema
 			return errorCount;
 		}
 
-		[MonoTODO]
 		internal override int Validate(ValidationEventHandler h, XmlSchema schema)
 		{
 			if (IsValidated (schema.CompilationId))

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

@@ -35,7 +35,6 @@ namespace System.Xml.Schema
 		/// 1. ref must be present
 		/// 2. The element must be empty. ?? FIXME: Is this correct or annotation is permitted?
 		/// </remarks>
-		[MonoTODO]
 		internal override int Compile(ValidationEventHandler h, XmlSchema schema)
 		{
 			// If this is already compiled this time, simply skip.
@@ -57,7 +56,6 @@ namespace System.Xml.Schema
 			return errorCount;
 		}
 		
-		[MonoTODO]
 		internal override int Validate(ValidationEventHandler h, XmlSchema schema)
 		{
 			return errorCount;

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

@@ -18,7 +18,6 @@ namespace System.Xml.Schema
 	public class XmlSchemaChoice : XmlSchemaGroupBase
 	{
 		private XmlSchemaObjectCollection items;
-		private XmlSchemaObjectCollection compiledItems;
 		private static string xmlname = "choice";
 		private decimal minEffectiveTotalRange = -1;
 
@@ -36,10 +35,19 @@ namespace System.Xml.Schema
 		{
 			get{ return items; }
 		}
-		internal XmlSchemaObjectCollection CompiledItems 
-		{
-			get{ return compiledItems; }
+
+		/*
+		internal override XmlSchemaParticle ActualParticle {
+			get {
+				if (this.ValidatedMinOccurs == 1 &&
+					this.ValidatedMaxOccurs == 1 &&
+					CompiledItems.Count == 1)
+					return ((XmlSchemaParticle) CompiledItems [0]).ActualParticle;
+				else
+					return this;
+			}
 		}
+		*/
 
 		[MonoTODO]
 		internal override int Compile(ValidationEventHandler h, XmlSchema schema)
@@ -74,10 +82,10 @@ namespace System.Xml.Schema
 			if (IsValidated (schema.CompilationId))
 				return errorCount;
 
-			compiledItems = new XmlSchemaObjectCollection ();
+			CompiledItems.Clear ();
 			foreach (XmlSchemaObject obj in Items) {
 				errorCount += obj.Validate (h, schema);
-				compiledItems.Add (obj);
+				CompiledItems.Add (obj);
 			}
 
 			ValidationId = schema.ValidationId;

+ 54 - 5
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs

@@ -518,6 +518,8 @@ namespace System.Xml.Schema
 				// base
 				if (baseTypeName == XmlSchemaComplexType.AnyTypeName)
 					baseComplexType = XmlSchemaComplexType.AnyType;
+				else if (baseTypeName.Namespace == XmlSchema.Namespace)
+					error (h, "Referenced base schema type is XML Schema datatype.");
 				else if (baseComplexType == null && !schema.IsNamespaceAbsent (baseTypeName.Namespace))
 					error (h, "Referenced base schema type " + baseTypeName + " was not complex type or not found in the corresponding schema.");
 			}
@@ -548,6 +550,8 @@ namespace System.Xml.Schema
 				if (baseComplexType == null) {
 					// Basically it is an error. Considering ValidationEventHandler.
 				}
+				else if (baseComplexType.resolvedContentType == XmlSchemaContentType.TextOnly)
+					error (h, "Content of the base complex type is Text-only.");
 				else if (baseComplexType.ContentTypeParticle == XmlSchemaParticle.Empty
 					|| baseComplexType == XmlSchemaComplexType.AnyType)
 					contentTypeParticle = cce.Particle;
@@ -603,7 +607,7 @@ namespace System.Xml.Schema
 					baseAnyAttribute = baseComplexType.AttributeWildcard;
 				if (baseAnyAttribute != null && localAnyAttribute != null)
 					// 1.3 attribute wildcard subset. (=> 3.10.6)
-					baseAnyAttribute.ValidateWildcardSubset (localAnyAttribute, h, schema);
+					localAnyAttribute.ValidateWildcardSubset (baseAnyAttribute, h, schema);
 
 				// FIXME: Check 3.4.2 Complex Type Definition with complex content Schema Component
 				// and its {attribute uses} and {attribute wildcard}
@@ -654,7 +658,7 @@ namespace System.Xml.Schema
 					localAnyAttribute = scr.AnyAttribute;
 					if (localAnyAttribute != null && baseAnyAttribute != null)
 						// 1.3 attribute wildcard subset. (=> 3.10.6)
-						baseAnyAttribute.ValidateWildcardSubset (localAnyAttribute, h, schema);
+						localAnyAttribute.ValidateWildcardSubset (baseAnyAttribute, h, schema);
 					// TODO: 3.4.6 :: 5.1. Beware that There is an errata for 5.1!!
 					// http://www.w3.org/2001/05/xmlschema-errata#Errata1
 
@@ -830,7 +834,51 @@ namespace System.Xml.Schema
 				error (h, "Prohibited derivation by restriction by base schema type.");
 				return;
 			}
-			// TODO: 2. - 4.
+
+			// 2.
+			foreach (XmlSchemaAttribute attr in this.AttributeUses) {
+				XmlSchemaAttribute baseAttr = baseType.AttributeUses [attr.QualifiedName] as XmlSchemaAttribute;
+				if (baseAttr != null) {
+					// 2.1
+					// 2.1.1
+					if (baseAttr.ValidatedUse != XmlSchemaUse.Optional && attr.ValidatedUse != XmlSchemaUse.Required)
+						error (h, "Invalid attribute derivation by restriction was found for " + attr.QualifiedName + " .");
+					// 2.1.2
+					XmlSchemaSimpleType attrSimpleType = attr.AttributeType as XmlSchemaSimpleType;
+					XmlSchemaSimpleType baseAttrSimpleType = baseAttr.AttributeType as XmlSchemaSimpleType;
+					bool typeError = false;
+					if (attrSimpleType != null)
+						attrSimpleType.ValidateDerivationValid (baseAttrSimpleType, null, h, schema);
+					else if (attrSimpleType == null && baseAttrSimpleType != null)
+						typeError = true;
+					else {
+						Type t1 = attr.AttributeType.GetType ();
+						Type t2 = baseAttr.AttributeType.GetType ();
+						if (t1 != t2 && t1.IsSubclassOf (t2))
+							typeError = true;
+					}
+					if (typeError)
+						error (h, "Invalid attribute derivation by restriction because of its type: " + attr.QualifiedName + " .");
+					// 2.1.3
+					if (baseAttr.ValidatedFixedValue != null && attr.ValidatedFixedValue != baseAttr.ValidatedFixedValue)
+						error (h, "Invalid attribute derivation by restriction because of its fixed value constraint: " + attr.QualifiedName + " .");
+				} else {
+					// 2.2
+					if (baseType.AttributeWildcard != null)
+						if (!baseType.AttributeWildcard.ValidateWildcardAllowsNamespaceName (
+							attr.QualifiedName.Namespace, schema) &&
+							!schema.IsNamespaceAbsent (attr.QualifiedName.Namespace))
+							error (h, "Invalid attribute derivation by restriction was found for " + attr.QualifiedName + " .");
+				}
+			}
+			// I think 3. is considered in 2.
+			// 4.
+			if (this.AttributeWildcard != null) {
+				if (baseType.AttributeWildcard == null)
+					error (h, "Invalid attribute derivation by restriction because of attribute wildcard.");
+				else
+					AttributeWildcard.ValidateWildcardSubset (baseType.AttributeWildcard, h, schema);
+			}
 
 			// 5.
 			if (contentTypeParticle == XmlSchemaParticle.Empty) {
@@ -842,8 +890,9 @@ namespace System.Xml.Schema
 			} else {
 				// 5.3 => 3.9.6 Particle Valid (Restriction)
 				if (baseType.ContentTypeParticle != null) {
-					contentTypeParticle.ActualParticle.ValidateDerivationByRestriction (
-						baseType.ContentTypeParticle.ActualParticle, h, schema);
+					if (!contentTypeParticle.ActualParticle.ParticleEquals (baseType.ContentTypeParticle.ActualParticle))
+						contentTypeParticle.ActualParticle.ValidateDerivationByRestriction (
+							baseType.ContentTypeParticle.ActualParticle, h, schema);
 				}
 			}
 		}

+ 34 - 0
mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs

@@ -599,6 +599,40 @@ namespace System.Xml.Schema
 			return errorCount;
 		}
 
+		internal override bool ParticleEquals (XmlSchemaParticle other)
+		{
+			XmlSchemaElement element = other as XmlSchemaElement;
+			if (element == null)
+				return false;
+			if (this.ValidatedMaxOccurs != element.ValidatedMaxOccurs ||
+				this.ValidatedMinOccurs != element.ValidatedMinOccurs)
+				return false;
+			if (this.QualifiedName != element.QualifiedName ||
+				this.ElementType != element.ElementType ||
+				this.Constraints.Count != element.Constraints.Count)
+				return false;
+			for (int i = 0; i < this.Constraints.Count; i++) {
+				XmlSchemaIdentityConstraint c1 = Constraints [i] as XmlSchemaIdentityConstraint;
+				XmlSchemaIdentityConstraint c2 = element.Constraints [i] as XmlSchemaIdentityConstraint;
+				if (c1.QualifiedName != c2.QualifiedName ||
+					c1.Selector.XPath != c2.Selector.XPath ||
+					c1.Fields.Count != c2.Fields.Count)
+					return false;
+				for (int f = 0; f < c1.Fields.Count; f++) {
+					XmlSchemaXPath f1 = c1.Fields [f] as XmlSchemaXPath;
+					XmlSchemaXPath f2 = c2.Fields [f] as XmlSchemaXPath;
+					if (f1.XPath != f2.XPath)
+						return false;
+				}
+			}
+			if (this.BlockResolved != element.BlockResolved ||
+				this.FinalResolved != element.FinalResolved ||
+				this.ValidatedDefaultValue != element.ValidatedDefaultValue ||
+				this.ValidatedFixedValue != element.ValidatedFixedValue)
+				return false;
+			return true;
+		}
+
 		internal override void ValidateDerivationByRestriction (XmlSchemaParticle baseParticle,
 			ValidationEventHandler h, XmlSchema schema)
 		{

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

@@ -10,13 +10,40 @@ namespace System.Xml.Schema
 	/// </summary>
 	public abstract class XmlSchemaGroupBase : XmlSchemaParticle
 	{
+		private XmlSchemaObjectCollection compiledItems;
+
 		protected XmlSchemaGroupBase()
 		{
+			compiledItems = new XmlSchemaObjectCollection ();
 		}
 
 		[XmlIgnore]
 		public abstract XmlSchemaObjectCollection Items { get; }
 
+		internal XmlSchemaObjectCollection CompiledItems 
+		{
+			get{ return compiledItems; }
+		}
+
+		internal override bool ParticleEquals (XmlSchemaParticle other)
+		{
+			XmlSchemaChoice choice = other as XmlSchemaChoice;
+			if (choice == null)
+				return false;
+			if (this.ValidatedMaxOccurs != choice.ValidatedMaxOccurs ||
+				this.ValidatedMinOccurs != choice.ValidatedMinOccurs)
+				return false;
+			if (this.CompiledItems.Count != choice.CompiledItems.Count)
+				return false;
+			for (int i = 0; i < CompiledItems.Count; i++) {
+				XmlSchemaParticle p1 = this.CompiledItems [i] as XmlSchemaParticle;
+				XmlSchemaParticle p2 = choice.CompiledItems [i] as XmlSchemaParticle;
+				if (!p1.ParticleEquals (p2))
+					return false;
+			}
+			return true;
+		}
+
 		internal void ValidateNSRecurseCheckCardinality (XmlSchemaAny any,
 			ValidationEventHandler h, XmlSchema schema)
 		{

+ 5 - 0
mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs

@@ -104,6 +104,11 @@ namespace System.Xml.Schema
 			return errorCount;
 		}
 
+		internal override bool ParticleEquals (XmlSchemaParticle other)
+		{
+			return ActualParticle.ParticleEquals (other.ActualParticle);
+		}
+
 		internal override void ValidateDerivationByRestriction (XmlSchemaParticle baseParticle,
 			ValidationEventHandler h, XmlSchema schema)
 		{

+ 8 - 0
mcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs

@@ -198,6 +198,8 @@ namespace System.Xml.Schema
 		// See http://www.thaiopensource.com/relaxng/simplify.html
 		internal abstract void CheckRecursion (int depth, ValidationEventHandler h, XmlSchema schema);
 
+		internal abstract bool ParticleEquals (XmlSchemaParticle other);
+
 		#region Internal Class
 		public class XmlSchemaParticleEmpty : XmlSchemaParticle
 		{
@@ -205,6 +207,12 @@ namespace System.Xml.Schema
 			{
 			}
 
+			internal override bool ParticleEquals (XmlSchemaParticle other)
+			{
+				return other == this || other is XmlSchemaParticleEmpty;
+			}
+
+
 			internal override void ValidateDerivationByRestriction (XmlSchemaParticle baseParticle,
 				ValidationEventHandler h, XmlSchema schema)
 			{

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

@@ -18,7 +18,6 @@ namespace System.Xml.Schema
 	public class XmlSchemaSequence : XmlSchemaGroupBase
 	{
 		private XmlSchemaObjectCollection items;
-		private XmlSchemaObjectCollection compiledItems;
 		private static string xmlname = "sequence";
 
 		public XmlSchemaSequence()
@@ -35,10 +34,6 @@ namespace System.Xml.Schema
 		{
 			get{ return items; }
 		}
-		internal XmlSchemaObjectCollection CompiledItems 
-		{
-			get{ return compiledItems; }
-		}
 
 		[MonoTODO]
 		internal override int Compile(ValidationEventHandler h, XmlSchema schema)
@@ -73,10 +68,10 @@ namespace System.Xml.Schema
 			if (IsValidated (schema.CompilationId))
 				return errorCount;
 
-			compiledItems = new XmlSchemaObjectCollection ();
+			CompiledItems.Clear ();
 			foreach (XmlSchemaObject obj in Items) {
 				errorCount += obj.Validate (h, schema);
-				compiledItems.Add (obj);
+				CompiledItems.Add (obj);
 			}
 
 			ValidationId = schema.ValidationId;
@@ -100,15 +95,15 @@ namespace System.Xml.Schema
 
 				// FIXME: What is the correct "order preserving" mapping?
 				int baseIndex = 0;
-				for (int i = 0; i < this.Items.Count; i++) {
-					XmlSchemaParticle pd = Items [i] as XmlSchemaParticle;
+				for (int i = 0; i < this.CompiledItems.Count; i++) {
+					XmlSchemaParticle pd = this.CompiledItems [i] as XmlSchemaParticle;
 					if (seq.Items.Count > baseIndex) {
-						XmlSchemaParticle pb = seq.Items [baseIndex] as XmlSchemaParticle;
+						XmlSchemaParticle pb = seq.CompiledItems [baseIndex] as XmlSchemaParticle;
 						pd.ActualParticle.ValidateDerivationByRestriction (pb.ActualParticle, h, schema);
 						baseIndex++;
 					}
 					else
-						error (h, "Invalid choice derivation by extension was found.");
+						error (h, "Invalid sequence derivation by extension was found.");
 				}
 
 				return;