0

Given a resource http://foo.com/res1 that is the subject of several of triples with properties from two different ontologies:

<http://foo.com/res1> dc:author <http://ppl.com/bob>
<http://foo.com/res1> dc:title "some resource"
<http://foo.com/res1> foaf:depiction <http://flickr.com/picture/1234>

I want to obtain all the triples with properties in the dc namespace and ignore all others. How can I do this?

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
João Rocha da Silva
  • 4,259
  • 4
  • 26
  • 35
  • Thanks, I am voting to close the question as it seems I was searching for restricting to "ontology" and not "namespace". – João Rocha da Silva Sep 16 '13 at 16:33
  • Since you posted it, you can actually delete the question, if you want. Having duplicates (but closed as such) around isn't bad through, because now if someone else searches and uses "ontologies" instead of namespaces, they'll find this one, and get pointed to the other question. You can also flag the question for moderator attention, too, if you don't have enough rep to cast a close vote. – Joshua Taylor Sep 16 '13 at 16:46
  • I flagged the question and explained your point. Thanks! – João Rocha da Silva Sep 16 '13 at 18:12

1 Answers1

4

How about using the XPath starts-with function:

SELECT * 
WHERE {
    <http://foo.com/res1> ?p ?o .
    FILTER(fn:starts-with(STR(?p),"http://purl.org/dc/elements/1.1/")).
}

It fetches all triples for <http://foo.com/res1>, but includes only the ones that have a predicate whose string representation starts with http://purl.org/dc/elements/1.1/.

cyroxx
  • 3,809
  • 3
  • 23
  • 35