2

Assuming I have resources identified by hash-uris as follows:

Because the fragment is stripped off, I have to serve the data about all these resources at http://www.example.com/about

I want to retrieve the data from my triple-store via SPARQL and return it to the client. Is there a way to perfom a SPARQL Describe on all these resources? Or any other query that will do the job?

flag

2 Answers

3

You could try to simulate a simple DESCRIBE and use a regex filter to match all hash URIs of your document:

SELECT ?s ?p ?o WHERE {
  ?s ?p ?o
  FILTER (regex(?s, "^http://www.example.com/about#") || regex(?o, "^http://www.example.com/about#"))
}

Or you could just select all hash URIs and then perform a DESCRIBE with them individually.

link|flag
You could use the same regex trick directly with describe, right? Just replace "SELECT ?s ?p ?o" in the above example with "DESCRIBE ?s". – lee Jun 24 at 16:41
True, that'd be even easier. :-) – Simon Reinhardt Jun 24 at 21:53
Could you post an example? Because DESCRIBE ?s WHERE { FILTER (regex(?s, "^example.com/about#";)) } does not return anything – angelov Jun 25 at 7:33
I got it: describe ?s where {?s ?p ?o . filter(regex(str(?s), "^example.com/about#";))} – angelov Jun 25 at 8:10
6

It might be a good idea to group these resources together in the data itself, something like:

<http://www.example.com/about#alice> rdfs:isDefinedBy <http://www.example.com/about> .
<http://www.example.com/about#bob> rdfs:isDefinedBy <http://www.example.com/about> .
<http://www.example.com/about#trudy> rdfs:isDefinedBy <http://www.example.com/about> .

Or perhaps by some relationship that is meaningful within the domain, e.g., Alice and Bob and Trudy all work for the same company.

Then you can do:

DESCRIBE ?x
WHERE { ?x rdfs:isDefinedBy <http://www.example.com/about> }

Or:

DESCRIBE ?x
WHERE { ?x foaf:workplaceHomepage <http://www.example.com/> }
link|flag
I think this is a good approach generally, but it doesn't fit to my actual case. I will use the regex solution. Thanks anyway. – angelov Jun 25 at 8:15

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.