Ejemplo n.º 1
0
        public void readXML()
        {
            XmlDocument xmlFile = new XmlDocument();

            xmlFile.Load(filepath);
            XmlNode   rootNode       = xmlFile.DocumentElement;
            Templates templateClass  = new Templates();
            ModelView modelViewClass = new ModelView();

            templates = DisplayTemplates(rootNode, null, templateClass, false, false, null, null);
            modelView = DisplayModelView(rootNode, templates, modelViewClass, null, null, null);
        }
Ejemplo n.º 2
0
        private static ModelView DisplayModelView(XmlNode node, Templates templates, ModelView modelView, ConceptRoot conceptRoot, Concept concept, Requirement requirement)
        {
            if (node.Name == "ModelView")
            {
                if (node.Attributes != null)
                {
                    XmlAttributeCollection attrs = node.Attributes;
                    foreach (XmlAttribute attr in attrs)
                    {
                        switch (attr.Name)
                        {
                        case "uuid":
                            modelView.uuid = attr.Value;
                            break;

                        case "name":
                            modelView.name = attr.Value;
                            break;

                        case "version":
                            modelView.version = attr.Value;
                            break;

                        case "applicableSchema":
                            modelView.applicableSchema = attr.Value;
                            break;
                        }
                    }
                }
            }

            else if (node.Name == "ExchangeRequirement")
            {
                ExchangeRequirement exchangeRequirement = new ExchangeRequirement();
                if (node.Attributes != null)
                {
                    XmlAttributeCollection attrs = node.Attributes;
                    foreach (XmlAttribute attr in attrs)
                    {
                        switch (attr.Name)
                        {
                        case "uuid":
                            exchangeRequirement.uuid = attr.Value;
                            break;

                        case "name":
                            exchangeRequirement.name = attr.Value;
                            break;

                        case "applicability":
                            exchangeRequirement.version = attr.Value;
                            break;
                        }
                    }
                }
                modelView.addExchangeRequirements(exchangeRequirement.uuid, exchangeRequirement);
            }
            else if (node.Name == "ConceptRoot")
            {
                conceptRoot = new ConceptRoot();
                if (node.Attributes != null)
                {
                    XmlAttributeCollection attrs = node.Attributes;
                    foreach (XmlAttribute attr in attrs)
                    {
                        switch (attr.Name)
                        {
                        case "uuid":
                            conceptRoot.uuid = attr.Value;
                            break;

                        case "name":
                            conceptRoot.name = attr.Value;
                            break;

                        case "applicableRootEntity":
                            conceptRoot.applicableRootEntity = attr.Value;
                            break;
                        }
                    }
                }
                modelView.addRoots(conceptRoot.uuid, conceptRoot);
            }
            else if (node.Name == "Concept")
            {
                concept = new Concept();
                if (node.Attributes != null)
                {
                    XmlAttributeCollection attrs = node.Attributes;
                    foreach (XmlAttribute attr in attrs)
                    {
                        switch (attr.Name)
                        {
                        case "uuid":
                            concept.uuid = attr.Value;
                            break;

                        case "name":
                            concept.name = attr.Value;
                            break;

                        case "Override":
                            concept.Override = attr.Value;
                            break;
                        }
                    }
                }


                // concept.setConceptTemplate(FindTemplate(templates, concept.uuid));
                conceptRoot.addConcept(concept.uuid, concept);
            }
            else if (node.Name == "Template")
            {
                if (node.Attributes != null)
                {
                    XmlAttributeCollection attrs = node.Attributes;
                    foreach (XmlAttribute attr in attrs)
                    {
                        switch (attr.Name)
                        {
                        case "ref":
                            var uuid = attr.Value;
                            foreach (var entry in templates.getConceptTemplates())
                            {
                                ConceptTemplate conceptTemplate = entry.Value;
                                concept.setConceptTemplate(FindTemplate(conceptTemplate, uuid));
                            }
                            break;
                        }
                    }
                }
            }
            XmlNodeList children = node.ChildNodes;

            foreach (XmlNode child in children)
            {
                DisplayModelView(child, templates, modelView, conceptRoot, concept, requirement);
            }
            return(modelView);
        }