Retrieve triples with properties restricted by namespace [duplicate]

筅森魡賤 提交于 2019-12-13 04:13:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!