tags:

views:

945

answers:

4

I am trying to select the rdf:ID of an object with sparql (inside Protege) and I cant seem to get the rdf:ID. Has anyone seen this problem. The SPARQL query i am using is:

Select * where (?element rdf:id ?id)

The following also does not work:

Select * where (?element rdfs:label ?id)

Took a suggestion, but still this is no go:

Select * where (?element rdfs:about ?id)

But this does:

Select * where (?element rdfs:comment ?id)

All I get is "No Matches". So I can select the comment but not thelabel...ideas?

UPDATE:: After some more research, selecting the following:

Select ?subject ?property ?object where (?subject ?property ?object)

Does not come up with any of the RDFS properties. Am I missing something major? (I can slect it with rdfs:comment, but that does not show up either...

+1  A: 

I guess your rdf:ID (a local reference in your rdf document) will be resolved using xml:base and transformed into a rdf:about

Pierre
+2  A: 

Firstly rdf:id does not exist in the data model - the rdf graph triples. "rdf:ID" is a syntax term used in one syntax, RDF/XML but does not appear in triples. Similarly rdf:about is a syntax term.

As to why the protege's sparql will not work here - and I have not used Protege - I imagine that the triples you are trying to find are inferred by the inference engine and thus are not necessarily in the base rdf graph.

It's not entirely clear what you are trying to do. You want the URI object [of some triple]? How do you identify that triple?

dajobe
+2  A: 

If you're looking for the URI of all RDF subjects, you would run:

SELECT ?subject WHERE { ?subject ?predicate ?object }

Note that you need curly braces and not parentheses. Also note that case matters in RDF, so be very careful about the spelling and capitalization of your URIs (and prefixes/local names).

To dajobe's point regarding entailments (inferred triples), rdfs:label is an OWL annotation property and will be ignored by inferencers unless you include your own rules and/or OWL constructs. In other words, if you're just starting out with RDF, I would be surprised if a reasoner inferred triples with rdfs:label as a predicate.

Phil M
A: 

The following query gets me the rdf:ID for an individual of type pref:class

select * where { ?id rdf:type pref:class }

rguha
Your query will return the full URI for any individuals that match, with each individual bound to a variable named "id". This is not the same as the rdf:ID (see http://www.w3.org/TR/rdf-primer/#newresources for detail).
Phil M