/// <summary> /// Gets the annotated attributes. /// </summary> /// <param name="schema">The schema.</param> /// <param name="annotated">The annotated.</param> /// <param name="nameSpace">The name space.</param> /// <returns>The list of all the attributes.</returns> public static List <XSDAttribute> GetAnnotatedAttributes(Schema schema, XMLSchema.annotated annotated, string nameSpace) { // Attributes enumeration List <XSDAttribute> listAttributes = new List <XSDAttribute>(); if (annotated is XMLSchema.element) { XMLSchema.element element = annotated as XMLSchema.element; if (element.Item is XMLSchema.complexType) { XMLSchema.complexType complexType = element.Item as XMLSchema.complexType; listAttributes.AddRange(GetComplexTypeAttributes(schema, complexType, nameSpace)); } else if (element.type != null) { //XSDObject xsdObject = this.schema.ElementsByName[DiagramHelpers.QualifiedNameToFullName("type", element.type)] as XSDObject; //if (xsdObject != null) XSDObject xsdObject; if (schema.ElementsByName.TryGetValue(DiagramHelpers.QualifiedNameToFullName("type", element.type), out xsdObject) && xsdObject != null) { XMLSchema.annotated annotatedElement = xsdObject.Tag as XMLSchema.annotated; if (annotatedElement is XMLSchema.complexType) { XMLSchema.complexType complexType = annotatedElement as XMLSchema.complexType; listAttributes.AddRange(GetComplexTypeAttributes(schema, complexType, nameSpace)); } else { } } else { } } else { } } else if (annotated is XMLSchema.complexType) { XMLSchema.complexType complexType = annotated as XMLSchema.complexType; listAttributes.AddRange(GetComplexTypeAttributes(schema, complexType, nameSpace)); } else if (annotated is XMLSchema.simpleType) { XMLSchema.attribute attr = new XMLSchema.attribute(); XMLSchema.localSimpleType def = new XMLSchema.localSimpleType(); def.Item = (annotated as XMLSchema.simpleType).Item; attr.simpleType = def; string type = ""; if (def.Item is XMLSchema.restriction) { type = (def.Item as XMLSchema.restriction)[email protected]; } XSDAttribute XSDattr = new XSDAttribute("filename", (annotated as XMLSchema.simpleType).name, "namespace", type, false, "", "", attr); listAttributes.Add(XSDattr); } return(listAttributes); }
private void SelectSchemaElement(XMLSchema.openAttrs openAttrs, string nameSpace) { this.propertyGridSchemaObject.SelectedObject = openAttrs; ShowDocumentation(null); XMLSchema.annotated annotated = openAttrs as XMLSchema.annotated; if (annotated != null) { // Element documentation if (annotated.annotation != null) ShowDocumentation(annotated.annotation); // Show the enumeration ShowEnumerate(annotated); // Attributes enumeration List<XSDAttribute> listAttributes = new List<XSDAttribute>(); if (annotated is XMLSchema.element) { XMLSchema.element element = annotated as XMLSchema.element; if (element.Item is XMLSchema.complexType) { XMLSchema.complexType complexType = element.Item as XMLSchema.complexType; listAttributes.AddRange(ShowAttributes(complexType, nameSpace)); } else if (element.type != null) { //XSDObject xsdObject = this.schema.ElementsByName[QualifiedNameToFullName("type", element.type)] as XSDObject; //if (xsdObject != null) XSDObject xsdObject; if (this.schema.ElementsByName.TryGetValue(QualifiedNameToFullName("type", element.type), out xsdObject) && xsdObject != null) { XMLSchema.annotated annotatedElement = xsdObject.Tag as XMLSchema.annotated; if (annotatedElement is XMLSchema.complexType) { XMLSchema.complexType complexType = annotatedElement as XMLSchema.complexType; listAttributes.AddRange(ShowAttributes(complexType, nameSpace)); } else { } } else { } } else { } } else if (annotated is XMLSchema.complexType) { XMLSchema.complexType complexType = annotated as XMLSchema.complexType; listAttributes.AddRange(ShowAttributes(complexType, nameSpace)); } //RC++ Original code //else //{ //} //this.listViewAttributes.Items.Clear(); //foreach (XSDAttribute attribute in listAttributes) // this.listViewAttributes.Items.Add(new ListViewItem(new string[] { attribute.Name, attribute.Type, attribute.Use, attribute.DefaultValue })).Tag = attribute; //RC-- //Adrian++ //This part i modify else if (annotated is XMLSchema.simpleType) { XMLSchema.attribute attr = new XMLSchema.attribute(); XMLSchema.localSimpleType def = new XMLSchema.localSimpleType(); def.Item = (annotated as XMLSchema.simpleType).Item; attr.simpleType = def; string type = ""; if (def.Item is XMLSchema.restriction) type = (def.Item as XMLSchema.restriction)[email protected]; XSDAttribute XSDattr = new XSDAttribute("filename", (annotated as XMLSchema.simpleType).name, "namespace", type, false, "", "", attr); listAttributes.Add(XSDattr); } //This part i modify this.listViewAttributes.Items.Clear(); listAttributes.Reverse(); foreach (XSDAttribute attribute in listAttributes) { string s = ""; //dgis fix github issue 2 (attribute.Tag == null ???) if (attribute.Tag != null && attribute.Tag.simpleType != null && attribute.Tag.simpleType.Item is XMLSchema.restriction) { XMLSchema.restriction r = attribute.Tag.simpleType.Item as XMLSchema.restriction; if (r.Items != null) { for (int i = 0; i < r.Items.Length; i++) { s += r.ItemsElementName[i].ToString() + "(" + r.Items[i].id + " " + r.Items[i].value + ");"; } } } this.listViewAttributes.Items.Add(new ListViewItem(new string[] { attribute.Name, attribute.Type, attribute.Use, attribute.DefaultValue, s })).Tag = attribute; } //Adrian-- } }