2009-03-16 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 16 Mar 2009 16:13:56 +0000 (16:13 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 16 Mar 2009 16:13:56 +0000 (16:13 -0000)
* XmlSchemaValidator.cs : check identities for untyped attributes.
  Attribute keyfield test must adjust depth, or it never matches.
  Missing braces for IgnoreIdentity test.

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

mcs/class/System.XML/System.Xml.Schema/ChangeLog
mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs

index b821729b1956867dd7c340c9eb5521911e56c8ab..a06f59c20afbec655c6b9ca350f9d0da8a558881 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlSchemaValidator.cs : check identities for untyped attributes.
+         Attribute keyfield test must adjust depth, or it never matches.
+         Missing braces for IgnoreIdentity test.
+
 2009-03-16  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlSchemaUtil.cs, XmlSchemaValidator.cs : predefined non-primitive
index 3d78823ee20aea1f72a17f130fbe5390027e0abb..64693a317a0b51453177c2a97a803d8b2ff543f6 100644 (file)
@@ -669,10 +669,11 @@ namespace System.Xml.Schema
                        }
 
 #region Key Constraints
-                       if (!IgnoreIdentity)
+                       if (!IgnoreIdentity) {
                                ValidateKeySelectors ();
                                ValidateKeyFields (false, xsiNilDepth == depth,
                                        Context.ActualType, null, null, null);
+                       }
 #endregion
                }
 
@@ -818,9 +819,11 @@ namespace System.Xml.Schema
                        XsDatatype dt = attr.AttributeType as XsDatatype;
                        if (dt == null)
                                dt = ((SimpleType) attr.AttributeType).Datatype;
+
+                       object parsedValue = null;
+
                        // It is a bit heavy process, so let's omit as long as possible ;-)
                        if (dt != SimpleType.AnySimpleType || attr.ValidatedFixedValue != null) {
-                               object parsedValue = null;
                                try {
                                        CurrentAttributeType = dt;
                                        parsedValue = getter ();
@@ -839,28 +842,28 @@ namespace System.Xml.Schema
                                        HandleError (String.Format ("The value of the attribute {0} does not match with its fixed value '{1}' in the space of type {2}", attr.QualifiedName, attr.ValidatedFixedValue, dt));
                                        parsedValue = attr.ValidatedFixedTypedValue;
                                }
+                       }
+
 #region ID Constraints
-                               if (!IgnoreIdentity) {
-                                       string error = idManager.AssessEachAttributeIdentityConstraint (dt, parsedValue, ((QName) elementQNameStack [elementQNameStack.Count - 1]).Name);
-                                       if (error != null)
-                                               HandleError (error);
-                               }
+                       if (!IgnoreIdentity) {
+                               string error = idManager.AssessEachAttributeIdentityConstraint (dt, parsedValue, ((QName) elementQNameStack [elementQNameStack.Count - 1]).Name);
+                               if (error != null)
+                                       HandleError (error);
+                       }
 #endregion
 
-                               #region Key Constraints
-                               if (!IgnoreIdentity)
-                                       ValidateKeyFields (
-                                               true,
-                                               false,
-                                               attr.AttributeType,
-                                               attr.QualifiedName.Name,
-                                               attr.QualifiedName.Namespace,
-                                               getter);
-                               #endregion
-
-                               return parsedValue;
-                       }
-                       return null;
+#region Key Constraints
+                       if (!IgnoreIdentity)
+                               ValidateKeyFields (
+                                       true,
+                                       false,
+                                       attr.AttributeType,
+                                       attr.QualifiedName.Name,
+                                       attr.QualifiedName.Namespace,
+                                       getter);
+#endregion
+
+                       return parsedValue;
                }
 
                private void AssessAttributeLocallyValidUse (XsAttribute attr)
@@ -1242,7 +1245,7 @@ namespace System.Xml.Schema
                                                        schemaType,
                                                        nsResolver,
                                                        lineInfo,
-                                                       depth,
+                                                       isAttr ? depth + 1 : depth,
                                                        attrName,
                                                        attrNs,
                                                        getter == null ?