private void PreprocessParticle(XmlSchemaParticle particle) {
if (particle is XmlSchemaAll) {
if (particle.MinOccurs != decimal.Zero && particle.MinOccurs != decimal.One) {
particle.MinOccurs = decimal.One;
SendValidationEvent(Res.Sch_InvalidAllMin, particle);
}
if (particle.MaxOccurs != decimal.One) {
particle.MaxOccurs = decimal.One;
SendValidationEvent(Res.Sch_InvalidAllMax, particle);
}
foreach(XmlSchemaElement element in ((XmlSchemaAll)particle).Items) {
if (element.MaxOccurs != decimal.Zero && element.MaxOccurs != decimal.One) {
element.MaxOccurs = decimal.One;
SendValidationEvent(Res.Sch_InvalidAllElementMax, element);
}
SetParent(element, particle);
PreprocessLocalElement(element);
}
}
else {
if (particle.MinOccurs > particle.MaxOccurs) {
particle.MinOccurs = particle.MaxOccurs;
SendValidationEvent(Res.Sch_MinGtMax, particle);
}
if (particle is XmlSchemaChoice) {
foreach(XmlSchemaObject item in ((XmlSchemaChoice)particle).Items) {
SetParent(item, particle);
if (item is XmlSchemaElement) {
PreprocessLocalElement((XmlSchemaElement)item);
}
else {
PreprocessParticle((XmlSchemaParticle)item);
}
}
}
else if (particle is XmlSchemaSequence) {
foreach(XmlSchemaObject item in ((XmlSchemaSequence)particle).Items) {
SetParent(item, particle);
if (item is XmlSchemaElement) {
PreprocessLocalElement((XmlSchemaElement)item);
}
else {
PreprocessParticle((XmlSchemaParticle)item);
}
}
}
else if (particle is XmlSchemaGroupRef) {
XmlSchemaGroupRef groupRef = (XmlSchemaGroupRef)particle;
if (groupRef.RefName.IsEmpty) {
SendValidationEvent(Res.Sch_MissAttribute, "ref", groupRef);
}
else {
ValidateQNameAttribute(groupRef, "ref", groupRef.RefName);
}
}
else if (particle is XmlSchemaAny) {
try {
((XmlSchemaAny)particle).BuildNamespaceListV1Compat(this.targetNamespace);
}
catch {
SendValidationEvent(Res.Sch_InvalidAny, particle);
}
}
}
PreprocessAnnotation(particle); //set parent of annotation child of group / all/ choice / sequence
ValidateIdAttribute(particle);
}