2008-09-09 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 9 Sep 2008 13:20:23 +0000 (13:20 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Tue, 9 Sep 2008 13:20:23 +0000 (13:20 -0000)
* XmlSchemaValidator.cs : do not try to validate CloseStartElement
  when it should be skipped. Fixed bug #422581.

* XmlSchemaValidatorTests.cs : added test for bug #422581.

* 422581.xsd, 422581.xml : new files.

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

mcs/class/System.XML/System.Xml.Schema/ChangeLog
mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs
mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog
mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaValidatorTests.cs
mcs/class/System.XML/Test/XmlFiles/xsd/422581.xml [new file with mode: 0644]
mcs/class/System.XML/Test/XmlFiles/xsd/422581.xsd [new file with mode: 0644]
mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog

index 1ce4f0b56c4d5eb82bce2a74ec62aac75bc5efe0..8a172831309901cc302201cf00b1fa8abeb08c26 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlSchemaValidator.cs : do not try to validate CloseStartElement
+         when it should be skipped. Fixed bug #422581.
+
 2008-08-19  Jb Evain  <jbevain@novell.com>
 
        * XmlSchema_2_1.cs
index 4338e5f98ce09faa68ef3de9b2380714fd5ef415..a7da8cfd3c6dc7ef09e1e2b4b92d2464223d12f7 100644 (file)
@@ -502,7 +502,9 @@ namespace System.Xml.Schema
                                if (schemas.Count == 0)
                                        return;
 
-                               AssessCloseStartElementSchemaValidity (info);
+                               if (skipValidationDepth < 0 || depth <= skipValidationDepth)
+                                       AssessCloseStartElementSchemaValidity (info);
+                               depth++;
                        } finally {
                                occuredAtts.Clear ();
                        }
@@ -720,8 +722,6 @@ namespace System.Xml.Schema
                                        next = state.Create (XmlSchemaParticle.Empty);
                        }
                        Context.State = next;
-
-                       depth++;
                }
 
                // It must be invoked after xsi:nil turned out not to be in
index 2fd3f301c7aad42e328d1531a2624ce815acbc79..e6c680787cde17874428bbd12471465af17bc911 100644 (file)
@@ -1,3 +1,7 @@
+2008-09-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlSchemaValidatorTests.cs : added test for bug #422581.
+
 2008-06-06  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlSchemaTests.cs : fix file path.
index e368aa3d8524a46db7c54041697eff2de9eb9778..e871e191c95f05cb1eb3aa5d4ac75c1c26ea66ae 100644 (file)
@@ -69,6 +69,18 @@ namespace MonoTests.System.Xml
                        v.ValidateElement ("foo", "", info, null, null, null, null);
                        v.ValidateAttribute ("bar", "", "", info);
                }
+
+               [Test]
+               public void SkipInvolved () // bug #422581
+               {
+                       XmlReader schemaReader = XmlReader.Create ("Test/XmlFiles/xsd/422581.xsd");
+                       XmlSchema schema = XmlSchema.Read (schemaReader, null);
+                       XmlReaderSettings settings = new XmlReaderSettings ();
+                       settings.ValidationType = ValidationType.Schema;
+                       settings.Schemas.Add (schema);
+                       XmlReader reader = XmlReader.Create ("Test/XmlFiles/xsd/422581.xml", settings);
+                       while (reader.Read ());
+               }
        }
 }
 
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/422581.xml b/mcs/class/System.XML/Test/XmlFiles/xsd/422581.xml
new file mode 100644 (file)
index 0000000..79d771b
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>\r
+<root foo="1">\r
+  <dummy>\r
+      <bar>\r
+          <elmnt name="value" />\r
+      </bar>\r
+  </dummy>\r
+  <dummy2></dummy2>\r
+</root>\r
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/422581.xsd b/mcs/class/System.XML/Test/XmlFiles/xsd/422581.xsd
new file mode 100644 (file)
index 0000000..447ed86
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">\r
+<xs:element name="root">\r
+  <xs:complexType>\r
+    <xs:sequence>\r
+      <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded" namespace="##any"/>\r
+    </xs:sequence>\r
+    <xs:attribute name="foo" type="xs:integer" use="required" />\r
+  </xs:complexType>\r
+</xs:element>\r
+</xs:schema>
\ No newline at end of file
index 2dbc129723dec42a7c240ce1708699ec9326710a..0dde55f87a09b884e6114b53fa0eee56d3a977f8 100644 (file)
@@ -1,3 +1,7 @@
+2008-09-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * 422581.xsd, 422581.xml : new files.
+
 2008-06-06  Atsushi Enomoto  <atsushi@ximian.com>
 
        * importNamespaceTest.xsd, xsdimporttest.xml, importedNamespace.xsd: