internal static XmlSchemaObjectCollection CloneAttributes(XmlSchemaObjectCollection attributes) {
if (HasAttributeQNameRef(attributes)) {
XmlSchemaObjectCollection newAttributes = attributes.Clone();
XmlSchemaAttributeGroupRef attributeGroupRef;
XmlSchemaAttributeGroupRef newAttGroupRef;
XmlSchemaObject xso;
XmlSchemaAttribute att;
for (int i = 0; i < attributes.Count; i++) {
xso = attributes[i];
attributeGroupRef = xso as XmlSchemaAttributeGroupRef;
if (attributeGroupRef != null) {
newAttGroupRef = (XmlSchemaAttributeGroupRef)attributeGroupRef.Clone();
newAttGroupRef.RefName = attributeGroupRef.RefName.Clone();
newAttributes[i] = newAttGroupRef;
}
else { //Its XmlSchemaAttribute
att = xso as XmlSchemaAttribute;
if (!att.RefName.IsEmpty || !att.SchemaTypeName.IsEmpty) {
newAttributes[i] = att.Clone();
}
}
}
return newAttributes;
}
return attributes;
}