PCoder
PCoder

Reputation: 2185

How to query an RDF individual for its data properties?

I have an ontology where arc_cfp is an individual of class Arc. I would like to know how could I get all the data properties of the individual, given that I have the individual's URI?

Basically, I am doing this:

SELECT ?idRef ?name ?src ?dst ?perf
WHERE 
{
    ?x rdf:type http://www.semanticweb.org/ontologies/2012/1/graph.owl#arc_cfp .
    ?x graph:idRef_arc ?idRef .
    ?x graph:name_arc ?name .
    ?x graph:hasSource ?src .
    ?x graph:hasDestination ?dst .
    ?x graph:hasPerformatif ?perf .
}

I am pretty sure, using rdf:type is the problem. But, I have no idea what I need to use.

Thanks.

~Codera

Upvotes: 2

Views: 727

Answers (2)

Pradeep Gollakota
Pradeep Gollakota

Reputation: 2181

You can also use a DESCRIBE query to grab all the RDF data about a Resource.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
DESCRIBE ?x
WHERE
{
    ?x rdf:type http://www.semanticweb.org/ontologies/2012/1/graph.owl#arc_cfp .
}

P.S. Don't forget to put prefixes in your queries.

Upvotes: 0

RobV
RobV

Reputation: 28646

Assuming you want a purely exploratory query of the form "give me all the triples about a subject" it should look the following:

SELECT *
WHERE
{
  <http://example.org/SomeThing> ?p ?o
} 

This will give you all predicate object pairs associated with the constant URI you pass in. If you are interesting in incoming as well as outgoing properties you could do the following instead:

SELECT *
WHERE
{
  { <http://example.org/SomeThing> ?p ?o }
  UNION
  { ?s ?p <http://example.org/SomeThing> }
} 

Upvotes: 1

Related Questions