Пример #1
0
 public void Fill(Database database, string connectionString)
 {
     if (database.Options.Ignore.FilterXMLSchema)
     {
         using (SqlConnection conn = new SqlConnection(connectionString))
         {
             using (SqlCommand command = new SqlCommand(GetSQLXMLSchema(), conn))
             {
                 conn.Open();
                 command.CommandTimeout = 0;
                 using (SqlDataReader reader = command.ExecuteReader())
                 {
                     while (reader.Read())
                     {
                         XMLSchema item = new XMLSchema(database);
                         item.Id    = (int)reader["ID"];
                         item.Name  = reader["name"].ToString();
                         item.Owner = reader["owner"].ToString();
                         item.Text  = reader["Text"].ToString();
                         database.XmlSchemas.Add(item);
                         root.RaiseOnReading(new ProgressEventArgs("Reading XML Schema " + item.Name + "...", Constants.READING_XMLSCHEMAS));
                     }
                 }
             }
         }
         if (database.Options.Ignore.FilterTable)
         {
             FillColumnsDependencies(database.XmlSchemas, connectionString);
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Occurs whenever an add-in loads.
 /// </summary>
 /// <param name="custom">
 /// An empty array that you can use to pass host-specific data for use when the
 /// add-in loads.
 /// </param>
 public void OnStartupComplete(ref Array custom)
 {
     TraceLogger.Log(TraceCategory.Info(), "Startup Arguments '{0}'", custom);
     try {
         XMLSchema s = _onProxy.OneNoteSchema; // cache the schema
     } catch (Exception ex) {
         TraceLogger.Log(TraceCategory.Error(), "{0} initialization failed: {1}", Properties.Resources.TaggingKit_About_Appname, ex);
         TraceLogger.Flush();
         throw;
     }
     TraceLogger.Log(TraceCategory.Info(), "{0} initialization complete!", Properties.Resources.TaggingKit_About_Appname);
     TraceLogger.Flush();
 }
Пример #3
0
        public void Fill(Database database, string connectionString)
        {
            //TODO XML_SCHEMA_NAMESPACE function not supported in Azure, is there a workaround?
            //not supported in azure yet
            if (database.Info.Version == DatabaseInfo.VersionTypeEnum.SQLServerAzure10)
            {
                return;
            }


            if (database.Options.Ignore.FilterXMLSchema)
            {
                root.RaiseOnReading(new ProgressEventArgs("Reading XML Schema...", Constants.READING_XMLSCHEMAS));
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    using (SqlCommand command = new SqlCommand(GetSQLXMLSchema(), conn))
                    {
                        conn.Open();
                        command.CommandTimeout = 0;
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                root.RaiseOnReadingOne(reader["name"]);
                                XMLSchema item = new XMLSchema(database);
                                item.Id    = (int)reader["ID"];
                                item.Name  = reader["name"].ToString();
                                item.Owner = reader["owner"].ToString();
                                item.Text  = reader["Text"].ToString();
                                database.XmlSchemas.Add(item);
                            }
                        }
                    }
                }
                if (database.Options.Ignore.FilterTable)
                {
                    FillColumnsDependencies(database.XmlSchemas, connectionString);
                }
            }
        }
Пример #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
 public DiagramItem AddCompositors(DiagramItem parentDiagramElement, 
     XMLSchema.group childElement, string nameSpace)
 {
     return AddCompositors(parentDiagramElement,
         childElement, DiagramItemGroupType.Group, nameSpace);
 }
Пример #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);
                            }
                        }
                        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
        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);
        }
