From: Rob V. <rv...@vd...> - 2012-04-11 16:14:08
|
Hi Anji You must explicitly define any prefixes that you want to use in your queries. So your query should look like the following: Object results = g.ExecuteQuery("PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT * WHERE { ?Bonds rdfs:subClassOf owl:class} "); Hope this helps, Rob On 4/11/12 2:10 AM, anji reddy wrote: Hi, I am getting an error while querying .owl file from my application...... The error code : The Namespace URI for the given Prefix 'owl' is not known by the in-scope NamespaceMapper in the line ---------- Object results = g.ExecuteQuery("SELECT * WHERE { ?Bonds rdfs:subClassOf owl:class} "); Here, I am attaching my .owl file (developed by using protege tool) and the below application code. i want read synonyms of Bonds from my owl file..... pls help me... i am not getting much more from it.... Sample Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using VDS.RDF; using VDS.RDF.Query; using VDS.RDF.Parsing; using VDS.RDF.Web; namespace SPARQL { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //Define your Graph here - it may be better to use a QueryableGraph if you plan //on making lots of Queries against this Graph as that is marginally more performant IGraph g = new Graph(); //Load some data into your Graph using the LoadFromFile() extension method g.LoadFromFile(@"C:\Users\admin\Desktop\UDDI\SPARQL\SPARQL\FinancialInvestme nt.owl"); //Use the extension method ExecuteQuery() to make the query against the Graph try { Object results = g.ExecuteQuery("SELECT * WHERE { ?Bonds rdfs:subClassOf owl:class} "); } if (results is SparqlResultSet) { //SELECT/ASK queries give a SparqlResultSet SparqlResultSet rset = (SparqlResultSet)results; foreach (SparqlResult r in rset) { //Do whatever you want with each Result } } else if (results is IGraph) { //CONSTRUCT/DESCRIBE queries give a IGraph IGraph resGraph = (IGraph)results; foreach (Triple t in resGraph.Triples) { //Do whatever you want with each Triple } } else { //If you don't get a SparqlResutlSet or IGraph something went wrong //but didn't throw an exception so you should handle it here Console.WriteLine("ERROR"); } } catch (RdfQueryException queryEx) { //There was an error executing the query so handle it here Console.WriteLine(queryEx.Message); } } } } ---------------------------------------------------------------------------- -- Better than sec? Nothing is better than sec when it comes to monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free. http://p.sf.net/sfu/Boundary-dev2dev _______________________________________________ dotNetRDF-Support mailing list dot...@li... https://lists.sourceforge.net/lists/listinfo/dotnetrdf-support |