Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2007-08-02 13:21:06 +0400
committerAtsushi Eno <atsushieno@gmail.com>2007-08-02 13:21:06 +0400
commitb6cbab331e465220490352488fcc44ef764fa651 (patch)
tree304829e0a1335cc19b2d8cb3ca12f75535b33a74 /mcs
parent9fbfd4fb7c680f0e9418fbd133ae0d225a0f9ce9 (diff)
2007-08-02 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaComplexType.cs, XmlSchemaComplexContentRestriction.cs : in Validate(), every descendant item in complexType must be first validated before getting GetOptimizedParticle(), or it could result in wrong content particle. Fixed bug #82010. * XsdValidatingReaderTests.cs : test for bug #82010. * 82010.xsd, 82010.xml : new test files. * Makefile : extra distfiles (82010.xml/.xsd). svn path=/trunk/mcs/; revision=83272
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.XML/ChangeLog4
-rw-r--r--mcs/class/System.XML/Makefile2
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/ChangeLog8
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs2
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs51
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs2
-rw-r--r--mcs/class/System.XML/Test/System.Xml/ChangeLog4
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs23
-rw-r--r--mcs/class/System.XML/Test/XmlFiles/xsd/82010.xml7
-rw-r--r--mcs/class/System.XML/Test/XmlFiles/xsd/82010.xsd29
-rw-r--r--mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog4
11 files changed, 112 insertions, 24 deletions
diff --git a/mcs/class/System.XML/ChangeLog b/mcs/class/System.XML/ChangeLog
index 13c1f1e09e2..fc2f33c0003 100644
--- a/mcs/class/System.XML/ChangeLog
+++ b/mcs/class/System.XML/ChangeLog
@@ -1,3 +1,7 @@
+2007-08-02 Atsushi Enomoto <atsushi@ximian.com>
+
+ * Makefile : extra distfiles (82010.xml/.xsd).
+
2007-06-28 Atsushi Enomoto <atsushi@ximian.com>
* System.Xml.dll.sources : added XsltDebuggerWrapper.cs, as initial
diff --git a/mcs/class/System.XML/Makefile b/mcs/class/System.XML/Makefile
index fcd5737d81f..b9fb096d058 100644
--- a/mcs/class/System.XML/Makefile
+++ b/mcs/class/System.XML/Makefile
@@ -77,6 +77,8 @@ EXTRA_DISTFILES = \
Test/XmlFiles/xsd/78985.xml \
Test/XmlFiles/xsd/78985.xsd \
Test/XmlFiles/xsd/79650.xsd \
+ Test/XmlFiles/xsd/82010.xml \
+ Test/XmlFiles/xsd/82010.xsd \
Test/XmlFiles/xsd/inter-inc-1.xsd \
Test/XmlFiles/xsl/91834.xml \
Test/XmlFiles/xsl/91834.xsl \
diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
index ac911fda08f..265d1b7d89f 100644
--- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
@@ -1,5 +1,13 @@
2007-08-02 Atsushi Enomoto <atsushi@ximian.com>
+ * XmlSchemaComplexType.cs,
+ XmlSchemaComplexContentRestriction.cs :
+ in Validate(), every descendant item in complexType must be first
+ validated before getting GetOptimizedParticle(), or it could result
+ in wrong content particle. Fixed bug #82010.
+
+2007-08-02 Atsushi Enomoto <atsushi@ximian.com>
+
* XmlSchemaValidator.cs : another extra whitespace rejection.
Fixed another issue reported on bug #82183.
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
index 9288d2b76f0..8f7d112e08f 100644
--- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
@@ -184,6 +184,8 @@ namespace System.Xml.Schema
internal override int Validate (ValidationEventHandler h, XmlSchema schema)
{
+ if (Particle != null)
+ Particle.Validate (h, schema);
return errorCount;
}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
index a44bfe60a35..4e74eb10e86 100644
--- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
@@ -409,13 +409,16 @@ namespace System.Xml.Schema
}
else
resolvedDerivedBy = XmlSchemaDerivationMethod.Empty;
+ }
-
+ void FillContentTypeParticle (ValidationEventHandler h, XmlSchema schema)
+ {
// {content type} => ContentType and ContentTypeParticle (later)
if (ContentModel != null) {
CollectContentTypeFromContentModel (h, schema);
} else
CollectContentTypeFromImmediateContent ();
+
contentTypeParticle = validatableParticle.GetOptimizedParticle (true);
if (contentTypeParticle == XmlSchemaParticle.Empty && resolvedContentType == XmlSchemaContentType.ElementOnly)
resolvedContentType = XmlSchemaContentType.Empty;
@@ -582,6 +585,10 @@ namespace System.Xml.Schema
CollectSchemaComponent (h, schema);
+ ValidateContentFirstPass (h, schema);
+
+ FillContentTypeParticle (h, schema);
+
// 3.4.6: Properties Correct
// Term. 1 => 3.4.1 already done by CollectSchemaComponent()
// except for {attribute uses} and {attribute wildcard}
@@ -590,11 +597,8 @@ namespace System.Xml.Schema
//
if (ContentModel != null)
ValidateContentModel (h, schema);
- else {
- if (Particle != null)
- ValidateImmediateParticle (h, schema);
+ else
ValidateImmediateAttributes (h, schema);
- }
// Additional support for 3.8.6 All Group Limited
if (ContentTypeParticle != null) {
@@ -634,19 +638,6 @@ namespace System.Xml.Schema
return errorCount;
}
- private void ValidateImmediateParticle (ValidationEventHandler h, XmlSchema schema)
- {
- errorCount += particle.Validate (h, schema);
- XmlSchemaGroupRef pgrp = Particle as XmlSchemaGroupRef;
- if (pgrp != null) {
- if (pgrp.TargetGroup != null)
- errorCount += pgrp.TargetGroup.Validate (h,schema);
- // otherwise, it might be missing sub components.
- else if (!schema.IsNamespaceAbsent (pgrp.RefName.Namespace))
- error (h, "Referenced group " + pgrp.RefName + " was not found in the corresponding schema.");
- }
- }
-
private void ValidateImmediateAttributes (ValidationEventHandler h, XmlSchema schema)
{
// {attribute uses}
@@ -656,12 +647,31 @@ namespace System.Xml.Schema
h, schema, attributes, anyAttribute, ref attributeWildcard, null, false);
}
+ private void ValidateContentFirstPass (ValidationEventHandler h, XmlSchema schema)
+ {
+ if (ContentModel != null) {
+ errorCount += contentModel.Validate (h, schema);
+ if (BaseXmlSchemaTypeInternal != null)
+ errorCount += BaseXmlSchemaTypeInternal.Validate (h, schema);
+ }
+ else if (Particle != null) {
+ errorCount += particle.Validate (h, schema);
+ XmlSchemaGroupRef pgrp = Particle as XmlSchemaGroupRef;
+ if (pgrp != null) {
+ if (pgrp.TargetGroup != null)
+ errorCount += pgrp.TargetGroup.Validate (h,schema);
+ // otherwise, it might be missing sub components.
+ else if (!schema.IsNamespaceAbsent (pgrp.RefName.Namespace))
+ error (h, "Referenced group " + pgrp.RefName + " was not found in the corresponding schema.");
+ }
+ }
+ }
+
private void ValidateContentModel (ValidationEventHandler h, XmlSchema schema)
{
XmlSchemaType baseType = BaseXmlSchemaTypeInternal;
// Here we check 3.4.6 Properties Correct :: 2. and 3.
- errorCount += contentModel.Validate (h, schema);
XmlSchemaComplexContentExtension cce = contentModel.Content as XmlSchemaComplexContentExtension;
XmlSchemaComplexContentRestriction ccr = contentModel.Content as XmlSchemaComplexContentRestriction;
XmlSchemaSimpleContentExtension sce = contentModel.Content as XmlSchemaSimpleContentExtension;
@@ -674,7 +684,6 @@ namespace System.Xml.Schema
if (ValidateRecursionCheck ())
error (h, "Circular definition of schema types was found.");
if (baseType != null) {
- baseType.Validate (h, schema);
// Fill "Datatype" property.
this.DatatypeInternal = baseType.Datatype;
} else if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)
@@ -776,8 +785,6 @@ namespace System.Xml.Schema
// For ValidationEventHandler.
if (baseComplexType == null)
baseComplexType = XmlSchemaComplexType.AnyType;
- if (ccr.Particle != null)
- ccr.Particle.Validate (h, schema);
// attributes
localAnyAttribute = ccr.AnyAttribute;
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs
index efc742f7ee6..b25e7130bc4 100644
--- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs
@@ -134,7 +134,7 @@ namespace System.Xml.Schema
XmlSchemaGroup g = referencedGroup != null ? referencedGroup : schema.Groups [RefName] as XmlSchemaGroup;
if (g != null && g.Particle != null) {
OptimizedParticle = g.Particle;
- OptimizedParticle = OptimizedParticle.GetOptimizedParticle (isTop);
+ OptimizedParticle = OptimizedParticle.GetOptimizedParticle (isTop);
if (OptimizedParticle != XmlSchemaParticle.Empty && (ValidatedMinOccurs != 1 || ValidatedMaxOccurs != 1)) {
OptimizedParticle = OptimizedParticle.GetShallowClone ();
OptimizedParticle.MinOccurs = this.MinOccurs;
diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog
index cf9989c7cc4..2df97d83e9c 100644
--- a/mcs/class/System.XML/Test/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/Test/System.Xml/ChangeLog
@@ -1,5 +1,9 @@
2007-08-02 Atsushi Enomoto <atsushi@ximian.com>
+ * XsdValidatingReaderTests.cs : test for bug #82010.
+
+2007-08-02 Atsushi Enomoto <atsushi@ximian.com>
+
* XsdValidatingReaderTests.cs : another test posted on bug #82183.
2007-07-17 Atsushi Enomoto <atsushi@ximian.com>
diff --git a/mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs b/mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs
index 79d22196427..977fafdba52 100644
--- a/mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XsdValidatingReaderTests.cs
@@ -5,7 +5,7 @@
// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
//
// (C)2003 Atsushi Enomoto
-// (C)2005-2006 Novell, Inc.
+// (C)2005-2007 Novell, Inc.
//
using System;
using System.IO;
@@ -432,6 +432,27 @@ namespace MonoTests.System.Xml
reader.Read ();
}
+ [Test]
+ public void Bug82010 ()
+ {
+ string xmlfile = "Test/XmlFiles/xsd/82010.xml";
+ string xsdfile = "Test/XmlFiles/xsd/82010.xsd";
+ XmlTextReader xr = null, xr2 = null;
+ try {
+ xr = new XmlTextReader (xsdfile);
+ xr2 = new XmlTextReader (xmlfile);
+ XmlValidatingReader xvr = new XmlValidatingReader (xr2);
+ xvr.Schemas.Add (XmlSchema.Read (xr, null));
+ while (!xvr.EOF)
+ xvr.Read ();
+ } finally {
+ if (xr2 != null)
+ xr2.Close ();
+ if (xr != null)
+ xr.Close ();
+ }
+ }
+
#if NET_2_0
[Test]
public void WhitespaceAndElementOnly ()
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/82010.xml b/mcs/class/System.XML/Test/XmlFiles/xsd/82010.xml
new file mode 100644
index 00000000000..5081c18dcb9
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlFiles/xsd/82010.xml
@@ -0,0 +1,7 @@
+<Document>
+ <SimpleCodeList>
+ <Row/>
+ <Row/>
+ </SimpleCodeList>
+</Document>
+
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/82010.xsd b/mcs/class/System.XML/Test/XmlFiles/xsd/82010.xsd
new file mode 100644
index 00000000000..7541a548373
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlFiles/xsd/82010.xsd
@@ -0,0 +1,29 @@
+<xsd:schema
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="Document" type="Document"/>
+ <xsd:complexType name="Document">
+ <xsd:sequence>
+ <xsd:group ref="OuterCodeListChoice" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:group name="OuterCodeListChoice">
+ <xsd:choice>
+ <xsd:group ref="SimpleCodeListSequence"/>
+ </xsd:choice>
+ </xsd:group>
+ <xsd:complexType name="Row">
+ <xsd:sequence>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="SimpleCodeList">
+ <xsd:sequence>
+ <xsd:element name="Row" minOccurs="0" maxOccurs="unbounded" type="Row"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:group name="SimpleCodeListSequence">
+ <xsd:sequence>
+ <xsd:element name="SimpleCodeList" type="SimpleCodeList"/>
+ </xsd:sequence>
+ </xsd:group>
+</xsd:schema>
+
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog b/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog
index 199e8f2342e..cf6f9e9faaf 100644
--- a/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog
+++ b/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog
@@ -1,3 +1,7 @@
+2007-08-02 Atsushi Enomoto <atsushi@ximian.com>
+
+ * 82010.xsd, 82010.xml : new test files.
+
2007-04-24 Atsushi Enomoto <atsushi@ximian.com>
* 81360.xsd, 81360inc1.xsd, 81360inc2.xsd : new test files.