2010-06-14 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 14 Jun 2010 06:55:54 +0000 (06:55 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 14 Jun 2010 06:55:54 +0000 (06:55 -0000)
* XmlSchemaValidator.cs : fill Validity. Fixed bug #613682.

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

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

index fc5f9a2936f83c8e454638f976befc81965daca6..b2f778f58c3f87bceaa05b42141963ab4c4dd334 100644 (file)
@@ -1,3 +1,7 @@
+2010-06-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlSchemaValidator.cs : fill Validity. Fixed bug #613682.
+
 2010-03-15  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlSchemaComplexType.cs : quick fix for bug #584664. Fill base
index bd84ffbb08c85f424f46d08519909d333cd861a0..c424345182776862ac64eb3735d1686a5849728f 100644 (file)
@@ -159,6 +159,8 @@ namespace System.Xml.Schema
                // information to validate attribute values.
                internal XmlSchemaDatatype CurrentAttributeType;
 
+               XmlSchemaInfo current_info;
+
                #endregion
 
                #region Public properties
@@ -404,6 +406,8 @@ namespace System.Xml.Schema
                                throw new ArgumentNullException ("localName");
                        if (ns == null)
                                throw new ArgumentNullException ("ns");
+                       SetCurrentInfo (info);
+                       try {
 
                        CheckState (Transition.Content);
                        transition = Transition.StartTag;
@@ -449,6 +453,10 @@ namespace System.Xml.Schema
                                info.MemberType = null;
                                // FIXME: supply Validity (really useful?)
                        }
+
+                       } finally {
+                               current_info = null;
+                       }
                }
 
                public object ValidateEndElement (XmlSchemaInfo info)
@@ -465,10 +473,15 @@ namespace System.Xml.Schema
                public object ValidateEndElement (XmlSchemaInfo info,
                        object var)
                {
+                       SetCurrentInfo (info);
+                       try {
+
                        // If it is going to validate an empty element, then
                        // first validate end of attributes.
-                       if (transition == Transition.StartTag)
+                       if (transition == Transition.StartTag) {
+                               current_info = null;
                                ValidateEndOfAttributes (info);
+                       }
 
                        CheckState (Transition.Content);
 
@@ -487,6 +500,10 @@ namespace System.Xml.Schema
                        else if (skipValidationDepth < 0 || depth <= skipValidationDepth)
                                ret = AssessEndElementSchemaValidity (info);
                        return ret;
+
+                       } finally {
+                               current_info = null;
+                       }
                }
 
                // StartTagCloseDeriv
@@ -494,6 +511,8 @@ namespace System.Xml.Schema
                public void ValidateEndOfAttributes (XmlSchemaInfo info)
                {
                        try {
+                               SetCurrentInfo (info);
+
                                CheckState (Transition.StartTag);
                                transition = Transition.Content;
                                if (schemas.Count == 0)
@@ -503,6 +522,7 @@ namespace System.Xml.Schema
                                        AssessCloseStartElementSchemaValidity (info);
                                depth++;
                        } finally {
+                               current_info = null;
                                occuredAtts.Clear ();
                        }
                }
@@ -595,6 +615,9 @@ namespace System.Xml.Schema
 
                private void HandleError (ValException exception, bool isWarning)
                {
+                       if (current_info != null)
+                               current_info.Validity = XmlSchemaValidity.Invalid;
+
                        if (isWarning && IgnoreWarnings)
                                return;
 
@@ -611,6 +634,16 @@ namespace System.Xml.Schema
 
                #endregion
 
+               // call this at entry point of every public method.
+               private void SetCurrentInfo (XmlSchemaInfo info)
+               {
+                       if (current_info != null)
+                               throw new InvalidOperationException ("Not allowed concurrent call to validation method");
+                       current_info = info;
+                       if (info != null)
+                               current_info.Validity = XmlSchemaValidity.Valid;
+               }
+
                private void CheckState (Transition expected)
                {
                        if (transition != expected) {