问题
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?
回答1:
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/
.
来源:https://stackoverflow.com/questions/18831007/retrieve-triples-with-properties-restricted-by-namespace