[英]Following namespaces in SPARQL query
给定这种数据结构
@prefix core <http://www.w3.org/2004/02/skos/core#>
<http://localhost/myvocab/1> core#notation 1 .
<http://localhost/myvocab/1> <http://www.w3.org/2006/time#inDateTime> <http://localhost/myvocab/item1#DateDescription> .
<http://localhost/myvocab/item1#DateDescription> <http://www.w3.org/2006/time#year> 2016 ;
<http://www.w3.org/2006/time#month> "June"
如果我跑步
select * where {?s ?p ?o .
<http://www.w3.org/2004/02/skos/core#notation> 1 . }
那么仅返回前两个三元组( :hasID
和:hasTime
)。 是否有一个sparql查询(最好不使用正则表达式过滤器来匹配ID)也要从子名称空间返回所有三元组?
我希望我可以达到以下目标
-------------------------------------------------------------------------------------------------------------------------------------------------------
| s | p | o |
=======================================================================================================================================================
| <http://localhost/myvocab/item1> | <http://www.w3.org/2006/time#inDateTime> | <http://localhost/myvocab/item1#DateDescription |
| <http://localhost/myvocab/item1> | <http://www.w3.org/2004/02/skos/core#notation> | 1 |
| <http://localhost/myvocab/item1#DateDescription> | <http://www.w3.org/2006/time#month> | "June" |
| <http://localhost/myvocab/item1#DateDescription> | <http://www.w3.org/2006/time#year> | 2016 |
-------------------------------------------------------------------------------------------------------------------------------------------------------
如果您提供了我们可以实际加载的数据以及您尝试过的属性形式的查询,那么它总是有帮助的。 您显示的数据实际上并不合法,您提供的查询也不合法。 以下是一些实际可加载的示例数据:
@prefix core: <http://www.w3.org/2004/02/skos/core#>
<http://localhost/myvocab/1> core:notation 1 ;
<http://www.w3.org/2006/time#inDateTime> <http://localhost/myvocab/item1#DateDescription> .
<http://localhost/myvocab/item1#DateDescription> <http://www.w3.org/2006/time#year> 2016 ;
<http://www.w3.org/2006/time#month> "June"
如果您了解我的话,那么您也想遵循:item1_DateTime对象的属性。 您可以通过遵循:item1的属性和值等的属性路径来实现。 在此查询中,我将(:|!:)用作通配符,因为每个属性都是:或不是。 末尾的*表示遵循任意长度的路径。
prefix core: <http://www.w3.org/2004/02/skos/core#>
select ?s ?p ?o where {
?s_ core:notation 1 ;
(<>|!<>)* ?s .
?s ?p ?o .
}
--------------------------------------------------------------------------------------------------------------------------------------------------
| s | p | o |
==================================================================================================================================================
| <http://localhost/myvocab/1> | <http://www.w3.org/2006/time#inDateTime> | <http://localhost/myvocab/item1#DateDescription> |
| <http://localhost/myvocab/1> | core:notation | 1 |
| <http://localhost/myvocab/item1#DateDescription> | <http://www.w3.org/2006/time#month> | "June" |
| <http://localhost/myvocab/item1#DateDescription> | <http://www.w3.org/2006/time#year> | 2016 |
--------------------------------------------------------------------------------------------------------------------------------------------------
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.