Пример #1
0
        /// <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);
        }
Пример #2
0
        public string GetTextDocumentation()
        {
            string text = null;

            XMLSchema.annotated annotated = this.TabSchema as XMLSchema.annotated;
            if (annotated != null && annotated.annotation != null)
            {
                text = DiagramHelpers.GetAnnotationText(annotated.annotation);

                //foreach (object o in annotated.annotation.Items)
                //{
                //    if (o is XMLSchema.documentation)
                //    {
                //        XMLSchema.documentation documentation = o as XMLSchema.documentation;
                //        if (documentation.Any != null && documentation.Any.Length > 0 && documentation.Any[0].Value != null)
                //        {
                //            text = documentation.Any[0].Value;
                //            text = text.Replace("\n", " ");
                //            text = text.Replace("\t", " ");
                //            text = text.Replace("\r", "");
                //            text = Regex.Replace(text, " +", " ");
                //            text = text.Trim();
                //        }
                //        else if (documentation.source != null)
                //        {
                //            text = documentation.source;
                //        }
                //
                //        break;
                //    }
                //}
            }

            return(text);
        }
Пример #3
0
 private void ExpandAnnotated(DiagramItem parentDiagramElement,
                              XMLSchema.annotated annotated, string nameSpace)
 {
     if (annotated is XMLSchema.element)
     {
         AddElement(parentDiagramElement, annotated as XMLSchema.element, nameSpace);
         parentDiagramElement.ShowChildElements = true;
     }
     else if (annotated is XMLSchema.group)
     {
         AddCompositors(parentDiagramElement, annotated as XMLSchema.group, nameSpace);
         parentDiagramElement.ShowChildElements = true;
     }
     else if (annotated is XMLSchema.complexType)
     {
         ExpandComplexType(parentDiagramElement, annotated as XMLSchema.complexType);
         parentDiagramElement.ShowChildElements = true;
     }
 }
Пример #4
0
 private void GetChildrenInfo(XMLSchema.element childElement,
                              out bool hasChildren, out bool isSimpleType)
 {
     if (childElement.Item is XMLSchema.complexType)
     {
         XMLSchema.complexType complexTypeElement = childElement.Item as XMLSchema.complexType;
         GetChildrenInfo(complexTypeElement, out hasChildren, out isSimpleType);
         return;
         //if (complexTypeElement.Items != null)
         //{
         //    for (int i = 0; i < complexTypeElement.Items.Length; i++)
         //    {
         //        if (complexTypeElement.Items[i] is XMLSchema.group ||
         //            complexTypeElement.Items[i] is XMLSchema.complexType ||
         //            complexTypeElement.Items[i] is XMLSchema.complexContent)
         //        {
         //            return true;
         //        }
         //    }
         //}
     }
     else if (childElement.type != null)
     {
         XSDObject xsdObject = null;
         if (_elementsByName.TryGetValue(childElement.type.Namespace + ":type:" + childElement.type.Name, out xsdObject) && xsdObject != null)
         //if (_elementsByName.ContainsKey(childElement.type.Namespace + ":type:" + childElement.type.Name))
         {
             XMLSchema.annotated annotated = xsdObject.Tag as XMLSchema.annotated;
             if (annotated is XMLSchema.simpleType)
             {
                 hasChildren  = false;
                 isSimpleType = true;
             }
             else
             {
                 GetChildrenInfo(annotated as XMLSchema.complexType, out hasChildren, out isSimpleType);
             }
             return;
         }
     }
     hasChildren  = false;
     isSimpleType = true;
 }
