Explorar el Código

2010-03-15 Atsushi Enomoto <[email protected]>

	* XmlSchemaComplexType.cs : quick fix for bug #584664. Fill base
	  content type particles in prior to filling its own.

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

	* 584664b.xsd, 584664a.xml, 584664b.xml, 584664a.xsd: new test files
	  by Florian Haag.


svn path=/trunk/mcs/; revision=153559
Atsushi Eno hace 16 años
padre
commit
a5b5e8ce99

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

@@ -1,3 +1,8 @@
+2010-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlSchemaComplexType.cs : quick fix for bug #584664. Fill base
+	  content type particles in prior to filling its own.
+
 2010-02-16  Atsushi Enomoto  <[email protected]>
 
 	* XmlSchemaComplexType.cs : in modern .NET, xs:anyType has the

+ 10 - 3
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs

@@ -414,6 +414,14 @@ namespace System.Xml.Schema
 
 		void FillContentTypeParticle (ValidationEventHandler h, XmlSchema schema)
 		{
+			if (CollectProcessId == schema.CompilationId)
+				return;
+			CollectProcessId = schema.CompilationId;
+
+			var ct = BaseXmlSchemaType as XmlSchemaComplexType;
+			if (ct != null)
+				ct.FillContentTypeParticle (h, schema);
+
 			// {content type} => ContentType and ContentTypeParticle (later)
 			if (ContentModel != null) {
 				CollectContentTypeFromContentModel (h, schema);
@@ -423,8 +431,6 @@ namespace System.Xml.Schema
 			contentTypeParticle = validatableParticle.GetOptimizedParticle (true);
 			if (contentTypeParticle == XmlSchemaParticle.Empty && resolvedContentType == XmlSchemaContentType.ElementOnly)
 				resolvedContentType = XmlSchemaContentType.Empty;
-
-			CollectProcessId = schema.CompilationId;
 		}
 
 		#region {content type}
@@ -480,7 +486,7 @@ namespace System.Xml.Schema
 			if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)
 				baseComplexType = XmlSchemaComplexType.AnyType;
 
-			// On error case, it simple reject any contents
+			// On error case, it simply rejects any contents
 			if (baseComplexType == null) {
 				validatableParticle = XmlSchemaParticle.Empty;
 				resolvedContentType = XmlSchemaContentType.Empty;
@@ -488,6 +494,7 @@ namespace System.Xml.Schema
 			}
 
 			// 3.4.2 complex content {content type}
+			// FIXME: this part is looking different than the spec. sections.
 			if (cce.Particle == null || cce.Particle == XmlSchemaParticle.Empty) {
 				// - 2.1
 				if (baseComplexType == null) {

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

@@ -1,3 +1,7 @@
+2010-03-15  Atsushi Enomoto  <[email protected]>
+
+	* XmlSchemaValidatorTests.cs : added test for bug #584664.
+
 2010-01-27  Atsushi Enomoto  <[email protected]>
 
 	* XmlSchemaValidatorTests.cs : added test for bug #557452, by

+ 7 - 0
mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaValidatorTests.cs

@@ -290,6 +290,13 @@ namespace MonoTests.System.Xml
 			doc.Schemas.Add (XmlSchema.Read (XmlReader.Create (new StringReader (xsd)), null));
 			doc.Validate (null);
 		}
+
+		[Test]
+		public void Bug584664 ()
+		{
+			Validate (File.ReadAllText ("Test/XmlFiles/xsd/584664a.xml"), File.ReadAllText ("Test/XmlFiles/xsd/584664a.xsd"));
+			Validate (File.ReadAllText ("Test/XmlFiles/xsd/584664b.xml"), File.ReadAllText ("Test/XmlFiles/xsd/584664b.xsd"));
+		}
 	}
 }
 

+ 4 - 0
mcs/class/System.XML/Test/XmlFiles/xsd/584664a.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<root xmlns="http://a">
+  <leaf/>
+</root>

+ 19 - 0
mcs/class/System.XML/Test/XmlFiles/xsd/584664a.xsd

@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://a" xmlns="http://a" elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+<xs:complexType name="base">
+  <xs:sequence>
+    <xs:element name="leaf" type="xs:string"/>
+    <xs:element name="nested" type="derived" minOccurs="0" maxOccurs="unbounded"/>
+  </xs:sequence>
+</xs:complexType>
+
+<xs:complexType name="derived">
+  <xs:complexContent>
+    <xs:extension base="base"/>
+  </xs:complexContent>
+</xs:complexType>
+
+<xs:element name="root" type="derived"/>
+
+</xs:schema>

+ 4 - 0
mcs/class/System.XML/Test/XmlFiles/xsd/584664b.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<root xmlns="http://b">
+  <leaf/>
+</root>

+ 18 - 0
mcs/class/System.XML/Test/XmlFiles/xsd/584664b.xsd

@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://b" xmlns="http://b" elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+<xs:complexType name="base">
+  <xs:sequence>
+    <xs:element name="leaf" type="xs:string"/>
+  </xs:sequence>
+</xs:complexType>
+
+<xs:complexType name="derived">
+  <xs:complexContent>
+    <xs:extension base="base"/>
+  </xs:complexContent>
+</xs:complexType>
+
+<xs:element name="root" type="derived"/>
+
+</xs:schema>

+ 5 - 0
mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog

@@ -1,3 +1,8 @@
+2010-03-15  Atsushi Enomoto  <[email protected]>
+
+	* 584664b.xsd, 584664a.xml, 584664b.xml, 584664a.xsd: new test files
+	  by Florian Haag.
+
 2009-05-21  Gert Driesen  <[email protected]>
 
 	* extension-attr-redefine-*.xsd: new test files.