Sfoglia il codice sorgente

2004-01-20 Atsushi Enomoto <[email protected]>

	* XsdParticleValidationState.cs : Use ValidatedMaxOccurs instead of
	  MaxOccurs. (in the meantime)
	* XsdValidatingReader.cs : "fixed" should not be treated as default.
	* XsdWildcard.cs : several Wildcard Subset constraint related fixes.

svn path=/trunk/mcs/; revision=22287
Atsushi Eno 22 anni fa
parent
commit
6487180ee7

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

@@ -1,3 +1,10 @@
+2004-01-20  Atsushi Enomoto <[email protected]>
+
+	* XsdParticleValidationState.cs : Use ValidatedMaxOccurs instead of
+	  MaxOccurs. (in the meantime)
+	* XsdValidatingReader.cs : "fixed" should not be treated as default.
+	* XsdWildcard.cs : several Wildcard Subset constraint related fixes.
+
 2004-01-15  Atsushi Enomoto <[email protected]>
 
 	* XsdValidatingReader.cs : Now use ValidatableParticle instead of

+ 5 - 5
mcs/class/System.XML/Mono.Xml.Schema/XsdParticleValidationState.cs

@@ -167,10 +167,10 @@ namespace Mono.Xml.Schema
 			this.manager = manager;
 		}
 
-		// Normally checks MaxOccurs boundary
+		// Normally checks Max Occurs boundary
 		public abstract XsdValidationState EvaluateStartElement (string localName, string ns);
 
-		// Normally checks MinOccurs boundary
+		// Normally checks Min Occurs boundary
 		public abstract bool EvaluateEndElement ();
 
 		internal abstract bool EvaluateIsEmptiable ();
@@ -276,7 +276,7 @@ namespace Mono.Xml.Schema
 				return result;
 
 			OccuredInternal++;
-			if (OccuredInternal > groupRef.MaxOccurs)
+			if (OccuredInternal > groupRef.ValidatedMaxOccurs)
 				return XsdValidationState.Invalid;
 			return Manager.MakeSequence (result, this);
 		}
@@ -558,7 +558,7 @@ namespace Mono.Xml.Schema
 			if (all.CompiledItems.Count == consumed.Count)
 				return true;
 			foreach (XmlSchemaElement el in all.CompiledItems)
-				if (el.MinOccurs > 0 && !consumed.Contains (el))
+				if (el.ValidatedMinOccurs > 0 && !consumed.Contains (el))
 					return false;
 			return true;
 		}
@@ -568,7 +568,7 @@ namespace Mono.Xml.Schema
 			if (all.Emptiable || all.ValidatedMinOccurs == 0)
 				return true;
 			foreach (XmlSchemaElement el in all.CompiledItems)
-				if (el.MinOccurs > 0 && !consumed.Contains (el))
+				if (el.ValidatedMinOccurs > 0 && !consumed.Contains (el))
 					return false;
 			return true;
 		}

+ 0 - 3
mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs

@@ -559,8 +559,6 @@ namespace Mono.Xml.Schema
 				if (context.Element != null) {
 					if (context.Element.ValidatedDefaultValue != null)
 						value = context.Element.ValidatedDefaultValue;
-					else if (context.Element.ValidatedFixedValue != null)
-						value = context.Element.ValidatedFixedValue;
 				}					
 			}
 
@@ -568,7 +566,6 @@ namespace Mono.Xml.Schema
 			XmlSchemaSimpleType st = context.ActualType as XmlSchemaSimpleType;
 			if (dt == null) {
 				if (st != null) {
-//					if (st.Variety == XmlSchemaDerivationMethod.Restriction)
 					dt = st.Datatype;
 				} else {
 					XmlSchemaComplexType ct = context.ActualType as XmlSchemaComplexType;

+ 47 - 21
mcs/class/System.XML/Mono.Xml.Schema/XsdWildcard.cs

@@ -172,46 +172,72 @@ namespace Mono.Xml.Schema
 		// Other = wider. this = restricted subset
 		internal void ValidateWildcardSubset (XsdWildcard other,
 			ValidationEventHandler h, XmlSchema schema)
+		{
+			ValidateWildcardSubset (other, h, schema, true);
+		}
+
+		internal bool ValidateWildcardSubset (XsdWildcard other,
+			ValidationEventHandler h, XmlSchema schema, bool raiseError)
 		{
 			// 1.
 			if (other.HasValueAny)
-				return;
+				return true;
+			// 2.
 			if (HasValueOther && other.HasValueOther) {
-					// 2.1 and 2.2
-					if (TargetNamespace == other.TargetNamespace ||
-						other.TargetNamespace == null || other.TargetNamespace == "")
-						return;
+				// 2.1 and 2.2
+				if (TargetNamespace == other.TargetNamespace ||
+					other.TargetNamespace == null || other.TargetNamespace == "")
+					return true;
+			}
+			// 3.1. (not)
+			if (this.HasValueAny) {
+				if (raiseError)
+					xsobj.error (h, "Invalid wildcard subset was found.");
+				return false;
 			}
-			// 3.1.
-			if (this.HasValueAny)
-				xsobj.error (h, "Invalid wildcard subset was found.");
 			// 3.2
 			if (other.HasValueOther) {
 				// 3.2.2
-				if (other.TargetNamespace == null || other.TargetNamespace == String.Empty)
-					return;
-				else {
-					foreach (string ns in ResolvedNamespaces)
+				if ( (this.HasValueTargetNamespace && other.TargetNamespace == this.TargetNamespace) ||
+					(this.HasValueLocal && (other.TargetNamespace == null || other.TargetNamespace.Length == 0)) ) {
+					if (raiseError)
+						xsobj.error (h, "Invalid wildcard subset was found.");
+					return false;
+				} else {
+					foreach (string ns in ResolvedNamespaces) {
 						if (ns == other.TargetNamespace) {
-							xsobj.error (h, "Invalid wildcard subset was found.");
-							return;
+							if (raiseError)
+								xsobj.error (h, "Invalid wildcard subset was found.");
+							return false;
 						}
+					}
 				}
 			} else {
 				// 3.2.1
-				if (!other.HasValueLocal && HasValueLocal) {
-					xsobj.error (h, "Invalid wildcard subset was found.");
-					return;
-				} else if (ResolvedNamespaces.Count == 0) {
-					return;
+				if ((this.HasValueLocal && !other.HasValueLocal) ||
+					this.HasValueTargetNamespace && !other.HasValueTargetNamespace) {
+					if (raiseError)
+						xsobj.error (h, "Invalid wildcard subset was found.");
+					return false;
+				} else if (this.HasValueOther) {
+//					if (
+//						(other.HasValueLocal && !(this.TargetNamespace == null || this.TargetNamespace.Length == 0)) || 
+//						other.ResolvedNamespaces.Count > 1 || 
+//						other.ResolvedNamespaces.Count == 1 && other.ResolvedNamespaces [0] != other.TargetNamespace) {
+						if (raiseError)
+							xsobj.error (h, "Invalid wildcard subset was found.");
+						return false;
+//					}
 				} else {
 					foreach (string ns in ResolvedNamespaces)
 						if (!other.ResolvedNamespaces.Contains (ns)) {
-							xsobj.error (h, "Invalid wildcard subset was found.");
-							return;
+							if (raiseError)
+								xsobj.error (h, "Invalid wildcard subset was found.");
+							return false;
 						}
 				}
 			}
+			return true;
 		}
 	}
 }