示例#1
0
        private void LoadInGraph(String path)
        {
            RdfXmlParser ttlparser = new RdfXmlParser();

            try
            {
                ttlparser.Load(situation, path);
            }
            catch (RdfParseException parseEx)
            {
                //This indicates a parser error e.g unexpected character, premature end of input, invalid syntax etc.
                logger.LogFunction("Parser Error");
                logger.LogFunction(parseEx.Message);
            }
            catch (RdfException rdfEx)
            {
                //This represents a RDF error e.g. illegal triple for the given syntax, undefined namespace
                logger.LogFunction("RDF Error");
                logger.LogFunction(rdfEx.Message);
            }
            catch (Exception ex)
            {
                logger.LogFunction("Unknown Error");
                logger.LogFunction(ex.Message);
            }
        }
示例#2
0
        public String SayHello()
        {
            logger.LogFunction("SayHello");
            var   result = "";
            Graph g      = new Graph();

            IUriNode     dotNetRDF    = g.CreateUriNode(UriFactory.Create("http://www.dotnetrdf.org"));
            IUriNode     says         = g.CreateUriNode(UriFactory.Create("http://example.org/says"));
            ILiteralNode helloWorld   = g.CreateLiteralNode("Hello World");
            ILiteralNode bonjourMonde = g.CreateLiteralNode("Bonjour tout le Monde", "fr");

            g.Assert(new Triple(dotNetRDF, says, helloWorld));
            g.Assert(new Triple(dotNetRDF, says, bonjourMonde));

            foreach (Triple t in g.Triples)
            {
                result += t.ToString() + "\n";
            }

            return(result);
        }