Пример #5
0
        private static void ParseComplexTypeAttributes(Schema schema, string nameSpace, List <XSDAttribute> listAttributes, XMLSchema.complexType complexType, bool isRestriction)
        {
            if (complexType.ItemsElementName != null)
            {
                for (int i = 0; i < complexType.ItemsElementName.Length; i++)
                {
                    switch (complexType.ItemsElementName[i])
                    {
                    case XMLSchema.ItemsChoiceType4.attribute:
                    {
                        XMLSchema.attribute attribute = complexType.Items[i] as XMLSchema.attribute;
                        ParseAttribute(schema, nameSpace, listAttributes, attribute, false);
                    }
                    break;

                    case XMLSchema.ItemsChoiceType4.attributeGroup:
                    {
                        XMLSchema.attributeGroup attributeGroup = complexType.Items[i] as XMLSchema.attributeGroup;
                        ParseAttributeGroup(schema, nameSpace, listAttributes, attributeGroup, false);
                    }
                    break;

                    case XMLSchema.ItemsChoiceType4.anyAttribute:
                        XMLSchema.wildcard wildcard     = complexType.Items[i] as XMLSchema.wildcard;
                        XSDAttribute       xsdAttribute = new XSDAttribute("", "*", wildcard.@namespace, "", false, null, null, null);
                        listAttributes.Add(xsdAttribute);
                        break;

                    case XMLSchema.ItemsChoiceType4.simpleContent:
                    case XMLSchema.ItemsChoiceType4.complexContent:
                        XMLSchema.annotated annotatedContent = null;
                        if (complexType.Items[i] is XMLSchema.complexContent)
                        {
                            XMLSchema.complexContent complexContent = complexType.Items[i] as XMLSchema.complexContent;
                            annotatedContent = complexContent.Item;
                        }
                        else if (complexType.Items[i] is XMLSchema.simpleContent)
                        {
                            XMLSchema.simpleContent simpleContent = complexType.Items[i] as XMLSchema.simpleContent;
                            annotatedContent = simpleContent.Item;
                        }
                        if (annotatedContent is XMLSchema.extensionType)
                        {
                            XMLSchema.extensionType extensionType = annotatedContent as XMLSchema.extensionType;
                            //XSDObject xsdExtensionType = this.schema.ElementsByName[QualifiedNameToFullName("type", extensionType.@base)] as XSDObject;
                            //if (xsdExtensionType != null)
                            XSDObject xsdExtensionType;
                            if (schema.ElementsByName.TryGetValue(QualifiedNameToFullName("type", extensionType.@base), out xsdExtensionType) && xsdExtensionType != null)
                            {
                                XMLSchema.annotated annotatedExtension = xsdExtensionType.Tag as XMLSchema.annotated;
                                if (annotatedExtension != null)
                                {
                                    if (annotatedExtension is XMLSchema.complexType)
                                    {
                                        ParseComplexTypeAttributes(schema, [email protected], listAttributes, annotatedExtension as XMLSchema.complexType, false);
                                    }
                                }
                            }
                            if (extensionType.Items != null)
                            {
                                foreach (XMLSchema.annotated annotated in extensionType.Items)
                                {
                                    if (annotated is XMLSchema.attribute)
                                    {
                                        ParseAttribute(schema, nameSpace, listAttributes, annotated as XMLSchema.attribute, false);
                                    }
                                    else if (annotated is XMLSchema.attributeGroup)
                                    {
                                        ParseAttributeGroup(schema, nameSpace, listAttributes, annotated as XMLSchema.attributeGroup, false);
                                    }
                                }
                            }
                        }
                        else if (annotatedContent is XMLSchema.restrictionType)
                        {
                            XMLSchema.restrictionType restrictionType = annotatedContent as XMLSchema.restrictionType;
                            //XSDObject xsdRestrictionType = this.schema.ElementsByName[QualifiedNameToFullName("type", restrictionType.@base)] as XSDObject;
                            //if (xsdRestrictionType != null)
                            XSDObject xsdRestrictionType;
                            if (schema.ElementsByName.TryGetValue(QualifiedNameToFullName("type", restrictionType.@base), out xsdRestrictionType) && xsdRestrictionType != null)
                            {
                                XMLSchema.annotated annotatedRestriction = xsdRestrictionType.Tag as XMLSchema.annotated;
                                if (annotatedRestriction != null)
                                {
                                    if (annotatedRestriction is XMLSchema.complexType)
                                    {
                                        ParseComplexTypeAttributes(schema, [email protected], listAttributes, annotatedRestriction as XMLSchema.complexType, false);
                                    }
                                }
                            }
                            if (restrictionType.Items1 != null)
                            {
                                foreach (XMLSchema.annotated annotated in restrictionType.Items1)
                                {
                                    if (annotated is XMLSchema.attribute)
                                    {
                                        ParseAttribute(schema, nameSpace, listAttributes, annotated as XMLSchema.attribute, true);
                                    }
                                    else if (annotated is XMLSchema.attributeGroup)
                                    {
                                        ParseAttributeGroup(schema, nameSpace, listAttributes, annotated as XMLSchema.attributeGroup, true);
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
            }
            else
            {
            }
        }
Пример #6
0
        private void ExpandComplexType(DiagramItem parentDiagramElement,
                                       XMLSchema.complexType complexTypeElement)
        {
            if (complexTypeElement.Items != null)
            {
                XMLSchema.annotated[]        items           = complexTypeElement.Items;
                XMLSchema.ItemsChoiceType4[] itemsChoiceType = complexTypeElement.ItemsElementName;

                for (int i = 0; i < items.Length; i++)
                {
                    if (items[i] is XMLSchema.group)
                    {
                        XMLSchema.group group = items[i] as XMLSchema.group;
                        DiagramItem     diagramCompositors = AddCompositors(parentDiagramElement,
                                                                            group, (DiagramItemGroupType)Enum.Parse(typeof(DiagramItemGroupType), itemsChoiceType[i].ToString(), true), parentDiagramElement.NameSpace);
                        parentDiagramElement.ShowChildElements = true;
                        if (diagramCompositors != null)
                        {
                            ExpandChildren(diagramCompositors);
                        }
                    }
                    else if (items[i] is XMLSchema.complexContent)
                    {
                        XMLSchema.complexContent complexContent = items[i] as XMLSchema.complexContent;
                        if (complexContent.Item is XMLSchema.extensionType)
                        {
                            XMLSchema.extensionType extensionType = complexContent.Item as XMLSchema.extensionType;

                            XSDObject xsdObject = null;
                            if (_elementsByName.TryGetValue([email protected] + ":type:" + [email protected], out xsdObject) && xsdObject != null)
                            {
                                XMLSchema.annotated annotated = xsdObject.Tag as XMLSchema.annotated;
                                ExpandAnnotated(parentDiagramElement, annotated, [email protected]);
                            }

                            XMLSchema.group group = extensionType.group as XMLSchema.group;
                            if (group != null)
                            {
                                DiagramItem diagramCompositors = AddCompositors(parentDiagramElement, group, DiagramItemGroupType.Group, [email protected]);
                                parentDiagramElement.ShowChildElements = true;
                                if (diagramCompositors != null)
                                {
                                    ExpandChildren(diagramCompositors);
                                }
                            }

                            XMLSchema.group groupSequence = extensionType.sequence as XMLSchema.group;
                            if (groupSequence != null)
                            {
                                DiagramItem diagramCompositors = AddCompositors(parentDiagramElement, groupSequence, DiagramItemGroupType.Sequence, [email protected]);
                                parentDiagramElement.ShowChildElements = true;
                                if (diagramCompositors != null)
                                {
                                    ExpandChildren(diagramCompositors);
                                }
                            }

                            XMLSchema.group groupChoice = extensionType.choice as XMLSchema.group;
                            if (groupChoice != null)
                            {
                                DiagramItem diagramCompositors = AddCompositors(parentDiagramElement, groupChoice, DiagramItemGroupType.Choice, [email protected]);
                                parentDiagramElement.ShowChildElements = true;
                                if (diagramCompositors != null)
                                {
                                    ExpandChildren(diagramCompositors);
                                }
                            }

                            XMLSchema.group groupAll = extensionType.all as XMLSchema.group;
                            if (groupAll != null)
                            {
                                DiagramItem diagramCompositors = AddCompositors(parentDiagramElement, groupAll, DiagramItemGroupType.All, [email protected]);
                                parentDiagramElement.ShowChildElements = true;
                                if (diagramCompositors != null)
                                {
                                    ExpandChildren(diagramCompositors);
                                }
                            }
                        }
                        else if (complexContent.Item is XMLSchema.restrictionType)
                        {
                            XMLSchema.restrictionType restrictionType = complexContent.Item as XMLSchema.restrictionType;
                            XSDObject xsdObject = null;
                            if (_elementsByName.TryGetValue([email protected] + ":type:" + [email protected], out xsdObject) && xsdObject != null)
                            {
                                XMLSchema.annotated annotated = xsdObject.Tag as XMLSchema.annotated;
                                ExpandAnnotated(parentDiagramElement, annotated, [email protected]);
                            }
                            else
                            {
                                //dgis fix github issue 2
                                if (restrictionType.Items != null)
                                {
                                    //for (int j = 0; j < items.Length; j++)
                                    for (int j = 0; j < restrictionType.Items.Length; j++)
                                    {
                                        if (restrictionType.Items[j] is XMLSchema.group)
                                        {
                                            XMLSchema.group group = restrictionType.Items[j] as XMLSchema.group;
                                            DiagramItem     diagramCompositors = AddCompositors(parentDiagramElement, group,
                                                                                                (DiagramItemGroupType)Enum.Parse(typeof(DiagramItemGroupType), restrictionType.ItemsElementName[j].ToString(), true), parentDiagramElement.NameSpace);
                                            parentDiagramElement.ShowChildElements = true;
                                            if (diagramCompositors != null)
                                            {
                                                ExpandChildren(diagramCompositors);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #7
0
        public bool ExpandChildren(DiagramItem parentDiagramElement)
        {
            bool result = false;

            ClearSearch();
            if (parentDiagramElement.ItemType == DiagramItemType.element || parentDiagramElement.ItemType == DiagramItemType.type)
            {
                result = true;
                DiagramItem diagramElement = parentDiagramElement;
                if (diagramElement.TabSchema is XMLSchema.element)
                {
                    XMLSchema.element element = diagramElement.TabSchema as XMLSchema.element;

                    if (element.Item is XMLSchema.complexType)
                    {
                        XMLSchema.complexType complexTypeElement = element.Item as XMLSchema.complexType;
                        ExpandComplexType(diagramElement, complexTypeElement);
                    }
                    else if (element.type != null)
                    {
                        XSDObject objectAnnotated = null;
                        if (_elementsByName.TryGetValue(element.type.Namespace + ":type:" + element.type.Name, out objectAnnotated) && objectAnnotated != null)
                        {
                            XMLSchema.annotated annotated = objectAnnotated.Tag as XMLSchema.annotated;
                            ExpandAnnotated(diagramElement, annotated, element.type.Namespace);
                        }
                    }
                }
                else if (diagramElement.TabSchema is XMLSchema.any)
                {
                    //XMLSchema.any any = diagramElement.TabSchema as XMLSchema.any;

                    if (RequestAnyElement != null)
                    {
                        XMLSchema.element requestElement;
                        string            requestNameSpace;
                        RequestAnyElement(diagramElement, out requestElement, out requestNameSpace);
                        if (requestElement != null)
                        {
                            AddElement(diagramElement, requestElement, requestNameSpace);
                            diagramElement.ShowChildElements = true;
                        }
                    }
                }
                else if (diagramElement.TabSchema is XMLSchema.complexType)
                {
                    XMLSchema.complexType complexTypeElement = diagramElement.TabSchema as XMLSchema.complexType;
                    ExpandComplexType(diagramElement, complexTypeElement);
                }
            }
            else if (parentDiagramElement.ItemType == DiagramItemType.group)
            {
                result = true;
                DiagramItem     diagramCompositors = parentDiagramElement;
                XMLSchema.group group = diagramCompositors.TabSchema as XMLSchema.group;

                if (group.Items != null)
                {
                    for (int i = 0; i < group.Items.Length; i++)
                    {
                        switch (group.ItemsElementName[i])
                        {
                        case XMLSchema.ItemsChoiceType2.element:
                            if (group.Items[i] is XMLSchema.element)
                            {
                                AddElement(diagramCompositors, group.Items[i] as XMLSchema.element, diagramCompositors.NameSpace);
                            }
                            break;

                        case XMLSchema.ItemsChoiceType2.any:
                            if (group.Items[i] is XMLSchema.any)
                            {
                                AddAny(diagramCompositors, group.Items[i] as XMLSchema.any, diagramCompositors.NameSpace);
                            }
                            break;

                        case XMLSchema.ItemsChoiceType2.group:
                            if (group.Items[i] is XMLSchema.group)
                            {
                                AddCompositors(diagramCompositors, group.Items[i] as XMLSchema.group, DiagramItemGroupType.Group, diagramCompositors.NameSpace);
                            }
                            break;

                        case XMLSchema.ItemsChoiceType2.all:
                            if (group.Items[i] is XMLSchema.group)
                            {
                                AddCompositors(diagramCompositors, group.Items[i] as XMLSchema.group, DiagramItemGroupType.All, diagramCompositors.NameSpace);
                            }
                            break;

                        case XMLSchema.ItemsChoiceType2.choice:
                            if (group.Items[i] is XMLSchema.group)
                            {
                                AddCompositors(diagramCompositors, group.Items[i] as XMLSchema.group, DiagramItemGroupType.Choice, diagramCompositors.NameSpace);
                            }
                            break;

                        case XMLSchema.ItemsChoiceType2.sequence:
                            if (group.Items[i] is XMLSchema.group)
                            {
                                AddCompositors(diagramCompositors, group.Items[i] as XMLSchema.group, DiagramItemGroupType.Sequence, diagramCompositors.NameSpace);
                            }
                            break;
                        }
                    }
                    parentDiagramElement.ShowChildElements = true;
                }
                else
                {
                    AddAny(diagramCompositors, null, diagramCompositors.NameSpace);
                }
            }
            return(result);
        }
Пример #8
0
        /// <summary>
        /// Renders the specified drawing item.
        /// </summary>
        /// <param name="drawingItem">The drawing item.</param>
        public override void Render(DiagramItem drawingItem)
        {
            string type = "";

            if (drawingItem.TabSchema is XMLSchema.element)
            {
                type = "element";
            }
            else if (drawingItem.TabSchema is XMLSchema.simpleType)
            {
                type = "simpleType";
            }
            else if (drawingItem.TabSchema is XMLSchema.complexType)
            {
                type = "complexType";
            }

            string occurences = String.Format("{0}..", drawingItem.MinOccurrence) +
                                (drawingItem.MaxOccurrence == -1 ? "∞" : string.Format("{0}", drawingItem.MaxOccurrence));

            if (type.Length > 0)
            {
                string      path          = '/' + drawingItem.Name;
                DiagramItem parentElement = drawingItem.Parent;
                while (parentElement != null)
                {
                    //if (parentElement.ItemType == DiagramItemType.element && !string.IsNullOrEmpty(parentElement.Name))
                    if ((type == "element" || type == "simpleType" || type == "complexType") && !string.IsNullOrEmpty(parentElement.Name))
                    {
                        path = '/' + parentElement.Name + path;
                    }
                    parentElement = parentElement.Parent;
                }

                // Get the comment/documentation
                string comment = "";
                XMLSchema.annotated annotated = drawingItem.TabSchema as XMLSchema.annotated;
                if (annotated != null && annotated.annotation != null)
                {
                    foreach (object o in annotated.annotation.Items)
                    {
                        if (o is XMLSchema.documentation)
                        {
                            XMLSchema.documentation documentation = o as XMLSchema.documentation;
                            if (documentation.Any != null && documentation.Any.Length > 0 && documentation.Any[0].Value != null)
                            {
                                string text = documentation.Any[0].Value;
                                text    = text.Replace("\n", " ");
                                text    = text.Replace("\t", " ");
                                text    = text.Replace("\r", "");
                                text    = Regex.Replace(text, " +", " ");
                                text    = text.Trim();
                                comment = text;
                            }
                            else if (documentation.source != null)
                            {
                                comment = documentation.source;
                            }
                            break;
                        }
                    }
                }

                //bool lastChild = drawingItem.Parent.ChildElements[drawingItem.Parent.ChildElements.Count - 1] == drawingItem;

                // Output the item
                string            t;
                XMLSchema.element el;
                for (int i = 0; i < _finalTextOutputFields.Count; i++)
                {
                    el = drawingItem.TabSchema as XMLSchema.element;
                    if (el != null)
                    {
                        string et = "" + el.type;
                        if (et == "")
                        {
                            t = "[none]";
                        }
                        else
                        {
                            t = et.Substring(et.LastIndexOf(':') + 1);
                            if (t == "")
                            {
                                t = "[none]";
                            }
                        }
                    }
                    else
                    {
                        t = "[none]";
                    }
                    if (i > 0)
                    {
                        _writer.Write(_fieldSeparator);
                    }
                    string field = _finalTextOutputFields[i];
                    switch (field)
                    {
                    case "PATH": _writer.Write(path); break;

                    case "NAME": _writer.Write(drawingItem.Name); break;

                    case "TYPE": _writer.Write(type); break;

                    case "NAMESPACE": _writer.Write(drawingItem.NameSpace); break;

                    case "COMMENT": _writer.Write(comment); break;

                    case "SEQ": _writer.Write(occurences); break;

                    case "LASTCHILD": _writer.Write(this.iteratingLastChild ? "1" : "0"); break;

                    case "XSDTYPE": _writer.Write(t); break;
                    }
                }
                _writer.WriteLine();


                // Output the item attributes
                if (this.Schema != null && this.DisplayAttributes)
                {
                    string nameSpace = drawingItem.NameSpace;
                    if (annotated != null)
                    {
                        // Attributes enumeration
                        List <XSDAttribute> listAttributes = DiagramHelpers.GetAnnotatedAttributes(this.Schema, annotated, nameSpace);
                        listAttributes.Reverse();
                        for (int a = 0; a < listAttributes.Count; a++)
                        {
                            XSDAttribute xsdAttribute = listAttributes[a];
                            if (xsdAttribute != null)
                            {
                                string commentAttribute       = "";
                                XMLSchema.attribute attribute = xsdAttribute.Tag;
                                if (attribute != null && attribute.annotation != null)
                                {
                                    commentAttribute = DiagramHelpers.GetAnnotationText(attribute.annotation);
                                }

                                for (int i = 0; i < _finalTextOutputFields.Count; i++)
                                {
                                    if (i > 0)
                                    {
                                        _writer.Write(_fieldSeparator);
                                    }
                                    string field = _finalTextOutputFields[i];
                                    switch (field)
                                    {
                                    case "PATH": _writer.Write(path + "@" + xsdAttribute.Name); break;

                                    case "NAME": _writer.Write(drawingItem.Name + "@" + xsdAttribute.Name); break;

                                    case "TYPE": _writer.Write(xsdAttribute.Type); break;

                                    case "NAMESPACE": _writer.Write(xsdAttribute.NameSpace); break;

                                    case "COMMENT": _writer.Write(commentAttribute); break;
                                    }
                                }
                                _writer.WriteLine();
                            }

                            //this.listViewAttributes.Items.Add(new ListViewItem(new string[] { attribute.Name, attribute.Type, attribute.Use, attribute.DefaultValue, s })).Tag = attribute;
                        }
                    }
                }


                //// Draw the inheritor line
                //if (drawingItem.InheritFrom != null)
                //{
                //}

                //switch (drawingItem.ItemType)
                //{
                //    case DiagramItemType.element:
                //        break;

                //    case DiagramItemType.type:
                //        break;

                //    case DiagramItemType.group:
                //        {
                //            // Draw the main shape following the min/max occurences

                //            // Draw the group type
                //            switch (drawingItem.GroupType)
                //            {
                //                case DiagramItemGroupType.Sequence: break;
                //                case DiagramItemGroupType.Choice: break;
                //                case DiagramItemGroupType.All: break;
                //            }
                //            break;
                //        }
                //}

                //// Draw text
                //if (drawingItem.Name.Length > 0)
                //{
                //    //drawingItem.Name;
                //}

                //// Draw occurences small text
                //if (drawingItem.MaxOccurrence > 1 || drawingItem.MaxOccurrence == -1) {}

                //// Draw type
                //if (drawingItem.IsSimpleContent) {}

                //// Draw reference arrow
                //if (drawingItem.IsReference) {}
            }

            // Draw children expand box
            if (drawingItem.HasChildElements && drawingItem.ShowChildElements)
            {
                int c = 0;
                foreach (DiagramItem element in drawingItem.ChildElements)
                {
                    this.iteratingLastChild = drawingItem.ChildElements.Count == ++c;
                    this.Render(element);
                    //_writer.WriteLine();
                }
            }
        }
Пример #9
0
        public override void Render(DiagramItem drawingItem)
        {
            string type = "";

            if (drawingItem.TabSchema is XMLSchema.element)
            {
                type = "element";
            }
            else if (drawingItem.TabSchema is XMLSchema.simpleType)
            {
                type = "simpleType";
            }
            else if (drawingItem.TabSchema is XMLSchema.complexType)
            {
                type = "complexType";
            }

            if (type.Length > 0)
            {
                string      path          = '/' + drawingItem.Name;
                DiagramItem parentElement = drawingItem.Parent;
                while (parentElement != null)
                {
                    //if (parentElement.ItemType == DiagramItemType.element && !string.IsNullOrEmpty(parentElement.Name))
                    if ((type == "element" || type == "simpleType" || type == "complexType") && !string.IsNullOrEmpty(parentElement.Name))
                    {
                        path = '/' + parentElement.Name + path;
                    }
                    parentElement = parentElement.Parent;
                }

                string comment = "";
                XMLSchema.annotated annotated = drawingItem.TabSchema as XMLSchema.annotated;
                if (annotated != null && annotated.annotation != null)
                {
                    foreach (object o in annotated.annotation.Items)
                    {
                        if (o is XMLSchema.documentation)
                        {
                            XMLSchema.documentation documentation = o as XMLSchema.documentation;
                            if (documentation.Any != null && documentation.Any.Length > 0)
                            {
                                string text = documentation.Any[0].Value;
                                text    = text.Replace("\n", " ");
                                text    = text.Replace("\t", " ");
                                text    = text.Replace("\r", "");
                                text    = Regex.Replace(text, " +", " ");
                                text    = text.Trim();
                                comment = text;
                            }
                            else if (documentation.source != null)
                            {
                                comment = documentation.source;
                            }
                            break;
                        }
                    }
                }

                for (int i = 0; i < _finalTextOutputFields.Count; i++)
                {
                    if (i > 0)
                    {
                        _writer.Write(_fieldSeparator);
                    }
                    string field = _finalTextOutputFields[i];
                    switch (field)
                    {
                    case "PATH": _writer.Write(path); break;

                    case "NAME": _writer.Write(drawingItem.Name); break;

                    case "TYPE": _writer.Write(type); break;

                    case "NAMESPACE": _writer.Write(drawingItem.NameSpace); break;

                    case "COMMENT": _writer.Write(comment); break;
                    }
                }
                _writer.WriteLine();


                //// Draw the inheritor line
                //if (drawingItem.InheritFrom != null)
                //{
                //}

                //switch (drawingItem.ItemType)
                //{
                //    case DiagramItemType.element:
                //        break;

                //    case DiagramItemType.type:
                //        break;

                //    case DiagramItemType.group:
                //        {
                //            // Draw the main shape following the min/max occurences

                //            // Draw the group type
                //            switch (drawingItem.GroupType)
                //            {
                //                case DiagramItemGroupType.Sequence: break;
                //                case DiagramItemGroupType.Choice: break;
                //                case DiagramItemGroupType.All: break;
                //            }
                //            break;
                //        }
                //}

                //// Draw text
                //if (drawingItem.Name.Length > 0)
                //{
                //    //drawingItem.Name;
                //}

                //// Draw occurences small text
                //if (drawingItem.MaxOccurrence > 1 || drawingItem.MaxOccurrence == -1) {}

                //// Draw type
                //if (drawingItem.IsSimpleContent) {}

                //// Draw reference arrow
                //if (drawingItem.IsReference) {}
            }

            // Draw children expand box
            if (drawingItem.HasChildElements && drawingItem.ShowChildElements)
            {
                foreach (DiagramItem element in drawingItem.ChildElements)
                {
                    this.Render(element);
                    //_writer.WriteLine();
                }
            }
        }