예제 #1
0
        public void LoadSchema(string fileName)
        {
            this.firstElement = null;
            this.elements.Clear();
            this.hashtableElementsByName.Clear();
            this.hashtableElementsByName[""] = null;
            this.hashtableAttributesByName.Clear();
            this.hashtableAttributesByName[""] = null;
            this.loadError.Clear();
            this.listOfXsdFilename.Clear();

            string url = fileName.Trim(), baseUrl = "";

            if (url.IndexOf("http://") == 0 || url.IndexOf("https://") == 0)
            {
                string basePath = Path.GetTempPath(), lf, bu;
                if (LoadSchemaFromUrl(basePath, url, out lf, out bu))
                {
                    fileName = lf;
                    baseUrl  = bu;
                }
            }

            ImportSchema(fileName, baseUrl);
        }
예제 #2
0
 public void Cleanup()
 {
     this.firstElement = null;
     this.elements.Clear();
     this.hashtableElementsByName.Clear();
     this.hashtableElementsByName[""] = null;
     this.hashtableAttributesByName.Clear();
     this.hashtableAttributesByName[""] = null;
     this.loadError.Clear();
     this.listOfXsdFilename.Clear();
 }
예제 #3
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;
                    }
                }
            }
        }
예제 #4
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;
                    }
                }
            }
        }
예제 #5
0
        public void LoadSchema(string fileName)
        {
            this.firstElement = null;
            this.elements.Clear();
            this.hashtableElementsByName.Clear();
            this.hashtableElementsByName[""] = null;
            this.hashtableAttributesByName.Clear();
            this.hashtableAttributesByName[""] = null;
            this.loadError.Clear();
            this.listOfXsdFilename.Clear();

            string url = fileName.Trim(), baseUrl = "";
            if (url.IndexOf("http://") == 0 || url.IndexOf("https://") == 0)
            {
                string basePath = Path.GetTempPath(), lf, bu;
                if (LoadSchemaFromUrl(basePath, url, out lf, out bu))
                {
                    fileName = lf;
                    baseUrl = bu;
                }
            }

            ImportSchema(fileName, baseUrl);
        }
예제 #6
0
파일: MainForm.cs 프로젝트: dgis/xsddiagram
 private void SelectSchemaElement(XSDObject xsdObject)
 {
     SelectSchemaElement(xsdObject.Tag, xsdObject.NameSpace);
 }
예제 #7
0
파일: Schema.cs 프로젝트: dgis/xsddiagram
 public void Cleanup()
 {
     this.firstElement = null;
     this.elements.Clear();
     this.hashtableElementsByName.Clear();
     this.hashtableElementsByName[""] = null;
     this.hashtableAttributesByName.Clear();
     this.hashtableAttributesByName[""] = null;
     this.loadError.Clear();
     this.listOfXsdFilename.Clear();
 }