当前位置: 首页>>代码示例>>C#>>正文


C# MediaType.AppendChild方法代码示例

本文整理汇总了C#中MediaType.AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C# MediaType.AppendChild方法的具体用法?C# MediaType.AppendChild怎么用?C# MediaType.AppendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaType的用法示例。


在下文中一共展示了MediaType.AppendChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createEmptyEarlGraph

        //Creates a XML-Document with namespaces, testsubject, testergroup  
        public void createEmptyEarlGraph(MediaType chosenMediaType)
        {
            this.mediaType = chosenMediaType;
            string baseDir = AppDomain.CurrentDomain.BaseDirectory;
            baseUri = "XMLFile1.xml";
            earl = new XmlDocument();
            XmlDeclaration xdeclaration = earl.CreateXmlDeclaration("1.0", "utf-8", null);
            nsmgr = new XmlNamespaceManager(earl.NameTable);
            nsmgr.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
            nsmgr.AddNamespace("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
            nsmgr.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema#");
            nsmgr.AddNamespace("xml", "http://www.w3.org/XML/1998/namespace");
            nsmgr.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
            nsmgr.AddNamespace("earl", "http://www.w3.org/ns/earl#");
            nsmgr.AddNamespace("foaf", "http://xmlns.com/foaf/spec/");
            nsmgr.AddNamespace("dct", "http://purl.org/dc/terms/");
            nsmgr.AddNamespace("doap", "http://usefulinc.com/ns/doap#");
            XmlDocumentType doctype;
            doctype = earl.CreateDocumentType("rdf:RDF", null, null, @"
    <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
    <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
    <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>
    <!ENTITY xml 'http://www.w3.org/XML/1998/namespace'>
    <!ENTITY dc 'http://purl.org/dc/elements/1.1/'>
    <!ENTITY earl 'http://www.w3.org/ns/earl#'>
    <!ENTITY foaf 'http://xmlns.com/foaf/spec/'>
    <!ENTITY dct 'http://purl.org/dc/terms/'>
    <!ENTITY doap 'http://usefulinc.com/ns/doap#'>");
            earl.AppendChild(doctype);


            root = earl.CreateElement("rdf", "RDF", nsmgr.LookupNamespace("rdf"));

            foreach (String prefix in nsmgr)
            {
                if (!String.IsNullOrWhiteSpace(prefix)
                    && !prefix.Equals("xmlns")
                    )
                {
                    var uri = nsmgr.LookupNamespace(prefix);
                    if (!String.IsNullOrWhiteSpace(uri))
                        root.SetAttribute("xmlns:" + prefix, uri);
                }
            }
            earl.AppendChild(root);

            software2 = earl.CreateElement("earl", "Software", nsmgr.LookupNamespace("earl"));
            software2.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            software2.SetAttribute("ID", "pruefdialog");
            root.AppendChild(software2);

            XmlElement desc = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
            desc.AppendChild(earl.CreateTextNode("Ein Dialog zur Bewertung taktiler Grafiken"));
            desc.SetAttributeNode("lang", nsmgr.LookupNamespace("xml"));
            desc.SetAttribute("lang", "de");
            software2.AppendChild(desc);

            XmlElement title = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
            title.AppendChild(earl.CreateTextNode("Pruefdialog taktile Grafiken"));
            title.SetAttributeNode("lang", nsmgr.LookupNamespace("xml"));
            title.SetAttribute("lang", "de");
            software2.AppendChild(title);

            testPerson = earl.CreateElement("foaf", "Person", nsmgr.LookupNamespace("foaf"));
            testPerson.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            testPerson.SetAttribute("ID", "testperson");

            XmlElement name = earl.CreateElement("foaf", "name", nsmgr.LookupNamespace("foaf"));
            name.AppendChild(earl.CreateTextNode("Max Mustermann"));
            testPerson.AppendChild(name);

            group = earl.CreateElement("foaf", "Group", nsmgr.LookupNamespace("foaf"));
            group.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            group.SetAttribute("ID", "assertorgroup");
            root.AppendChild(group);

            //TODOOOOOOOO!!!!
            XmlElement descgroup = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
            descgroup.AppendChild(earl.CreateTextNode("Max Mustermann und Pruefdialog"));
            group.AppendChild(descgroup);

            XmlElement descAssertorGroup = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
            descAssertorGroup.AppendChild(earl.CreateTextNode("Max Mustermann überprüfte die Grafik manuell mit dem Pruefdialog"));
            group.AppendChild(descAssertorGroup);

            XmlElement mainAssertor = earl.CreateElement("earl", "mainAssertor", nsmgr.LookupNamespace("earl"));
            mainAssertor.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            mainAssertor.SetAttribute("resource", "#"+software2.GetAttribute("ID"));
            group.AppendChild(mainAssertor);

            XmlElement foafMember = earl.CreateElement("foaf", "member", nsmgr.LookupNamespace("foaf"));
            group.AppendChild(foafMember);

            foafMember.AppendChild(testPerson);

            testsubject = earl.CreateElement("earl", "TestSubject", nsmgr.LookupNamespace("earl"));
            testsubject.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            testsubject.SetAttribute("ID", "testsubject");
            root.AppendChild(testsubject);
//.........这里部分代码省略.........
开发者ID:TUD-INF-IAI-MCI,项目名称:Tangram_QS-Dialog,代码行数:101,代码来源:Earl.cs


注:本文中的MediaType.AppendChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。