Example #1
0
        private void GetChildrenInfo(XMLSchema.complexType complexTypeElement,
                                     out bool hasChildren, out bool isSimpleType)
        {
            bool hasSimpleContent = false;

            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)
                    {
                        hasChildren  = true;
                        isSimpleType = complexTypeElement.mixed;
                        if (complexTypeElement.Items[i] is XMLSchema.complexContent)
                        {
                            //hasChildren = false;
                            XMLSchema.complexContent complexContent = complexTypeElement.Items[i] as XMLSchema.complexContent;
                            if (complexContent.Item is XMLSchema.extensionType)
                            {
                                hasChildren = false;
                                XMLSchema.extensionType extensionType = complexContent.Item as XMLSchema.extensionType;
                                if (extensionType.all != null || extensionType.group != null || extensionType.choice != null || extensionType.sequence != null)
                                {
                                    hasChildren = true;
                                }
                                else if (extensionType.@base != null)
                                {
                                    XSDObject xsdObject = null;
                                    if (_elementsByName.TryGetValue([email protected] + ":type:" + [email protected], out xsdObject) && xsdObject != null)
                                    {
                                        XMLSchema.complexType baseComplexType = xsdObject.Tag as XMLSchema.complexType;
                                        if (baseComplexType != null)
                                        {
                                            GetChildrenInfo(baseComplexType, out hasChildren, out isSimpleType);
                                        }
                                    }
                                }
                            }
                            //else if (complexContent.Item is XMLSchema.complexRestrictionType)
                            //{
                            //    XMLSchema.complexRestrictionType complexRestrictionType = complexContent.Item as XMLSchema.complexRestrictionType;

                            //}
                        }
                        return;
                    }
                    else if (complexTypeElement.Items[i] is XMLSchema.simpleContent)
                    {
                        hasSimpleContent = true;
                    }
                }
            }
            hasChildren  = false;
            isSimpleType = (hasSimpleContent ? true : complexTypeElement.mixed);
        }
Example #2
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
            {
            }
        }
Example #3
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);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }