[英]Extend prefix URIs in SPARQL query
I have created a prefix which has various sublevels for example:我创建了一个具有各种子级别的前缀,例如:
PREFIX myprefix: <https://myprefix.org/>
I have several sublevels of prefix that I have used to organise my data.我有几个子级别的前缀用于组织数据。 For example:
例如:
https://myprefix.org/people
https://myprefix.org/buildings
https://myprefix.org/plants
I would now like to be able to specify the prefix with the extension in a SPARQL query.我现在希望能够在 SPARQL 查询中指定带有扩展名的前缀。 For example, I would like to select all of the properties in my database connected to the instance with the URI
https://myprefix.org/people/michael
:例如,我想 select 我的数据库中的所有属性都连接到 URI
https://myprefix.org/people/michael
的实例:
PREFIX myprefix: <https://myprefix.org/>
select * where {
myprefix:people/michael ?p ?o.
} limit 100
I have tried several approaches and have been unable to extend the prefix URI in the SPARQL query.我尝试了几种方法,但无法在 SPARQL 查询中扩展前缀 URI。 I am now wondering if it good practice to use subcategories for prefixes or whether each prefix be complete to the instance or property it is describing.
我现在想知道使用子类别作为前缀是否是一种好的做法,或者每个前缀是否完整到它所描述的实例或属性。
Is there any advice on how to accomplish this?关于如何实现这一点有什么建议吗?
What I tend to do is to have a prefix for entities and one for ontologies, such as this: PREFIX: <http://example.com/entities#>
PREFIX ont: <http://example.com/ontology#>
我倾向于做的是为实体设置一个前缀,为本体设置一个前缀,例如:
PREFIX: <http://example.com/entities#>
PREFIX ont: <http://example.com/ontology#>
Then, when I want different entities, I will simply write: :people_michael
or :plants_1234
.然后,当我想要不同的实体时,我会简单地写:
:people_michael
或:plants_1234
。
Alternatively, your approach can also work, but in SPARQL you'll need to escape the /
, so your query will be:或者,您的方法也可以工作,但在 SPARQL 中,您需要转义
/
,因此您的查询将是:
PREFIX myprefix: <https://myprefix.org/>
SELECT *
WHERE {
myprefix:people\/michael ?p ?o.
}
LIMIT 100
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.