コード例 #1
0
        /// <summary>
        /// Determines whether the data provided is valid syntax
        /// </summary>
        /// <param name="data">Data</param>
        /// <returns></returns>
        public virtual ISyntaxValidationResults Validate(string data)
        {
            String message;
            try
            {
                StoreCountHandler handler = new StoreCountHandler();
                this._parser.Load(handler, new TextReaderParams(new StringReader(data)));

                message = "Valid RDF Dataset - " + handler.GraphCount + " Graphs with " + handler.TripleCount + " Triples - Parser: " + this._parser.GetType().Name;
                return new SyntaxValidationResults(true, message, handler);
            }
            catch (RdfParseException parseEx)
            {
                message = "Invalid RDF Dataset - Parsing Error from Parser: " + this._parser.GetType().Name + " - " + parseEx.Message;
                return new SyntaxValidationResults(message, parseEx);
            }
            catch (RdfException rdfEx)
            {
                message = "Invalid RDF Dataset - RDF Error from Parser: " + this._parser.GetType().Name + " - " + rdfEx.Message;
                return new SyntaxValidationResults(message, rdfEx);
            }
            catch (Exception ex)
            {
                message = "Invalid RDF Dataset - Error from Parser: " + this._parser.GetType().Name + " - " + ex.Message;
                return new SyntaxValidationResults(message, ex);
            }
        }
コード例 #2
0
        private void ParsingFileLoaderStoreHandlerCountingActual()
        {
            this.EnsureTestData("test.nq");

            StoreCountHandler counter = new StoreCountHandler();

            FileLoader.LoadDataset(counter, "test.nq");

            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");
        }
コード例 #3
0
        public void ParsingFileLoaderStoreHandlerCounting()
        {
            this.EnsureTestData("test.nq");

            StoreCountHandler counter = new StoreCountHandler();

            FileLoader.LoadDataset(counter, "test.nq");

            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);
        }
コード例 #4
0
        public void ParsingStoreHandlerTriGCounting()
        {
            this.EnsureTestData("test.trig");

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

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

            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");
        }
コード例 #5
0
        private void ParsingStoreHandlerTriXCountingActual()
        {
            this.EnsureTestData("test.xml");

            StreamParams ps = new StreamParams("test.xml", Encoding.ASCII);

            TriXParser parser = new TriXParser();
            StoreCountHandler counter = new StoreCountHandler();
            parser.Load(counter, ps);

            Graph configOrig = new Graph();
            configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            Graph lvnOrig = new Graph();
            lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.Functions.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");
        }
コード例 #6
0
        private void ParsingFileLoaderStoreHandlerCountingActual()
        {
            this.EnsureTestData("test.nq");

            StoreCountHandler counter = new StoreCountHandler();
            FileLoader.LoadDataset(counter, "test.nq");

            Graph configOrig = new Graph();
            configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            Graph lvnOrig = new Graph();
            lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.Functions.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");
        }