Hi,

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

asked 22 Feb '12, 08:21

Codera%20Purpa's gravatar image

Codera Purpa
14416
accept rate: 0%


How about

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

?

permanent link

answered 22 Feb '12, 10:54

database_animal's gravatar image

database_animal ♦
8.4k1612
accept rate: 15%

Or to avoid the FILTER:

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

Or abbreviated:

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

Or abbreviated further:

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

Or SPARQL 1.1 bind:

BASE <http://www.semanticweb.org/ontologies/2012/1/graph.owl#>
SELECT ?idRef ?name ?src ?dst ?perf
WHERE {
   BIND (<arc_cfp> as >?x)
   ?x graph:idRef_arc ?idRef ; 
     graph:name_arc ?name ;
     graph:hasSource ?src ;
     graph:hasDestination ?dst ;
     graph:hasPerformatif ?perf .
}
permanent link

answered 22 Feb '12, 13:12

Signified's gravatar image

Signified ♦
24.0k1623
accept rate: 37%

edited 22 Feb '12, 15:20

I like the use of FILTER here, since I don't like repeating the URI.

Mind you, many toolsets would let you just use ?x in your query and bind ?x to a URI when you do the query, and that's convenient.

(22 Feb '12, 14:55) database_animal ♦ database_animal's gravatar image

Including SPARQL 1.1.

http://www.w3.org/TR/sparql11-query/#bind

... BIND (<http://www.semanticweb.org/ontologies/2012/1/graph.owl#arc_cfp> as ?x) ...

The FILTER might imply a performance hit in some stores.

(22 Feb '12, 15:17) Signified ♦ Signified's gravatar image

Duplicating my answer from StackOverflow:

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> }
}
permanent link

answered 22 Feb '12, 15:10

Rob%20Vesse's gravatar image

Rob Vesse ♦
13.9k1715
accept rate: 29%

1

DESCRIBE might be worth a mention here, with the caveat that it's not well-defined.

(22 Feb '12, 15:20) Signified ♦ Signified's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×1,305
×878
×617
×150

question asked: 22 Feb '12, 08:21

question was seen: 1,833 times

last updated: 22 Feb '12, 15:20