示例#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
        private void ParseSchema(string fileName, string baseUrl, XMLSchema.schema schemaDOM)
        {
            string basePath = Path.GetDirectoryName(fileName);

            if (schemaDOM.Items != null)
            {
                foreach (XMLSchema.openAttrs openAttrs in schemaDOM.Items)
                {
                    string loadedFileName = "";
                    string schemaLocation = "";

                    if (openAttrs is XMLSchema.include)
                    {
                        XMLSchema.include include = openAttrs as XMLSchema.include;
                        if (include.schemaLocation != null)
                        {
                            schemaLocation = include.schemaLocation;
                        }
                    }
                    else if (openAttrs is XMLSchema.import)
                    {
                        XMLSchema.import import = openAttrs as XMLSchema.import;
                        if (import.schemaLocation != null)
                        {
                            schemaLocation = import.schemaLocation;
                        }
                    }

                    if (!string.IsNullOrEmpty(schemaLocation))
                    {
                        schemaLocation = Uri.UnescapeDataString(schemaLocation);

                        loadedFileName = basePath + Path.DirectorySeparatorChar + schemaLocation.Replace('/', Path.DirectorySeparatorChar);

                        string url = schemaLocation.Trim();
                        if (url.IndexOf("http://") == 0 || url.IndexOf("https://") == 0)
                        {
                            string lf, bu;
                            if (LoadSchemaFromUrl(basePath, url, out lf, out bu))
                            {
                                loadedFileName = lf;
                                baseUrl        = bu; // The baseUrl change for this file
                            }
                        }
                        else if (!File.Exists(loadedFileName))
                        {
                            // The relative file does not exist, so try to download it from the web with the baseUrl
                            url = baseUrl + "/" + schemaLocation;

                            string lf, bu;
                            if (LoadSchemaFromUrl(basePath, url, out lf, out bu))
                            {
                                loadedFileName = lf;
                                baseUrl        = bu; // The baseUrl change for this file
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(loadedFileName))
                    {
                        ImportSchema(loadedFileName, baseUrl);
                    }
                }
            }

            string nameSpace = schemaDOM.targetNamespace;

            if (schemaDOM.Items1 != null)
            {
                foreach (XMLSchema.openAttrs openAttrs in schemaDOM.Items1)
                {
                    if (openAttrs is XMLSchema.element)
                    {
                        XMLSchema.element element   = openAttrs as XMLSchema.element;
                        XSDObject         xsdObject = new XSDObject(fileName, element.name, nameSpace, "element", element);
                        this.hashtableElementsByName[xsdObject.FullName] = xsdObject;

                        if (this.firstElement == null)
                        {
                            this.firstElement = xsdObject;
                        }

                        elements.Add(xsdObject);
                    }
                    else if (openAttrs is XMLSchema.group)
                    {
                        XMLSchema.group group     = openAttrs as XMLSchema.group;
                        XSDObject       xsdObject = new XSDObject(fileName, group.name, nameSpace, "group", group);
                        this.hashtableElementsByName[xsdObject.FullName] = xsdObject;

                        elements.Add(xsdObject);
                    }
                    else if (openAttrs is XMLSchema.simpleType)
                    {
                        XMLSchema.simpleType simpleType = openAttrs as XMLSchema.simpleType;
                        XSDObject            xsdObject  = new XSDObject(fileName, simpleType.name, nameSpace, "simpleType", simpleType);
                        this.hashtableElementsByName[xsdObject.FullName] = xsdObject;

                        elements.Add(xsdObject);
                    }
                    else if (openAttrs is XMLSchema.complexType)
                    {
                        XMLSchema.complexType complexType = openAttrs as XMLSchema.complexType;
                        XSDObject             xsdObject   = new XSDObject(fileName, complexType.name, nameSpace, "complexType", complexType);
                        this.hashtableElementsByName[xsdObject.FullName] = xsdObject;

                        elements.Add(xsdObject);
                    }
                    else if (openAttrs is XMLSchema.attribute)
                    {
                        XMLSchema.attribute attribute    = openAttrs as XMLSchema.attribute;
                        XSDAttribute        xsdAttribute = new XSDAttribute(fileName, attribute.name, nameSpace, "attribute", attribute.@ref != null, attribute.@default, attribute.use.ToString(), attribute);
                        this.hashtableAttributesByName[xsdAttribute.FullName] = xsdAttribute;
                    }
                    else if (openAttrs is XMLSchema.attributeGroup)
                    {
                        XMLSchema.attributeGroup attributeGroup    = openAttrs as XMLSchema.attributeGroup;
                        XSDAttributeGroup        xsdAttributeGroup = new XSDAttributeGroup(fileName, attributeGroup.name, nameSpace, "attributeGroup", attributeGroup is XMLSchema.attributeGroupRef, attributeGroup);
                        this.hashtableAttributesByName[xsdAttributeGroup.FullName] = xsdAttributeGroup;
                    }
                }
            }
        }
示例#3
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
            {
            }
        }
示例#4
0
        private static XSDAttribute ParseAttribute(Schema schema, string nameSpace, List <XSDAttribute> listAttributes, XMLSchema.attribute attribute, bool isRestriction)
        {
            bool   isReference = false;
            string filename    = "";
            string name        = attribute.name;
            string type        = "";

            if (attribute.@ref != null)
            {
                object o = null;
                schema.AttributesByName.TryGetValue(QualifiedNameToFullName("attribute", attribute.@ref), out o);
                if (o is XSDAttribute)
                {
                    XSDAttribute xsdAttributeInstance = o as XSDAttribute;
                    XSDAttribute refXSDAttribute      = ParseAttribute(schema, nameSpace, listAttributes, xsdAttributeInstance.Tag, isRestriction);
                    if (refXSDAttribute != null)
                    {
                        // Override the "use" field with
                        refXSDAttribute.Use = attribute.use.ToString();
                    }
                    return(null);
                }
                else // Reference not found!
                {
                    type        = QualifiedNameToAttributeTypeName(attribute.@ref);
                    name        = [email protected];
                    nameSpace   = [email protected];
                    isReference = true;
                }
            }
            else if (attribute.type != null)
            {
                type      = QualifiedNameToAttributeTypeName(attribute.type);
                nameSpace = attribute.type.Namespace;
            }
            else if (attribute.simpleType != null)
            {
                XMLSchema.simpleType simpleType = attribute.simpleType as XMLSchema.simpleType;
                if (simpleType.Item is XMLSchema.restriction)
                {
                    XMLSchema.restriction restriction = simpleType.Item as XMLSchema.restriction;
                    type      = QualifiedNameToAttributeTypeName(restriction.@base);
                    nameSpace = [email protected];
                }
                else if (simpleType.Item is XMLSchema.list)
                {
                    XMLSchema.list list = simpleType.Item as XMLSchema.list;
                    type      = QualifiedNameToAttributeTypeName(list.itemType);
                    nameSpace = list.itemType.Namespace;
                }
                else
                {
                }
            }
            else
            {
            }
            if (string.IsNullOrEmpty(attribute.name) && string.IsNullOrEmpty(name))
            {
            }
            if (isRestriction)
            {
                if (attribute.use == XMLSchema.attributeUse.prohibited)
                {
                    foreach (XSDAttribute xsdAttribute in listAttributes)
                    {
                        if (xsdAttribute.Name == name)
                        {
                            //listAttributes.Remove(xsdAttribute);
                            xsdAttribute.Use = attribute.use.ToString();
                            break;
                        }
                    }
                }
            }
            else
            {
                XSDAttribute xsdAttribute = new XSDAttribute(filename, name, nameSpace, type, isReference, attribute.@default, attribute.use.ToString(), attribute);
                listAttributes.Insert(0, xsdAttribute);
                return(xsdAttribute);
            }
            return(null);
        }
示例#5
0
        private void ParseSchema(string fileName, string baseUrl, XMLSchema.schema schemaDOM)
        {
            string basePath = Path.GetDirectoryName(fileName);
            if (schemaDOM.Items != null)
            {
                foreach (XMLSchema.openAttrs openAttrs in schemaDOM.Items)
                {
                    string loadedFileName = "";
                    string schemaLocation = "";

                    if (openAttrs is XMLSchema.include)
                    {
                        XMLSchema.include include = openAttrs as XMLSchema.include;
                        if (include.schemaLocation != null)
                            schemaLocation = include.schemaLocation;
                    }
                    else if (openAttrs is XMLSchema.import)
                    {
                        XMLSchema.import import = openAttrs as XMLSchema.import;
                        if (import.schemaLocation != null)
                            schemaLocation = import.schemaLocation;
                    }

                    if (!string.IsNullOrEmpty(schemaLocation))
                    {
                        loadedFileName = basePath + Path.DirectorySeparatorChar + schemaLocation.Replace('/', Path.DirectorySeparatorChar);

                        string url = schemaLocation.Trim();
                        if (url.IndexOf("http://") == 0 || url.IndexOf("https://") == 0)
                        {
                            string lf, bu;
                            if (LoadSchemaFromUrl(basePath, url, out lf, out bu))
                            {
                                loadedFileName = lf;
                                baseUrl = bu; // The baseUrl change for this file
                            }
                        }
                        else if (!File.Exists(loadedFileName))
                        {
                            // The relative file does not exist, so try to download it from the web with the baseUrl
                            url = baseUrl + "/" + schemaLocation;

                            string lf, bu;
                            if (LoadSchemaFromUrl(basePath, url, out lf, out bu))
                            {
                                loadedFileName = lf;
                                baseUrl = bu; // The baseUrl change for this file
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(loadedFileName))
                        ImportSchema(loadedFileName, baseUrl);
                }
            }

            string nameSpace = schemaDOM.targetNamespace;

            if (schemaDOM.Items1 != null)
            {
                foreach (XMLSchema.openAttrs openAttrs in schemaDOM.Items1)
                {
                    if (openAttrs is XMLSchema.element)
                    {
                        XMLSchema.element element = openAttrs as XMLSchema.element;
                        XSDObject xsdObject = new XSDObject(fileName, element.name, nameSpace, "element", element);
                        this.hashtableElementsByName[xsdObject.FullName] = xsdObject;

                        if (this.firstElement == null)
                            this.firstElement = xsdObject;

                        elements.Add(xsdObject);
                    }
                    else if (openAttrs is XMLSchema.group)
                    {
                        XMLSchema.group group = openAttrs as XMLSchema.group;
                        XSDObject xsdObject = new XSDObject(fileName, group.name, nameSpace, "group", group);
                        this.hashtableElementsByName[xsdObject.FullName] = xsdObject;

                        elements.Add(xsdObject);
                    }
                    else if (openAttrs is XMLSchema.simpleType)
                    {
                        XMLSchema.simpleType simpleType = openAttrs as XMLSchema.simpleType;
                        XSDObject xsdObject = new XSDObject(fileName, simpleType.name, nameSpace, "simpleType", simpleType);
                        this.hashtableElementsByName[xsdObject.FullName] = xsdObject;

                        elements.Add(xsdObject);
                    }
                    else if (openAttrs is XMLSchema.complexType)
                    {
                        XMLSchema.complexType complexType = openAttrs as XMLSchema.complexType;
                        XSDObject xsdObject = new XSDObject(fileName, complexType.name, nameSpace, "complexType", complexType);
                        this.hashtableElementsByName[xsdObject.FullName] = xsdObject;

                        elements.Add(xsdObject);
                    }
                    else if (openAttrs is XMLSchema.attribute)
                    {
                        XMLSchema.attribute attribute = openAttrs as XMLSchema.attribute;
                        XSDAttribute xsdAttribute = new XSDAttribute(fileName, attribute.name, nameSpace, "attribute", attribute.@ref != null, attribute.@default, attribute.use.ToString(), attribute);
                        this.hashtableAttributesByName[xsdAttribute.FullName] = xsdAttribute;
                    }
                    else if (openAttrs is XMLSchema.attributeGroup)
                    {
                        XMLSchema.attributeGroup attributeGroup = openAttrs as XMLSchema.attributeGroup;
                        XSDAttributeGroup xsdAttributeGroup = new XSDAttributeGroup(fileName, attributeGroup.name, nameSpace, "attributeGroup", attributeGroup is XMLSchema.attributeGroupRef, attributeGroup);
                        this.hashtableAttributesByName[xsdAttributeGroup.FullName] = xsdAttributeGroup;
                    }
                }
            }
        }
示例#6
0
        private XSDAttribute ParseAttribute(string nameSpace, List<XSDAttribute> listAttributes, XMLSchema.attribute attribute, bool isRestriction)
        {
            bool isReference = false;
            string filename = "";
            string name = attribute.name;
            string type = "";
            if (attribute.@ref != null)
            {
                object o = null;
                this.schema.AttributesByName.TryGetValue(QualifiedNameToFullName("attribute", attribute.@ref), out o);
                if (o is XSDAttribute)
                {
                    XSDAttribute xsdAttributeInstance = o as XSDAttribute;
                    XSDAttribute refXSDAttribute = ParseAttribute(nameSpace, listAttributes, xsdAttributeInstance.Tag, isRestriction);
                    if(refXSDAttribute != null)
                    {
                        // Override the "use" field with
                        refXSDAttribute.Use = attribute.use.ToString();
                    }
                    return null;
                }
                else // Reference not found!
                {
                    type = QualifiedNameToAttributeTypeName(attribute.@ref);
                    name = [email protected];
                    nameSpace = [email protected];
                    isReference = true;
                }
            }
            else if (attribute.type != null)
            {
                type = QualifiedNameToAttributeTypeName(attribute.type);
                nameSpace = attribute.type.Namespace;
            }
            else if (attribute.simpleType != null)
            {
                XMLSchema.simpleType simpleType = attribute.simpleType as XMLSchema.simpleType;
                if (simpleType.Item is XMLSchema.restriction)
                {
                    XMLSchema.restriction restriction = simpleType.Item as XMLSchema.restriction;
                    type = QualifiedNameToAttributeTypeName(restriction.@base);
                    nameSpace = [email protected];
                }
                else if (simpleType.Item is XMLSchema.list)
                {
                    XMLSchema.list list = simpleType.Item as XMLSchema.list;
                    type = QualifiedNameToAttributeTypeName(list.itemType);
                    nameSpace = list.itemType.Namespace;
                }
                else
                {
                }
            }
            else
            {

            }
            if (string.IsNullOrEmpty(attribute.name) && string.IsNullOrEmpty(name))
            {
            }
            if (isRestriction)
            {
                if (attribute.use == XMLSchema.attributeUse.prohibited)
                {
                    foreach (XSDAttribute xsdAttribute in listAttributes)
                    {
                        if (xsdAttribute.Name == name)
                        {
                            //listAttributes.Remove(xsdAttribute);
                            xsdAttribute.Use = attribute.use.ToString();
                            break;
                        }
                    }
                }
            }
            else
            {
                XSDAttribute xsdAttribute = new XSDAttribute(filename, name, nameSpace, type, isReference, attribute.@default, attribute.use.ToString(), attribute);
                listAttributes.Insert(0, xsdAttribute);
                return xsdAttribute;

            }
            return null;
        }
示例#7
0
        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--
            }
        }
示例#8
0
 private void ParseComplexTypeAttributes(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(nameSpace, listAttributes, attribute, false);
                     }
                     break;
                 case XMLSchema.ItemsChoiceType4.attributeGroup:
                     {
                         XMLSchema.attributeGroup attributeGroup = complexType.Items[i] as XMLSchema.attributeGroup;
                         ParseAttributeGroup(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 (this.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([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(nameSpace, listAttributes, annotated as XMLSchema.attribute, false);
                                 }
                                 else if (annotated is XMLSchema.attributeGroup)
                                 {
                                     ParseAttributeGroup(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 (this.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([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(nameSpace, listAttributes, annotated as XMLSchema.attribute, true);
                                 }
                                 else if (annotated is XMLSchema.attributeGroup)
                                 {
                                     ParseAttributeGroup(nameSpace, listAttributes, annotated as XMLSchema.attributeGroup, true);
                                 }
                             }
                         }
                     }
                     break;
             }
         }
     }
     else
     {
     }
 }