private XmlSchemaContentType resolvedContentType;
internal bool ValidatedIsAbstract;
- internal bool ParentIsSchema = false;
+ internal bool ParentIsSchema {
+ get { return Parent is XmlSchema; }
+ }
const string xmlname = "complexType";
get {
if (anyType == null) {
anyType = new XmlSchemaComplexType ();
- anyType.Name = ""; // In MS.NET, it is not "anyType"
- anyType.QNameInternal = XmlQualifiedName.Empty; // Not xs:anyType as well.
-#if BUGGY_MS_COMPLIANT
- anyType.validatableParticle = XmlSchemaParticle.Empty; // This code makes validator handles these schemas incorrectly: particlesIb001, mgM013, mgH014, ctE004, ctD004
-#else
- anyType.validatableParticle = XmlSchemaAny.AnyTypeContent;
-#endif
+ anyType.Name = "anyType";
+ anyType.QNameInternal = new XmlQualifiedName ("anyType", XmlSchema.Namespace);
+ if (XmlSchemaUtil.StrictMsCompliant)
+ anyType.validatableParticle = XmlSchemaParticle.Empty; // This code makes validator handles these schemas incorrectly: particlesIb001, mgM013, mgH014, ctE004, ctD004
+ else
+ anyType.validatableParticle = XmlSchemaAny.AnyTypeContent;
+
anyType.contentTypeParticle = anyType.validatableParticle;
anyType.DatatypeInternal = XmlSchemaSimpleType.AnySimpleType;
anyType.isMixed = true;
get{ return contentTypeParticle; }
}
+ internal override void SetParent (XmlSchemaObject parent)
+ {
+ base.SetParent (parent);
+ if (ContentModel != null)
+ ContentModel.SetParent (this);
+ if (Particle != null)
+ Particle.SetParent (this);
+ if (AnyAttribute != null)
+ AnyAttribute.SetParent (this);
+ foreach (XmlSchemaObject obj in Attributes)
+ obj.SetParent (this);
+ }
+
/// <remarks>
/// 1. If ContentModel is present, neither particle nor Attributes nor AnyAttribute can be present.
/// 2. If particle is present,
if (CompilationId == schema.CompilationId)
return errorCount;
-#if NET_2_0
- if (ContentModel != null)
- ContentModel.Parent = this;
- if (Particle != null)
- Particle.Parent = this;
- if (AnyAttribute != null)
- AnyAttribute.Parent = this;
- foreach (XmlSchemaObject obj in Attributes)
- obj.Parent = this;
-#endif
-
ValidatedIsAbstract = isAbstract;
+ attributeUses.Clear();
if (isRedefinedComponent) {
if (Annotation != null)
else if(!XmlSchemaUtil.CheckNCName(Name))
error(h,"name must be a NCName");
else
- this.QNameInternal = new XmlQualifiedName(Name, schema.TargetNamespace);
+ this.QNameInternal = new XmlQualifiedName(Name, AncestorSchema.TargetNamespace);
if(Block != XmlSchemaDerivationMethod.None)
{
}
else
resolvedDerivedBy = XmlSchemaDerivationMethod.Empty;
+ }
+ 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);
} else
CollectContentTypeFromImmediateContent ();
+
contentTypeParticle = validatableParticle.GetOptimizedParticle (true);
if (contentTypeParticle == XmlSchemaParticle.Empty && resolvedContentType == XmlSchemaContentType.ElementOnly)
resolvedContentType = XmlSchemaContentType.Empty;
-
- CollectProcessId = schema.CompilationId;
}
#region {content type}
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;
}
// 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) {
} else {
validatableParticle = baseComplexType.ValidatableParticle;
resolvedContentType = baseComplexType.resolvedContentType;
+ // Bug #501814
+ if (resolvedContentType == XmlSchemaContentType.Empty)
+ resolvedContentType = GetComplexContentType (contentModel);
}
} else if (baseComplexType.validatableParticle == XmlSchemaParticle.Empty
|| baseComplexType == XmlSchemaComplexType.AnyType) {
CollectSchemaComponent (h, schema);
+ ValidateBaseXmlSchemaType (h, schema);
+
+ ValidateParticle (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}
//
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) {
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}
XmlSchemaUtil.ValidateAttributesResolved (attributeUses,
h, schema, attributes, anyAttribute, ref attributeWildcard, null, false);
}
+
+ private void ValidateBaseXmlSchemaType (ValidationEventHandler h, XmlSchema schema)
+ {
+ if (ContentModel != null && BaseXmlSchemaTypeInternal != null)
+ errorCount += BaseXmlSchemaTypeInternal.Validate (h, schema);
+ }
+
+ private void ValidateParticle (ValidationEventHandler h, XmlSchema schema)
+ {
+ if (ContentModel == null && 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)
{
+ errorCount += contentModel.Validate (h, 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;
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)
// For ValidationEventHandler.
if (baseComplexType == null)
baseComplexType = XmlSchemaComplexType.AnyType;
- if (ccr.Particle != null)
- ccr.Particle.Validate (h, schema);
// attributes
localAnyAttribute = ccr.AnyAttribute;
}
// complexType/simpleContent/restriction
if (scr != null) {
- // Attributes
- baseAnyAttribute = baseComplexType != null ? baseComplexType.AttributeWildcard : null;
-
+ // attributes
localAnyAttribute = scr.AnyAttribute;
- if (localAnyAttribute != null && baseAnyAttribute != null)
+ this.attributeWildcard = localAnyAttribute;
+ if (baseComplexType != null)
+ baseAnyAttribute = baseComplexType.AttributeWildcard;
+ if (baseAnyAttribute != null && localAnyAttribute != null)
// 1.3 attribute wildcard subset. (=> 3.10.6)
localAnyAttribute.ValidateWildcardSubset (baseAnyAttribute, h, schema);
// 3.4.6 :: 5.1. Beware that There is an errata for 5.1!!
errorCount += XmlSchemaUtil.ValidateAttributesResolved (
this.attributeUses, h, schema, scr.Attributes,
scr.AnyAttribute, ref attributeWildcard, null, false);
+ foreach (DictionaryEntry entry in baseComplexType.AttributeUses) {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) entry.Value;
+ if (attributeUses [attr.QualifiedName] == null)
+ XmlSchemaUtil.AddToTable (attributeUses, attr, attr.QualifiedName, h);
+ }
}
// Common process of AttributeWildcard.