Пример #8
0
        public DiagramItem AddElement(DiagramItem parentDiagramElement, XMLSchema.element childElement, string nameSpace)
        {
            if (childElement != null)
            {
                DiagramItem childDiagramElement = new DiagramItem();

                XMLSchema.element referenceElement = null;
                if (childElement.@ref != null)
                {
                    if ([email protected])
                    {
                        childDiagramElement.IsReference = true;

                        XSDObject objectReferred = null;
                        if(_elementsByName.TryGetValue([email protected] + ":element:" + [email protected], out objectReferred) && objectReferred != null)
                        {
                            XMLSchema.element elementReferred = objectReferred.Tag as XMLSchema.element;
                            if (elementReferred != null)
                            {
                                referenceElement = childElement;
                                childElement = elementReferred;
                            }
                        }
                        else
                            childElement.name = [email protected];
                    }
                }

                childDiagramElement.Diagram = this;
                childDiagramElement.TabSchema = childElement;
                childDiagramElement.Name = childElement.name != null ? childElement.name : "";
                childDiagramElement.NameSpace = nameSpace;
                childDiagramElement.ItemType = DiagramItemType.element;
                int occurrence;
                if (int.TryParse(referenceElement != null ? referenceElement.minOccurs : childElement.minOccurs, out occurrence))
                    childDiagramElement.MinOccurrence = occurrence;
                else
                    childDiagramElement.MinOccurrence = -1;
                //try { childDiagramElement.MinOccurrence = int.Parse(referenceElement != null ? referenceElement.minOccurs : childElement.minOccurs); }
                //catch { childDiagramElement.MinOccurrence = -1; }
                if (int.TryParse(referenceElement != null ? referenceElement.maxOccurs : childElement.maxOccurs, out occurrence))
                    childDiagramElement.MaxOccurrence = occurrence;
                else
                    childDiagramElement.MaxOccurrence = -1;
                //try { childDiagramElement.MaxOccurrence = int.Parse(referenceElement != null ? referenceElement.maxOccurs : childElement.maxOccurs); }
                //catch { childDiagramElement.MaxOccurrence = -1; }

                bool hasChildren;
                bool isSimpleType;
                GetChildrenInfo(childElement, out hasChildren, out isSimpleType);
                childDiagramElement.HasChildElements = hasChildren;
                childDiagramElement.IsSimpleContent = isSimpleType;

                if (parentDiagramElement == null)
                {
                    _rootElements.Add(childDiagramElement);
                }
                else
                {
                    childDiagramElement.Parent = parentDiagramElement;
                    parentDiagramElement.ChildElements.Add(childDiagramElement);
                }

                if (childElement.@abstract)
                {
                    string abstractElementFullName = childDiagramElement.FullName;
                    foreach(XSDObject xsdObject in _elementsByName.Values)
                    {
                        if (xsdObject != null && xsdObject.Tag is XMLSchema.element)
                        {
                            XMLSchema.element element = xsdObject.Tag as XMLSchema.element;
                            if (element.substitutionGroup != null)
                            {
                                string elementFullName = element.substitutionGroup.Namespace + ":element:" + element.substitutionGroup.Name;
                                if (elementFullName == abstractElementFullName)
                                {
                                    DiagramItem diagramBase = AddElement(parentDiagramElement, element, xsdObject.NameSpace);
                                    if (diagramBase != null)
                                        diagramBase.InheritFrom = childDiagramElement;
                                }
                            }
                        }
                    }
                }

                return childDiagramElement;
            }

            return null;
        }
Пример #9
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;
     }
 }
Пример #10
0
 public XSDAttribute(string filename, string name, string nameSpace, string type, bool isReference, string defaultValue, string use, XMLSchema.attribute attribute)
 {
     this.filename = filename;
     this.name = name;
     this.nameSpace = (nameSpace == null ? "" : nameSpace);
     this.type = type;
     this.isReference = isReference;
     this.defaultValue = defaultValue;
     this.use = use;
     this.tag = attribute;
 }
Пример #11
0
 public DiagramItem AddElement(XMLSchema.element childElement, string nameSpace)
 {
     return AddElement(null, childElement, nameSpace);
 }
