Selaa lähdekoodia

2006-01-13 Atsushi Enomoto <[email protected]>

	* XsdValidatingReader.cs : whitespace nodes should be allowed inside
	  empty or element-only content types. Fixed bug #77241.

	* XsdValidatingReaderTests.cs : test from bug #77241.


svn path=/trunk/mcs/; revision=55523
Atsushi Eno 20 vuotta sitten
vanhempi
sitoutus
f67469ac41

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

@@ -1,3 +1,8 @@
+2006-01-13  Atsushi Enomoto <[email protected]>
+
+	* XsdValidatingReader.cs : whitespace nodes should be allowed inside
+	  empty or element-only content types. Fixed bug #77241.
+
 2006-01-11  Atsushi Enomoto <[email protected]>
 
 	* XmlSchemaValidatingReader.cs : removed unused constructors.

+ 2 - 1
mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs

@@ -1603,7 +1603,8 @@ namespace Mono.Xml.Schema
 					switch (ct.ContentType) {
 					case XmlSchemaContentType.ElementOnly:
 					case XmlSchemaContentType.Empty:
-						HandleError ("Not allowed character content was found.");
+						if (reader.NodeType != XmlNodeType.Whitespace)
+							HandleError ("Not allowed character content was found.");
 						break;
 					}
 				}

+ 4 - 0
mcs/class/System.XML/Test/System.Xml/ChangeLog

@@ -1,3 +1,7 @@
+2006-01-13  Atsushi Enomoto  <[email protected]>
+
+	* XsdValidatingReaderTests.cs : test from bug #77241.
+
 2006-01-13  Atsushi Enomoto  <[email protected]>
 
 	* XmlTextWriterTests.cs : added some tests for XMLdecl state check.

+ 30 - 0
mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs

@@ -5,8 +5,10 @@
 //	Atsushi Enomoto <[email protected]>
 //
 // (C)2003 Atsushi Enomoto
+// (C)2005-2006 Novell, Inc.
 //
 using System;
+using System.IO;
 using System.Xml;
 using System.Xml.Schema;
 using NUnit.Framework;
@@ -289,5 +291,33 @@ namespace MonoTests.System.Xml
 			AssertEquals ("  ", vr.ReadTypedValue ());
 			AssertEquals (XmlNodeType.EndElement, vr.NodeType);
 		}
+
+		[Test] // bug #77241
+		public void EmptyContentAllowWhitespace ()
+		{
+			string doc = @"
+<root>
+        <!-- some comment -->
+        <child/>
+</root>
+";
+			string schema = @"
+<xsd:schema xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
+    <xsd:element name=""root"">
+        <xsd:complexType>
+            <xsd:sequence>
+                <xsd:element name=""child"" type=""xsd:string"" />
+            </xsd:sequence>
+        </xsd:complexType>
+    </xsd:element>
+</xsd:schema>
+";
+			XmlValidatingReader reader = new XmlValidatingReader (
+				new XmlTextReader (new StringReader (doc)));
+			reader.Schemas.Add (null,
+				new XmlTextReader (new StringReader (schema)));
+			while (reader.Read ())
+				;
+		}
 	}
 }