I have a RDF File like the one shown below. But I am finding it hard to do queries on it. For example could anyone tell me a simple query where I could extract the about (http://websitename.com/urls/a) or resource (http://websitename.com/urls/b) or about and resource where the relationship/owl is sameas.
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#" >
<rdf:Description rdf:about="http://websitename.com/urls/a">
<owl:sameas rdf:resource="http://websitename.com/urls/b"/>
</rdf:Description>
</rdf:RDF>
Thanks
An RDF query language is a computer language, specifically a query language for databases, able to retrieve and manipulate data stored in Resource Description Framework (RDF) format. SPARQL has emerged as the standard RDF query language, and in 2008 became a W3C recommendation.
SPARQL contains capabilities for querying required and optional graph patterns along with their conjunctions and disjunctions. SPARQL also supports extensible value testing and constraining queries by source RDF graph. The results of SPARQL queries can be results sets or RDF graphs.
The query consists of two parts: the SELECT clause identifies the variables to appear in the query results, and the WHERE clause provides the basic graph pattern to match against the data graph.
You've been bitten by a common misconception among novice RDF/XML users that the attribute names are directly related to the actual data when in fact they are not. The attribute names within the rdf namespaces are just XML syntax and don't actually relate to URIs in the data, on the other hand things in other namespaces e.g. owl in your examples typically do relate directly to URIs in the data. So this is why it's so easy for people new to RDF/XML to get confused.
If we convert your data to a more readable syntax like Turtle it actually looks like the following:
@prefix : <http://websitename.com/urls/> .
@prefix owl: <http://www.w3.org/2002/07/owl#sameas>
:a owl:sameAs :b .
Most times people prefer to show snippets of RDF as Turtle as it is much more readable and easy to see exactly what the data is.
So to actual query this you might want a query like the following:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT ?x ?y WHERE { ?x owl:sameAs ?y }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With