internal bool Compile() {
schemaTypes.Insert(DatatypeImplementation.QnAnyType, XmlSchemaComplexType.AnyType);
if (schemaForSchema != null) { //Get our built-in types
schemaForSchema.SchemaTypes.Replace(DatatypeImplementation.QnAnyType, XmlSchemaComplexType.AnyType);
UpdateSForSSimpleTypes();
}
foreach(XmlSchemaGroup group in groups.Values) {
CompileGroup(group);
}
foreach(XmlSchemaAttributeGroup attributeGroup in attributeGroups.Values) {
CompileAttributeGroup(attributeGroup);
}
foreach (XmlSchemaType type in schemaTypes.Values) {
XmlSchemaComplexType ct = type as XmlSchemaComplexType;
if (ct != null) {
CompileComplexType(ct);
}
else {
CompileSimpleType((XmlSchemaSimpleType)type);
}
}
foreach (XmlSchemaElement element in elements.Values) {
if (element.ElementDecl == null) {
CompileElement(element);
}
}
foreach (XmlSchemaAttribute attribute in attributes.Values) {
if (attribute.AttDef == null) {
CompileAttribute(attribute);
}
}
foreach (XmlSchemaIdentityConstraint identityConstraint in identityConstraints.Values) {
if (identityConstraint.CompiledConstraint == null) {
CompileIdentityConstraint(identityConstraint);
}
}
while (this.complexTypeStack.Count > 0) {
XmlSchemaComplexType type = (XmlSchemaComplexType)complexTypeStack.Pop();
CompileComplexTypeElements(type);
}
ProcessSubstitutionGroups();
foreach (XmlSchemaType type in schemaTypes.Values) {
XmlSchemaComplexType localType = type as XmlSchemaComplexType;
if (localType != null) {
CheckParticleDerivation(localType);
}
}
foreach (XmlSchemaElement element in elements.Values) {
XmlSchemaComplexType localComplexType = element.ElementSchemaType as XmlSchemaComplexType;
if (localComplexType != null && element.SchemaTypeName == XmlQualifiedName.Empty) { // only local schemaTypes
CheckParticleDerivation(localComplexType);
}
}
foreach (XmlSchemaGroup group in groups.Values) { //Check particle derivation for redefined groups
XmlSchemaGroup baseGroup = group.Redefined;
if (baseGroup != null) {
RecursivelyCheckRedefinedGroups(group, baseGroup);
}
}
foreach (XmlSchemaAttributeGroup attributeGroup in attributeGroups.Values) {
XmlSchemaAttributeGroup baseAttributeGroup = attributeGroup.Redefined;
if (baseAttributeGroup != null) {
RecursivelyCheckRedefinedAttributeGroups(attributeGroup, baseAttributeGroup);
}
}
return !HasErrors;
}