SPARQL Querying for RDF File
Asked Answered
P

1

6

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

Publisher answered 17/12, 2011 at 17:28 Comment(0)
D
7

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 }
Desinence answered 17/12, 2011 at 21:24 Comment(1)
Cheers for the answer this is exactly what I was looking for.Publisher

© 2022 - 2024 — McMap. All rights reserved.