Beispiel #1
0
        public void GenerateLiftingXSLT()
        {
            SaveFileDialog D = new SaveFileDialog();

            D.Filter          = "XSLT Stylesheet|*.xslt";
            D.CheckPathExists = true;
            D.Title           = "Save Lifting XSLT as...";
            if (D.ShowDialog() != true)
            {
                return;
            }

            foreach (PSMSuperordinateComponent C in (controller.Diagram as PSMDiagram).Roots)
            {
                if (C is PSMClass)
                {
                    string newname = GetTemplateName((C as PSMClass).ElementName);
                    RDFElement.Add(new XElement(nsxsl + "for-each",
                                                new XAttribute("select", Namespaces[nsproject] + ":" + (C as PSMClass).ElementName),
                                                new XElement(nsxsl + "call-template",
                                                             new XAttribute("name", newname))));
                    ProcessClass(C as PSMClass, newname);
                }
            }

            foreach (KeyValuePair <XNamespace, string> P in Namespaces)
            {
                Stylesheet.Add(new XAttribute(XNamespace.Xmlns + P.Value, P.Key.NamespaceName));
            }

            Stylesheet_doc.Save(D.FileName);
        }
Beispiel #2
0
        public void GenerateLoweringXSLT()
        {
            SaveFileDialog D = new SaveFileDialog();

            D.Filter          = "XSLT Stylesheet|*.xslt";
            D.CheckPathExists = true;
            D.Title           = "Save Lowering XSLT as...";
            if (D.ShowDialog() != true)
            {
                return;
            }

            foreach (PSMSuperordinateComponent C in (controller.Diagram as PSMDiagram).Roots)
            {
                if (C is PSMClass)
                {
                    string XPath   = Namespaces[nsrdf] + ":Description[descendant::" + Namespaces[nsrdfs] + ":Class[@" + Namespaces[nsrdf] + ":resource='" + (C as PSMClass).RepresentedClass.OntologyEquivalent + "'] and not(@" + Namespaces[nsrdf] + ":about = //@" + Namespaces[nsrdf] + ":resource)]/@" + Namespaces[nsrdf] + ":about";
                    string newname = GetTemplateName((C as PSMClass).RepresentedClass.OntologyEquivalent);
                    rootTemplate.Add(new XElement(nsxsl + "call-template",
                                                  new XAttribute("name", newname),
                                                  new XElement(nsxsl + "with-param",
                                                               new XAttribute("name", "id"),
                                                               new XAttribute("select", XPath))));
                    ProcessClass(C as PSMClass, newname);
                }
            }

            foreach (KeyValuePair <XNamespace, string> P in Namespaces)
            {
                Stylesheet.Add(new XAttribute(XNamespace.Xmlns + P.Value, P.Key.NamespaceName));
            }

            Stylesheet_doc.Save(D.FileName);
        }
Beispiel #3
0
        public LiftingXSLT(DiagramController C) : base(C)
        {
            RDFElement = new XElement(nsrdf + "RDF");

            Stylesheet.Add(new XElement(nsxsl + "template",
                                        new XAttribute("match", "/"),
                                        RDFElement));
        }
