sparql rdf fuseki 我如何过滤图形名称中的日期

sparql rdf fuseki how can i filter date in graph name

我在 jena fuseki rdf store 上得到了很多图名, 这些是我的图表的名称:

| <http://stormsmacs/tests/2015-03-03T04:27:57Z> |
| <http://stormsmacs/tests/2015-03-03T05:20:59Z> |
| <http://stormsmacs/tests/2015-03-03T05:22:29Z> |
| <http://stormsmacs/tests/2015-03-03T05:25:03Z> |
| <http://stormsmacs/tests/2015-03-03T05:27:01Z> |
| <http://stormsmacs/tests/2015-03-03T05:30:37Z> |
| <http://stormsmacs/tests/2015-03-03T05:44:02Z> |
| <http://stormsmacs/tests/2015-03-03T05:52:19Z> |
| <http://stormsmacs/tests/2015-03-03T05:58:47Z> |

等等。 我如何过滤图表以获得两个日期之间的所有图表?

非常感谢!

当我们有实际数据可以使用时,这会更容易。请务必提供我们将来可以使用的数据。对于这种情况,我只是使用 values 块将嵌入日期时间的 URI 绑定到 ?dateUri 变量。查询中的注释解释了正在发生的事情。大致的思路是将URI转为字符串,去掉公共前缀,将后缀转为xsd:dateTime,并以此为基础进行过滤

prefix xsd: <http://www.w3.org/2001/XMLSchema#>

select ?dateTime where {
  #-- the "dates" encoded in URIs
  values ?dateUri { <http://stormsmacs/tests/2015-03-03T04:27:57Z>
                    <http://stormsmacs/tests/2015-03-03T05:20:59Z>
                    <http://stormsmacs/tests/2015-03-03T05:22:29Z>
                    <http://stormsmacs/tests/2015-03-03T05:25:03Z>
                    <http://stormsmacs/tests/2015-03-03T05:27:01Z>
                    <http://stormsmacs/tests/2015-03-03T05:30:37Z>
                    <http://stormsmacs/tests/2015-03-03T05:44:02Z>
                    <http://stormsmacs/tests/2015-03-03T05:52:19Z>
                    <http://stormsmacs/tests/2015-03-03T05:58:47Z> }

  #-- an arbitrary begin and end date                    
  values ?begin { "2015-03-03T05:22:29Z"^^xsd:dateTime }
  values ?end   { "2015-03-03T05:44:02Z"^^xsd:dateTime }

  #-- extract the dateTime portion from the URI string, and convert
  #-- it to an xsd:dateTime.
  bind( xsd:dateTime(strafter(str(?dateUri),"http://stormsmacs/tests/")) as ?dateTime )

  #-- filter results based on the begin and end time
  filter( ?begin <= ?dateTime && ?dateTime <= ?end )
}
----------------------------------------
| dateTime                             |
========================================
| "2015-03-03T05:22:29Z"^^xsd:dateTime |
| "2015-03-03T05:25:03Z"^^xsd:dateTime |
| "2015-03-03T05:27:01Z"^^xsd:dateTime |
| "2015-03-03T05:30:37Z"^^xsd:dateTime |
| "2015-03-03T05:44:02Z"^^xsd:dateTime |
----------------------------------------