Ejemplo n.º 1
0
        private void ParsingStoreHandlerTriXExplicitActual()
        {
            this.EnsureTestData("test.xml");

            TripleStore store = new TripleStore();

            TriXParser parser = new TriXParser();

            parser.Load(new StoreHandler(store), "test.xml");

            Assert.IsTrue(store.HasGraph(new Uri("http://www.dotnetrdf.org/configuration#")), "Configuration Vocab Graph should have been parsed from Dataset");
            Graph configOrig = new Graph();

            configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            IGraph config = store[new Uri("http://www.dotnetrdf.org/configuration#")];

            Assert.AreEqual(configOrig, config, "Configuration Vocab Graphs should have been equal");

            Assert.IsTrue(store.HasGraph(new Uri("http://www.dotnetrdf.org/leviathan#")), "Leviathan Function Library Graph should have been parsed from Dataset");
            Graph lvnOrig = new Graph();

            lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl");
            IGraph lvn = store[new Uri("http://www.dotnetrdf.org/leviathan#")];

            Assert.AreEqual(lvnOrig, lvn, "Leviathan Function Library Graphs should have been equal");
        }
Ejemplo n.º 2
0
        public void ParsingStoreHandlerTriXExplicit()
        {
            this.EnsureTestData("test.xml");

            TripleStore store = new TripleStore();

            TriXParser parser = new TriXParser();

            parser.Load(new StoreHandler(store), "test.xml");

            Assert.True(store.HasGraph(new Uri("http://graphs/1")), "Configuration Vocab Graph should have been parsed from Dataset");
            Graph configOrig = new Graph();

            configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            IGraph config = store[new Uri("http://graphs/1")];

            Assert.Equal(configOrig, config);

            Assert.True(store.HasGraph(new Uri("http://graphs/2")), "Leviathan Function Library Graph should have been parsed from Dataset");
            Graph lvnOrig = new Graph();

            lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl");
            IGraph lvn = store[new Uri("http://graphs/2")];

            Assert.Equal(lvnOrig, lvn);
        }
Ejemplo n.º 3
0
        public static Object LoadFromFile(java.io.File f, string baseUri, org.openrdf.rio.RDFFormat rdff)
        {
            Object obj;

            if (rdff == dotSesameFormats.RDFFormat.N3)
            {
                obj = new Graph();
                if (baseUri != null)
                {
                    ((IGraph)obj).BaseUri = new Uri(baseUri);
                }
                FileLoader.Load((IGraph)obj, f.getPath(), new Notation3Parser());
            }
            else if (rdff == dotSesameFormats.RDFFormat.NTRIPLES)
            {
                obj = new Graph();
                if (baseUri != null)
                {
                    ((IGraph)obj).BaseUri = new Uri(baseUri);
                }
                FileLoader.Load((IGraph)obj, f.getPath(), new NTriplesParser());
            }
            else if (rdff == dotSesameFormats.RDFFormat.RDFXML)
            {
                obj = new Graph();
                if (baseUri != null)
                {
                    ((IGraph)obj).BaseUri = new Uri(baseUri);
                }
                FileLoader.Load((IGraph)obj, f.getPath(), new RdfXmlParser());
            }
            else if (rdff == dotSesameFormats.RDFFormat.TRIG)
            {
                obj = new TripleStore();
                TriGParser trig = new TriGParser();
                trig.Load((ITripleStore)obj, new StreamParams(f.getPath()));
            }
            else if (rdff == dotSesameFormats.RDFFormat.TRIX)
            {
                obj = new TripleStore();
                TriXParser trix = new TriXParser();
                trix.Load((ITripleStore)obj, new StreamParams(f.getPath()));
            }
            else if (rdff == dotSesameFormats.RDFFormat.TURTLE)
            {
                obj = new Graph();
                if (baseUri != null)
                {
                    ((IGraph)obj).BaseUri = new Uri(baseUri);
                }
                FileLoader.Load((IGraph)obj, f.getPath(), new TurtleParser());
            }
            else
            {
                throw new RdfParserSelectionException("The given Input Format is not supported by dotNetRDF");
            }

            return(obj);
        }
        protected void ParsingStoreHandlerBlankNodesTriXActual()
        {
            EnsureTestData("test-bnodes.xml");

            TriXParser  parser = new TriXParser();
            TripleStore store  = new TripleStore();

            parser.Load(store, "test-bnodes.xml");

            EnsureTestResults(store);
        }
Ejemplo n.º 5
0
        private void ParsingStoreHandlerTriXCountingActual()
        {
            this.EnsureTestData("test.xml");

            TriXParser        parser  = new TriXParser();
            StoreCountHandler counter = new StoreCountHandler();

            parser.Load(counter, "test.xml");

            Graph configOrig = new Graph();

            configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            Graph lvnOrig = new Graph();

            lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl");

            Assert.AreEqual(2, counter.GraphCount, "Expected 2 Graphs to be counted");
            Assert.AreEqual(configOrig.Triples.Count + lvnOrig.Triples.Count, counter.TripleCount, "Expected Triple Count to be sum of Triple Counts in two input Graphs");
        }
Ejemplo n.º 6
0
        public void ParsingStoreHandlerTriXCounting()
        {
            this.EnsureTestData("test.xml");

            TriXParser        parser  = new TriXParser();
            StoreCountHandler counter = new StoreCountHandler();

            parser.Load(counter, "test.xml");

            Graph configOrig = new Graph();

            configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            Graph lvnOrig = new Graph();

            lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl");

            Assert.Equal(2, counter.GraphCount);
            Assert.Equal(configOrig.Triples.Count + lvnOrig.Triples.Count, counter.TripleCount);
        }