Beispiel #4
0
        void ProcessClass(PSMClass C, string templateName)
        {
            //Presumptions:
            // - every PIM class and PIM association has an ontology-equivalent
            // - PSM associations are mapped to single PIM associations
            // - only PSM Classes, attributes, associations
            // - namespace in id separated by #
            // - each instance of a class has an id attribute
            // - pim-less attribute name/alias is "nice" - can be appended to a namespace URI to form another URI

            #region Generation of RDF class header
            XElement rdfDescription = new XElement(nsrdf + "Description");
            XElement template       = new XElement(nsxsl + "template",
                                                   new XAttribute("name", templateName),
                                                   rdfDescription);
            Stylesheet.Add(template);

            rdfDescription.Add(new XElement(nsxsl + "attribute",
                                            new XAttribute("name", Namespaces[nsrdf] + ":about"),
                                            new XElement(nsxsl + "value-of",
                                                         new XAttribute("select", "concat('" + C.RepresentedClass.OntologyEquivalent + "', @id)"))));

            rdfDescription.Add(new XElement(nsrdfs + "Class",
                                            new XElement(nsxsl + "attribute",
                                                         new XAttribute("name", Namespaces[nsrdf] + ":resource"),
                                                         new XElement(nsxsl + "text", C.RepresentedClass.OntologyEquivalent))));
            #endregion

            #region Generation of attribute transformation

            foreach (PSMAttribute A in C.PSMAttributes)
            {
                rdfDescription.Add(new XElement(
                                       A.RepresentedAttribute == null
                                                ? nsproject + A.AliasOrName
                                                : GetNamespace(A.RepresentedAttribute.OntologyEquivalent) + CutID(A.RepresentedAttribute.OntologyEquivalent),
                                       new XElement(nsxsl + "value-of",
                                                    new XAttribute("select", "@" + A.AliasOrName))));
            }

            #endregion

            #region Generation of content transformation

            foreach (PSMSubordinateComponent S in C.Components)
            {
                if (S is PSMAssociation)
                {
                    PSMAssociation A = S as PSMAssociation;
                    if (A.Child is PSMClass)
                    {
                        PSMClass child      = A.Child as PSMClass;
                        string   newRefName = GetTemplateName(child.ElementName + "-ref");
                        rdfDescription.Add(new XElement(nsxsl + "for-each",
                                                        new XAttribute("select", Namespaces[nsproject] + ":" + child.ElementName),
                                                        new XElement(nsxsl + "call-template",
                                                                     new XAttribute("name", newRefName))));

                        string newname = GetTemplateName(child.ElementName);
                        Stylesheet.Add(new XElement(nsxsl + "template",
                                                    new XAttribute("name", newRefName),
                                                    new XElement(GetNamespace(A.NestingJoins[0].Parent.Steps[0].Association.OntologyEquivalent) + CutID(A.NestingJoins[0].Parent.Steps[0].Association.OntologyEquivalent),
                                                                 new XElement(nsxsl + "attribute",
                                                                              new XAttribute("name", "rdf:resource"),
                                                                              new XElement(nsxsl + "value-of",
                                                                                           new XAttribute("select", "concat('" + child.RepresentedClass.OntologyEquivalent + "', @id)"))))));

                        template.Add(new XElement(nsxsl + "for-each",
                                                  new XAttribute("select", Namespaces[nsproject] + ":" + child.ElementName),
                                                  new XElement(nsxsl + "call-template",
                                                               new XAttribute("name", newname))));

                        ProcessClass(child, newname);
                    }
                }
            }

            #endregion
        }
Beispiel #5
0
        void ProcessClass(PSMClass C, string templateName)
        {
            //Presumptions:
            // - every PIM class and PIM associations have ontology-equivalents
            // - PSM associations are mapped to single PIM associations
            // - only PSM Classes, attributes, associations
            // - namespace in id separated by #
            // - pim-less attribute name/alias is "nice" - can be appended to a namespace URI to form another URI
            // - one root

            string   XPath   = "//" + Namespaces[nsrdf] + ":Description[@" + Namespaces[nsrdf] + ":about=$id]";
            XElement element = new XElement(nsproject + C.ElementName);

            Stylesheet.Add(new XElement(nsxsl + "template",
                                        new XAttribute("name", templateName),
                                        new XElement(nsxsl + "param",
                                                     new XAttribute("name", "id")),
                                        new XElement(nsxsl + "for-each",
                                                     new XAttribute("select", XPath), element)));

            #region Attribute rules generation
            foreach (PSMAttribute A in C.PSMAttributes)
            {
                XNamespace ns;
                string     id;
                if (A.RepresentedAttribute == null)
                {
                    ns = nsproject;
                    id = A.AliasOrName;
                }
                else
                {
                    ns = GetNamespace(A.RepresentedAttribute.OntologyEquivalent);
                    id = CutID(A.RepresentedAttribute.OntologyEquivalent);
                }
                element.Add(new XElement(nsxsl + "attribute",
                                         new XAttribute("name", Namespaces[nsproject] + ":" + A.AliasOrName),
                                         new XElement(nsxsl + "value-of",
                                                      new XAttribute("select", Namespaces[ns] + ":" + id))));
            }
            #endregion

            #region Content rules generation

            foreach (PSMSubordinateComponent S in C.Components)
            {
                if (S is PSMAssociation)
                {
                    PSMAssociation A = S as PSMAssociation;
                    if (A.Child is PSMClass)
                    {
                        PSMClass child = A.Child as PSMClass;

                        string newTemplateName = GetTemplateName(child.RepresentedClass.OntologyEquivalent);

                        element.Add(new XElement(nsxsl + "for-each",
                                                 new XAttribute("select", Namespaces[GetNamespace(A.NestingJoins[0].Parent.Steps[0].Association.OntologyEquivalent)] + ":" + CutID(A.NestingJoins[0].Parent.Steps[0].Association.OntologyEquivalent)),
                                                 new XElement(nsxsl + "call-template",
                                                              new XAttribute("name", newTemplateName),
                                                              new XElement(nsxsl + "with-param",
                                                                           new XAttribute("name", "id"),
                                                                           new XAttribute("select", "@" + Namespaces[nsrdf] + ":resource")))));

                        ProcessClass(child, newTemplateName);
                    }
                }
            }

            #endregion
        }
Beispiel #6
0
 public LoweringXSLT(DiagramController C) : base(C)
 {
     rootTemplate = new XElement(nsxsl + "template",
                                 new XAttribute("match", "/" + Namespaces[nsrdf] + ":RDF"));
     Stylesheet.Add(rootTemplate);
 }