Пример #12
0
        public DiagramItem AddComplexType(DiagramItem parentDiagramElement, 
            XMLSchema.complexType childElement, bool isReference,
            string nameSpace)
        {
            if (childElement != null)
            {
                DiagramItem childDiagramElement = new DiagramItem();
                childDiagramElement.Diagram = this;
                childDiagramElement.TabSchema = childElement;
                childDiagramElement.Name = childElement.name != null ? childElement.name : "";
                childDiagramElement.NameSpace = nameSpace;
                childDiagramElement.ItemType = DiagramItemType.type;
                childDiagramElement.MinOccurrence = 1;
                childDiagramElement.MaxOccurrence = 1;
                childDiagramElement.IsReference = isReference;
                childDiagramElement.IsSimpleContent = false;
                childDiagramElement.HasChildElements = false;

                if (childElement.Items != null)
                {
                    for (int i = 0; i < childElement.Items.Length; i++)
                    {
                        if (childElement.Items[i] is XMLSchema.group ||
                            childElement.Items[i] is XMLSchema.complexType ||
                            childElement.Items[i] is XMLSchema.complexContent)
                        {
                            childDiagramElement.HasChildElements = true;
                            break;
                        }
                    }
                }

                if (parentDiagramElement == null)
                    _rootElements.Add(childDiagramElement);
                else
                {
                    childDiagramElement.Parent = parentDiagramElement;
                    parentDiagramElement.ChildElements.Add(childDiagramElement);
                }

                return childDiagramElement;
            }
            return null;
        }
Пример #13
0
 public XSDAttributeGroup(string filename, string name, string nameSpace, string type, bool isReference, XMLSchema.attributeGroup attributeGroup)
 {
     this.filename = filename;
     this.name = name;
     this.nameSpace = (nameSpace == null ? "" : nameSpace);
     this.type = type;
     this.isReference = isReference;
     this.tag = attributeGroup;
 }
Пример #14
0
 public DiagramItem AddComplexType(DiagramItem parentDiagramElement, 
     XMLSchema.complexType childElement, string nameSpace)
 {
     return AddComplexType(parentDiagramElement, childElement,
         false, nameSpace);
 }
Пример #15
0
 public DiagramItem AddComplexType(XMLSchema.complexType childElement, 
     string nameSpace)
 {
     return AddComplexType(null, childElement, false, nameSpace);
 }
Пример #16
0
        public DiagramItem AddAny(DiagramItem parentDiagramElement, 
            XMLSchema.any childElement, string nameSpace)
        {
            bool isDisabled = false;
            if (childElement == null)
            {
                isDisabled = true;
                if (_fakeAny == null)
                {
                    _fakeAny = new XMLSchema.any();
                    _fakeAny.minOccurs = "0";
                    _fakeAny.maxOccurs = "unbounded";
                }
                childElement = _fakeAny;
            }
            if (childElement != null)
            {
                DiagramItem childDiagramElement = new DiagramItem();
                childDiagramElement.IsDisabled = isDisabled;
                childDiagramElement.Diagram = this;
                childDiagramElement.TabSchema = childElement;
                childDiagramElement.Name = "any  " + childElement.@namespace;
                childDiagramElement.NameSpace = nameSpace;
                childDiagramElement.ItemType = DiagramItemType.group;  //DiagramBase.TypeEnum.element;
                int occurrence;
                if (int.TryParse(childElement.minOccurs, out occurrence))
                    childDiagramElement.MinOccurrence = occurrence;
                else
                    childDiagramElement.MinOccurrence = -1;
                //try { childDiagramElement.MinOccurrence = int.Parse(childElement.minOccurs); }
                //catch { childDiagramElement.MinOccurrence = -1; }
                if (int.TryParse(childElement.maxOccurs, out occurrence))
                    childDiagramElement.MaxOccurrence = occurrence;
                else
                    childDiagramElement.MaxOccurrence = -1;
                //try { childDiagramElement.MaxOccurrence = int.Parse(childElement.maxOccurs); }
                //catch { childDiagramElement.MaxOccurrence = -1; }

                childDiagramElement.IsReference = false;
                childDiagramElement.IsSimpleContent = false;
                childDiagramElement.HasChildElements = false; // true;

                if (parentDiagramElement == null)
                {
                    _rootElements.Add(childDiagramElement);
                }
                else
                {
                    childDiagramElement.Parent = parentDiagramElement;
                    parentDiagramElement.ChildElements.Add(childDiagramElement);
                }

                return childDiagramElement;
            }

            return null;
        }
