private ContentValidator CompileComplexContent(XmlSchemaComplexType complexType) {
if (complexType.ContentType == XmlSchemaContentType.Empty) {
return ContentValidator.Empty;
}
else if (complexType.ContentType == XmlSchemaContentType.TextOnly) {
return ContentValidator.TextOnly;
}
XmlSchemaParticle particle = complexType.ContentTypeParticle;
if (particle == null || particle == XmlSchemaParticle.Empty) {
if (complexType.ContentType == XmlSchemaContentType.ElementOnly) {
return ContentValidator.Empty;
}
else {
return ContentValidator.Mixed;
}
}
PushComplexType(complexType);
if (particle is XmlSchemaAll) {
XmlSchemaAll all = (XmlSchemaAll)particle;
AllElementsContentValidator contentValidator = new AllElementsContentValidator(complexType.ContentType, all.Items.Count, all.MinOccurs == decimal.Zero);
foreach (XmlSchemaElement localElement in all.Items) {
if (!contentValidator.AddElement(localElement.QualifiedName, localElement, localElement.MinOccurs == decimal.Zero)) {
SendValidationEvent(Res.Sch_DupElement, localElement.QualifiedName.ToString(), localElement);
}
}
return contentValidator;
}
else {
ParticleContentValidator contentValidator = new ParticleContentValidator(complexType.ContentType);
#if DEBUG
string name = complexType.Name != null ? complexType.Name : string.Empty;
Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceVerbose, "CompileComplexContent: "+ name + DumpContentModel(particle));
#endif
try {
contentValidator.Start();
BuildParticleContentModel(contentValidator, particle);
return contentValidator.Finish(compileContentModel);
}
catch(UpaException e) {
if (e.Particle1 is XmlSchemaElement) {
if (e.Particle2 is XmlSchemaElement) {
SendValidationEvent(Res.Sch_NonDeterministic, ((XmlSchemaElement)e.Particle1).QualifiedName.ToString(), (XmlSchemaElement)e.Particle2);
}
else {
SendValidationEvent(Res.Sch_NonDeterministicAnyEx, ((XmlSchemaAny)e.Particle2).NamespaceList.ToString(), ((XmlSchemaElement)e.Particle1).QualifiedName.ToString(), (XmlSchemaAny)e.Particle2);
}
}
else {
if (e.Particle2 is XmlSchemaElement) {
SendValidationEvent(Res.Sch_NonDeterministicAnyEx, ((XmlSchemaAny)e.Particle1).NamespaceList.ToString(), ((XmlSchemaElement)e.Particle2).QualifiedName.ToString(), (XmlSchemaAny)e.Particle1);
}
else {
SendValidationEvent(Res.Sch_NonDeterministicAnyAny, ((XmlSchemaAny)e.Particle1).NamespaceList.ToString(), ((XmlSchemaAny)e.Particle2).NamespaceList.ToString() ,(XmlSchemaAny)e.Particle1);
}
}
return XmlSchemaComplexType.AnyTypeContentValidator;
}
catch(NotSupportedException) {
SendValidationEvent(Res.Sch_ComplexContentModel, complexType, XmlSeverityType.Warning);
return XmlSchemaComplexType.AnyTypeContentValidator;
}
}
}