public void RunList(String[] args) { if (args.Length < 2) { Console.Error.WriteLine("rdfWebDeploy: Error: 2 Arguments are required in order to use the -list mode"); return; } if (!File.Exists(args[1])) { Console.Error.WriteLine("rdfWebDeploy: Error: Cannot list handlers from " + args[1] + " since the file does not exist"); return; } Graph g = new Graph(); try { FileLoader.Load(g, args[1]); } catch (Exception ex) { Console.Error.WriteLine("rdfWebDeploy: Error: Cannot parse the configuration file"); Console.Error.WriteLine("rdfWebDeploy: Error: " + ex.Message); return; } Object results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + ListHandlers); if (results is SparqlResultSet) { SparqlResultSet rset = (SparqlResultSet)results; Console.WriteLine("rdfWebDeploy: Configuration file contains " + rset.Count + " handler registrations"); foreach (SparqlResult r in rset) { Console.WriteLine(); Console.WriteLine("rdfWebDeploy: Handler URI: " + r["handler"].ToString()); Console.WriteLine("rdfWebDeploy: Handler Type: " + r["type"].ToString()); if (r.HasValue("label")) { Console.WriteLine("rdfWebDeploy: Label: " + r["label"].ToString()); } } } }
public void SparqlLazyLimitSimple2() { const string query = @"PREFIX eg: <http://example.org/vehicles/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?car ?speed WHERE { ?car rdf:type eg:Car . ?car eg:Speed ?speed } LIMIT 20"; var g = new Graph(); FileLoader.Load(g, "InferenceTest.ttl"); var parser = new SparqlQueryParser(); var q = parser.ParseFromString(query); var results = g.ExecuteQuery(q); Assert.IsTrue(results is SparqlResultSet, "Expected a SPARQL results set"); var rset = results as SparqlResultSet; foreach (var r in rset) { Console.WriteLine(r); Assert.AreEqual(2, r.Count, "Expected 2 variable bindings per row."); } }
public static void Main(string[] args) { StreamWriter output = new StreamWriter("RdfATestSuite.txt"); String[] wantTrace = { }; String[] wantOutput = { }; bool outputAll = true; bool traceAll = false; String[] skipTests = { "0002.xhtml", "0003.xhtml", "0004.xhtml", "0005.xhtml", "0016.xhtml", "0022.xhtml", "0024.xhtml", "0028.xhtml", "0043.xhtml", "0044.xhtml", "0045.xhtml", "0095.xhtml", "0096.xhtml", "0097.xhtml", "0098.xhtml", "0122.xhtml", "0123.xhtml", "0124.xhtml", "0125.xhtml", "0126.xhtml" }; String[] skipCheck = { "0011.xhtml", "0092.xhtml", "0094.xhtml", "0100.xhtml", "0101.xhtml", "0102.xhtml", "0103.xhtml", }; String[] falseTests = { "0042.xhtml", "0086.xhtml", "0095.xhtml", "0096.xhtml", "0097.xhtml", "0107.xhtml", "0116.xhtml", "0122.xhtml", "0125.xhtml" }; Console.SetOut(output); try { int testsPassed = 0; int testsFailed = 0; String[] files = Directory.GetFiles("rdfa_tests"); RdfAParser parser = new RdfAParser(RdfASyntax.AutoDetectLegacy); parser.Warning += new RdfReaderWarning(parser_Warning); SparqlQueryParser queryparser = new SparqlQueryParser(); bool passed, passDesired; Graph g = new Graph(); Stopwatch timer = new Stopwatch(); long totalTime = 0; long totalTriples = 0; foreach (String file in files) { timer.Reset(); if (skipTests.Contains(Path.GetFileName(file))) { output.WriteLine("## Skipping Test of File " + Path.GetFileName(file)); output.WriteLine(); continue; } if (Path.GetExtension(file) != ".html" && Path.GetExtension(file) != ".xhtml") { continue; } Debug.WriteLine("Testing File " + Path.GetFileName(file)); output.WriteLine("## Testing File " + Path.GetFileName(file)); output.WriteLine("# Test Started at " + DateTime.Now.ToString(TestSuite.TestSuiteTimeFormat)); passed = false; passDesired = true; try { g = new Graph(); g.BaseUri = new Uri("http://www.w3.org/2006/07/SWD/RDFa/testsuite/xhtml1-testcases/" + Path.GetFileName(file)); if (Path.GetFileNameWithoutExtension(file).StartsWith("bad")) { passDesired = false; output.WriteLine("# Desired Result = Parsing Failed"); } else { output.WriteLine("# Desired Result = Parses OK"); } //if (traceAll || wantTrace.Contains(Path.GetFileName(file))) //{ // parser.TraceTokeniser = true; //} //else //{ // parser.TraceTokeniser = false; //} timer.Start(); parser.Load(g, file); timer.Stop(); Console.WriteLine("Parsing took " + timer.ElapsedMilliseconds + "ms"); passed = true; output.WriteLine("Parsed OK"); if (outputAll || wantOutput.Contains(Path.GetFileName(file))) { NTriplesWriter writer = new NTriplesWriter(); writer.Save(g, "rdfa_tests\\" + Path.GetFileNameWithoutExtension(file) + ".out"); } } catch (IOException ioEx) { reportError(output, "IO Exception", ioEx); } catch (RdfParseException parseEx) { reportError(output, "Parsing Exception", parseEx); } catch (RdfException rdfEx) { reportError(output, "RDF Exception", rdfEx); } catch (Exception ex) { reportError(output, "Other Exception", ex); } finally { timer.Stop(); //Write the Triples to the Output foreach (Triple t in g.Triples) { Console.WriteLine(t.ToString()); } //Now we run the Test SPARQL (if present) if (File.Exists("rdfa_tests/" + Path.GetFileNameWithoutExtension(file) + ".sparql")) { if (skipCheck.Contains(Path.GetFileName(file))) { output.WriteLine("## Skipping Check of File " + Path.GetFileName(file)); output.WriteLine(); } else { try { SparqlQuery q = queryparser.ParseFromFile("rdfa_tests/" + Path.GetFileNameWithoutExtension(file) + ".sparql"); Object results = g.ExecuteQuery(q); if (results is SparqlResultSet) { //The Result is the result of the ASK Query if (falseTests.Contains(Path.GetFileName(file))) { passed = !((SparqlResultSet)results).Result; } else { passed = ((SparqlResultSet)results).Result; } } } catch { passed = false; } } } if (passed && passDesired) { //Passed and we wanted to Pass testsPassed++; output.WriteLine("# Result = Test Passed"); totalTime += timer.ElapsedMilliseconds; totalTriples += g.Triples.Count; } else if (!passed && passDesired) { //Failed when we should have Passed testsFailed++; output.WriteLine("# Result = Test Failed"); } else if (passed && !passDesired) { //Passed when we should have Failed testsFailed++; output.WriteLine("# Result = Test Failed"); } else { //Failed and we wanted to Fail testsPassed++; output.WriteLine("# Result = Test Passed"); } output.WriteLine("# Triples Generated = " + g.Triples.Count()); output.WriteLine("# Test Ended at " + DateTime.Now.ToString(TestSuite.TestSuiteTimeFormat)); } output.WriteLine(); } output.WriteLine(testsPassed + " Tests Passed"); output.WriteLine(testsFailed + " Tests Failed"); output.WriteLine(); output.Write("Total Parsing Time was " + totalTime + " ms"); if (totalTime > 1000) { output.WriteLine(" (" + totalTime / 1000d + " seconds)"); } output.WriteLine("Average Parsing Speed was " + totalTriples / (totalTime / 1000d) + " triples/second"); } catch (Exception ex) { reportError(output, "Other Exception", ex); } Console.SetOut(Console.Out); Console.WriteLine("Done"); Debug.WriteLine("Finished"); output.Close(); }
/// <summary> /// Выполнение Sparql-запроса /// </summary> /// <param name="sparqlCommandText">Текст Sparql-запроса</param> /// <returns>Результат запроса в виде текста</returns> public string ExecuteQuery(string sparqlCommandText) { using (Graph baseGraph = new Graph()) { RdfXmlParser fileParser = new RdfXmlParser(); foreach (string fileName in FilesToQuery) { if (String.IsNullOrWhiteSpace(fileName)) continue; using (Graph g = new Graph()) { try { fileParser.Load(g, fileName); baseGraph.Merge(g); } catch (Exception ex) { throw new Exception(String.Format("Ошибка при обработке файла {0}\r\n{1}",fileName, ex.Message), ex); } } } var resultSet = baseGraph.ExecuteQuery(sparqlCommandText); if (resultSet is SparqlResultSet) { SparqlResultSet outputSet = resultSet as SparqlResultSet; if (outputSet.IsEmpty) QueryResult = "Пустой результат"; else { StringBuilder outputString = new StringBuilder(); foreach (SparqlResult result in outputSet.Results) outputString.AppendLine(result.ToString()); QueryResult = outputString.ToString(); } } else if (resultSet is Graph) { Graph resultGraph = resultSet as Graph; if (resultGraph.IsEmpty) QueryResult = "Пустой граф"; else QueryResult = VDS.RDF.Writing.StringWriter.Write(resultGraph, new RdfXmlWriter()); } else { QueryResult = string.Format("Неизвестный результат: {0}", resultSet.GetType()); } return QueryResult; } }
public void SparqlAnton() { Graph g = new Graph(); FileLoader.Load(g, "anton.rdf"); SparqlQueryParser parser = new SparqlQueryParser(); SparqlQuery query = parser.ParseFromFile("anton.rq"); Object results = g.ExecuteQuery(query); if (results is SparqlResultSet) { SparqlResultSet rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { Console.WriteLine(r); } Assert.AreEqual(1, rset.Count, "Should be exactly 1 result"); } else { Assert.Fail("Query should have returned a Result Set"); } }
public void RunTest(String[] args) { if (args.Length < 2) { Console.Error.WriteLine("rdfWebDeploy: Error: 2 Arguments are required in order to use the -test mode"); return; } if (!File.Exists(args[1])) { Console.Error.WriteLine("rdfWebDeploy: Error: Cannot test " + args[1] + " since the file does not exist"); return; } Graph g = new Graph(); try { FileLoader.Load(g, args[1]); } catch (Exception ex) { Console.Error.WriteLine("rdfWebDeploy: Error: Cannot parse the configuration file"); Console.Error.WriteLine("rdfWebDeploy: Error: " + ex.Message); return; } Console.WriteLine("rdfWebDeploy: Opened the configuration file successfully"); Graph vocab = new Graph(); try { TurtleParser ttlparser = new TurtleParser(); ttlparser.Load(vocab, new StreamReader(Assembly.GetAssembly(typeof(IGraph)).GetManifestResourceStream("VDS.RDF.Configuration.configuration.ttl"))); } catch (Exception ex) { Console.Error.WriteLine("rdfWebDeploy: Error: Cannot parse the configuration vocabulary"); Console.Error.WriteLine("rdfWebDeploy: Error: " + ex.Message); return; } Console.WriteLine("rdfWebDeploy: Loaded the configuration vocabulary successfully"); Console.WriteLine(); Console.WriteLine("rdfWebDeploy: Tests Started..."); Console.WriteLine(); //Now make some tests against it int warnings = 0, errors = 0; IInMemoryQueryableStore store = new TripleStore(); store.Add(vocab); if (g.BaseUri == null) g.BaseUri = new Uri("dotnetrdf:config"); store.Add(g); Object results; SparqlResultSet rset; //Unknown vocabulary term test Console.WriteLine("rdfWebDeploy: Testing for URIs in the vocabulary namespace which are unknown"); results = store.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + UnknownVocabularyTermsTest); if (results is SparqlResultSet) { rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { Console.Error.WriteLine("rdfWebDeploy: Error: The configuration file uses the URI '" + r["term"] + "' for a property/type and this does not appear to be a valid term in the Configuration vocabulary"); errors++; } } Console.WriteLine(); #region General dnr:type Tests //Missing dnr:type test Console.WriteLine("rdfWebDeploy: Testing for missing dnr:type properties"); results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + MissingConfigurationTypeTest); if (results is SparqlResultSet) { rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { Console.Error.WriteLine("rdfWebDeploy: Warning: The Node '" + r["s"].ToString() + "' has an rdf:type but no dnr:type which may be needed by the Configuration Loader"); warnings++; } } Console.WriteLine(); //Invalid dnr:type test Console.WriteLine("rdfWebDeploy: Testing that values given for dnr:type property are literals"); results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + InvalidTypePropertyTest); if (results is SparqlResultSet) { rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { Console.Error.WriteLine("rdfWebDeploy: Error: The node '" + r["s"].ToString() + "' has a dnr:type of '" + r["type"].ToString() + "' which is not given as a string literal"); errors++; } } Console.WriteLine(); //Multiple dnr:type test Console.WriteLine("rdfWebDeploy: Testing that no object has multiple dnr:type values"); results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + MultipleTypeTest); if (results is SparqlResultSet) { rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { Console.Error.WriteLine("rdfWebDeploy: Error: The node '" + r["s"].ToString() + "' has multiple dnr:type values which is not valid"); errors++; } } Console.WriteLine(); //Unknown Library Types test Console.WriteLine("rdfWebDeploy: Testing that values given for dnr:type property in the VDS.RDF namespace are valid"); results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + LibraryTypesTest); if (results is SparqlResultSet) { rset = (SparqlResultSet)results; Assembly dotnetrdf = Assembly.GetAssembly(typeof(IGraph)); foreach (SparqlResult r in rset) { Type t = dotnetrdf.GetType(((ILiteralNode)r["type"]).Value); if (t == null) { Console.Error.WriteLine("rdfWebDeploy: Error: The node '" + r["s"].ToString() + "' has a dnr:type of '" + r["type"].ToString() + "' which does not appear to be a valid type in dotNetRDF"); errors++; } } } Console.WriteLine(); #endregion #region dnr:HttpHandler Tests including specific dnr:type Tests //Bad Handler URI test Console.WriteLine("rdfWebDeploy: Testing for bad URIs given the rdf:type of dnr:HttpHandler"); results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + BadHandlerUriTest); if (results is SparqlResultSet) { rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { Console.Error.WriteLine("rdfWebDeploy: Error: The Handler node '" + r["s"].ToString() + "' is not a URI of the form <dotnetrdf:/path> which is required for correct detection of handler configuration"); errors++; } } Console.WriteLine(); //Missing Handler type test Console.WriteLine("rdfWebDeploy: Testing for missing dnr:type for dnr:HttpHandler objects"); results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + MissingHandlerTypeTest); if (results is SparqlResultSet) { rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { Console.Error.WriteLine("rdfWebDeploy: Error: The Handler node '" + r["s"].ToString() + "' has an rdf:type but no dnr:type which is requiring for automated deployment via this tool"); errors++; } } Console.WriteLine(); //Invalid Handler Type test Console.WriteLine("rdfWebDeploy: Testing that values given for dnr:type for dnr:HttpHandler objects in the VDS.RDF namespace are valid IHttpHandlers"); results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + InvalidHandlerTypeTest); if (results is SparqlResultSet) { rset = (SparqlResultSet)results; Assembly dotnetrdf = Assembly.GetAssembly(typeof(IGraph)); foreach (SparqlResult r in rset) { Type t = dotnetrdf.GetType(((ILiteralNode)r["type"]).Value); if (t != null) { if (!t.GetInterfaces().Any(i => i.Equals(typeof(System.Web.IHttpHandler)))) { Console.Error.WriteLine("rdfWebDeploy: Error: The node '" + r["s"].ToString() + "' has a dnr:type of '" + r["type"].ToString() + "' which does not appear to be a valid IHttpHandler implementation in dotNetRDF"); errors++; } } } } Console.WriteLine(); #endregion #region Property Tests //Range test Console.WriteLine("rdfWebDeploy: Testing for bad ranges for properties"); results = store.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + InvalidRangeTest); if (results is SparqlResultSet) { rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { SparqlParameterizedString hasValidRange = new SparqlParameterizedString(); hasValidRange.QueryText = RdfWebDeployHelper.NamespacePrefixes + ValidRangeTest; hasValidRange.SetParameter("property", r["property"]); hasValidRange.SetParameter("s", r["s"]); Object temp = store.ExecuteQuery(hasValidRange.ToString()); if (temp is SparqlResultSet) { if (!((SparqlResultSet)temp).Result) { Console.Error.WriteLine("rdfWebDeploy: Error: The Node '" + r["s"].ToString() + "' has a value for the property '" + r["property"].ToString() + "' which is '" + r["obj"].ToString() + "' which does not appear to be valid for the range of this property which is '" + r["range"].ToString() + "'"); errors++; } } } } Console.WriteLine(); //Domain test Console.WriteLine("rdfWebDeploy: Testing for bad domains for properties"); results = store.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + InvalidDomainTest); if (results is SparqlResultSet) { rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { SparqlParameterizedString hasValidDomain = new SparqlParameterizedString(); hasValidDomain.QueryText = RdfWebDeployHelper.NamespacePrefixes + ValidDomainTest; hasValidDomain.SetParameter("property", r["property"]); hasValidDomain.SetParameter("s", r["s"]); Object temp = store.ExecuteQuery(hasValidDomain.ToString()); if (temp is SparqlResultSet) { if (!((SparqlResultSet)temp).Result) { Console.Error.WriteLine("rdfWebDeploy: Error: The Node '" + r["s"].ToString() + "' has a value for the property '" + r["property"].ToString() + "' and the type given is '" + r["type"].ToString() + "' which does not match the domain of this property which is '" + r["domain"].ToString() + "'"); errors++; } } } } Console.WriteLine(); #endregion #region Clear Text Password Tests Console.WriteLine("rdfWebDeploy: Testing for clear text passwords used with dnr:password property"); results = store.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + ClearTextPasswordTest); if (results is SparqlResultSet) { foreach (SparqlResult r in (SparqlResultSet)results) { Console.Error.WriteLine("rdfWebDeploy: Warning: The Node '" + r["s"].ToString() + "' has a value for the dnr:password property specified as a Literal in clear text. It is recommended that you specify any passwords as AppSetting URIs e.g. <appsetting:MyPassword> and then create an AppSetting in the <appSettings> section of your Web.config file to store your password. The Web.config file can then have the <appSettings> section encrypted to help protect your password"); warnings++; } } Console.WriteLine(); #endregion //Show Test Results Console.WriteLine("rdfWedDeploy: Tests Completed - " + warnings + " Warning(s) - " + errors + " Error(s)"); }
public static IEnumerable<NamespaceTerm> LoadNamespaceTerms(String namespaceUri) { //Don't load if already loaded if (_loadedNamespaces.Contains(namespaceUri)) return GetNamespaceTerms(namespaceUri); try { Graph g = new Graph(); try { UriLoader.Load(g, new Uri(namespaceUri)); } catch { //Try and load from our local copy if there is one String prefix = GetDefaultPrefix(namespaceUri); if (!prefix.Equals(String.Empty)) { Stream localCopy = Assembly.GetExecutingAssembly().GetManifestResourceStream("rdfEditor.AutoComplete.Vocabularies." + prefix + ".ttl"); if (localCopy != null) { TurtleParser ttlparser = new TurtleParser(); ttlparser.Load(g, new StreamReader(localCopy)); } } } List<NamespaceTerm> terms = new List<NamespaceTerm>(); String termUri; //UriNode rdfType = g.CreateUriNode(new Uri(RdfSpecsHelper.RdfType)); IUriNode rdfsClass = g.CreateUriNode(new Uri(NamespaceMapper.RDFS + "Class")); IUriNode rdfsLabel = g.CreateUriNode(new Uri(NamespaceMapper.RDFS + "label")); IUriNode rdfsComment = g.CreateUriNode(new Uri(NamespaceMapper.RDFS + "comment")); IUriNode rdfProperty = g.CreateUriNode(new Uri(NamespaceMapper.RDF + "Property")); IUriNode rdfsDatatype = g.CreateUriNode(new Uri(NamespaceMapper.RDFS + "Datatype")); SparqlParameterizedString queryString = new SparqlParameterizedString(); queryString.CommandText = "SELECT ?term STR(?label) AS ?RawLabel STR(?comment) AS ?RawComment WHERE { {{?term a @class} UNION {?term a @property} UNION {?term a @datatype}} OPTIONAL {?term @label ?label} OPTIONAL {?term @comment ?comment} }"; queryString.SetParameter("class", rdfsClass); queryString.SetParameter("property", rdfProperty); queryString.SetParameter("datatype", rdfsDatatype); queryString.SetParameter("label", rdfsLabel); queryString.SetParameter("comment", rdfsComment); Object results = g.ExecuteQuery(queryString.ToString()); if (results is SparqlResultSet) { foreach (SparqlResult r in ((SparqlResultSet)results)) { termUri = r["term"].ToString(); if (termUri.StartsWith(namespaceUri)) { //Use the Comment as the label if available if (r.HasValue("RawComment")) { if (r["RawComment"] != null) { terms.Add(new NamespaceTerm(namespaceUri, termUri.Substring(namespaceUri.Length), r["RawComment"].ToString())); continue; } } //Use the Label as the label if available if (r.HasValue("RawLabel")) { if (r["RawLabel"] != null) { terms.Add(new NamespaceTerm(namespaceUri, termUri.Substring(namespaceUri.Length), r["RawLabel"].ToString())); continue; } } //Otherwise no label terms.Add(new NamespaceTerm(namespaceUri, termUri.Substring(namespaceUri.Length))); } } } lock (_terms) { terms.RemoveAll(t => _terms.Contains(t)); _terms.AddRange(terms.Distinct()); } } catch { //Ignore Exceptions - just means we won't have those namespace terms available } try { _loadedNamespaces.Add(namespaceUri); } catch (NullReferenceException) { //For some reason .Net sometimes throws a NullReferenceException here which we shall ignore } return GetNamespaceTerms(namespaceUri); }
//static void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) //{ // if (e.PropertyName == "ConsoleOutput") // Console.WriteLine((sender as ProcessViewModel).ConsoleOutput); //} /// <summary> /// https://bitbucket.org/dotnetrdf/dotnetrdf/wiki/User%20Guide /// </summary> static void TestRDF() { IGraph g = new Graph(); RdfXmlParser fileParser = new RdfXmlParser(); //fileParser.Load(g, "schema.xml"); fileParser.Load(g, "TestRdf.xml"); //SparqlQueryParser queryParser = new SparqlQueryParser(); //queryParser.ParseFromString("SELECT * WHERE { ?s a ?type }"); //VDS.RDF.Writing.StringWriter.Write(g, new RdfXmlWriter()) StringBuilder div = new StringBuilder(); XElement rdf = XElement.Parse(VDS.RDF.Writing.StringWriter.Write(g, new RdfXmlWriter())); foreach (XElement element in rdf.Elements()) { div.AppendFormat("<div itemscope itemtype=\"{0}/{1}\">", element.Name.NamespaceName.TrimEnd('/'), element.Name.LocalName); div.AppendLine(); foreach (XElement content in element.Elements()) { div.AppendFormat("<meta itemprop=\"{0}\" content=\"{1}\">", content.Name.LocalName, content.Value); div.AppendLine(); } div.AppendLine("</div>"); } var output = g.ExecuteQuery("SELECT * WHERE { ?s a ?type }"); SparqlParameterizedString query = new SparqlParameterizedString(); query.Namespaces.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#")); query.Namespaces.AddNamespace("owl", new Uri("http://www.w3.org/2002/07/owl#")); query.Namespaces.AddNamespace("xsd", new Uri("http://www.w3.org/2001/XMLSchema#")); query.Namespaces.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#")); query.Namespaces.AddNamespace("schema", new Uri("http://schema.org/")); query.Namespaces.AddNamespace("fact", new Uri("http://www.co-ode.org/ontologies/ont.owl#")); query.CommandText = "SELECT * WHERE { ?organization rdf:type fact:UniqueCompany }"; var output2 = g.ExecuteQuery(query); // var output2 = g.ExecuteQuery(@"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> // PREFIX owl: <http://www.w3.org/2002/07/owl#> // PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> // PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> // PREFIX schema: <http://schema.org/> // PREFIX fact:<http://www.co-ode.org/ontologies/ont.owl#> // SELECT * // WHERE { ?organization rdf:type fact:UniqueCompany }"); }