Пример #17
0
        public DiagramItem Add(XMLSchema.openAttrs childElement, string nameSpace)
        {
            if (childElement is XMLSchema.element)
                return AddElement(childElement as XMLSchema.element, nameSpace);
            else if (childElement is XMLSchema.group)
                return AddCompositors(childElement as XMLSchema.group, nameSpace);
            else if (childElement is XMLSchema.complexType)
                return AddComplexType(childElement as XMLSchema.complexType, nameSpace);

            return null;
        }
Пример #18
0
 public XSDObject(string filename, string name, string nameSpace, string type, XMLSchema.openAttrs tag)
 {
     this.filename = filename;
     this.name = name;
     this.nameSpace = (nameSpace == null ? "" : nameSpace);
     this.type = type;
     if (this.type == "simpleType" || this.type == "complexType")
         this.fullNameType = "type";
     else
         this.fullNameType = this.type;
     this.tag = tag;
 }
Пример #19
0
        public DiagramItem AddCompositors(DiagramItem parentDiagramElement, 
            XMLSchema.group childGroup, DiagramItemGroupType type,
            string nameSpace)
        {
            if (childGroup != null)
            {
                DiagramItem childDiagramGroup = new DiagramItem();
                childDiagramGroup.ItemType = DiagramItemType.group;
                if (childGroup.@ref != null)
                {
                    childDiagramGroup.IsReference = true;
                    childDiagramGroup.Name = [email protected] != null ? [email protected] : "";
                    childDiagramGroup.NameSpace = [email protected] != null ? [email protected] : "";
                    XSDObject grpObject = null;
                    if (_elementsByName.TryGetValue(childDiagramGroup.FullName, out grpObject) && grpObject != null)
                    {
                        XMLSchema.group group = grpObject.Tag as XMLSchema.group;
                        if (group != null)
                            childGroup = group;
                    }
                }
                else if (type == DiagramItemGroupType.Group)
                {
                    childDiagramGroup.Name = childGroup.name != null ? childGroup.name : "";
                    childDiagramGroup.NameSpace = nameSpace;
                }
                else
                {
                    childDiagramGroup.NameSpace = nameSpace;
                }

                childDiagramGroup.Diagram = this;
                childDiagramGroup.TabSchema = childGroup;
                int occurrence;
                if (int.TryParse(childGroup.minOccurs, out occurrence))
                    childDiagramGroup.MinOccurrence = occurrence;
                else
                    childDiagramGroup.MinOccurrence = -1;
                //try { childDiagramGroup.MinOccurrence = int.Parse(childGroup.minOccurs); }
                //catch { childDiagramGroup.MinOccurrence = -1; }
                if (int.TryParse(childGroup.maxOccurs, out occurrence))
                    childDiagramGroup.MaxOccurrence = occurrence;
                else
                    childDiagramGroup.MaxOccurrence = -1;
                //try { childDiagramGroup.MaxOccurrence = int.Parse(childGroup.maxOccurs); }
                //catch { childDiagramGroup.MaxOccurrence = -1; }
                childDiagramGroup.HasChildElements = true;
                childDiagramGroup.GroupType = type;

                if (parentDiagramElement == null)
                    _rootElements.Add(childDiagramGroup);
                else
                {
                    childDiagramGroup.Parent = parentDiagramElement;
                    parentDiagramElement.ChildElements.Add(childDiagramGroup);
                }

                return childDiagramGroup;
            }
            return null;
        }
Пример #20
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;
                    }
                }
            }
        }