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
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/class/System.XML/System.Xml.Schema
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/class/System.XML/System.Xml.Schema')
-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
4 files changed, 40 insertions, 23 deletions
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;