gpt4 book ai didi

java - xsd :dateTime in SPARQL query with Jena? 的数据类型格式异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:24:20 26 4
gpt4 key购买 nike

我正在尝试对格式为 xsd:dateTime 的 RDF 属性应用范围查询。这是我的查询:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
SELECT ?x WHERE { ?y <DATE:> ?x .
FILTER(?x>"2014-06-05T10:10:10+0530"^^xsd:dateTime) }

它给出警告但没有任何结果:

WARN [main] (Log.java:78) - Datatype format exception: "2014-06-11T12:44:22+0530"^^xsd:dateTime

我不明白这是什么问题?我仅以 xsd:dateTime 格式存储该属性。

最佳答案

I have stored the property in xsd:dateTime format only.

简单的回答是不,您没有将该值存储为 xsd:dateTime。标准xsd:dateTime说:

The lexical space of dateTime consists of finite-length sequences ofcharacters of the form: '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?

您的日期时间的一部分与此匹配,即 2014-06-05T10:10:10。然而,

zzzzzz (if present) represents the timezone (as described below).

当我们往下看时,我们看到

The lexical representation of a timezone is a string of the form:(('+' | '-') hh ':' mm) | 'Z', where

  • hh is a two-digit numeral (with leading zeros as required) that represents the hours,
  • mm is a two-digit numeral that represents the minutes,
  • '+' indicates a nonnegative duration,
  • '-' indicates a nonpositive duration,
  • 'Z' indicates a zero-timezone offset (UTC+0).

您的时区不匹配。我认为您可能是指 +05:30。因此应该有

"2014-06-05T10:10:10+05:30"^^xsd:dateTime

果然,如果我们使用Jena的命令行工具qparse:

$ qparse --query query.rq # the original query, warnigns
14:12:22 WARN NodeValue :: Datatype format exception: "2014-06-05T10:10:10+0530"^^xsd:dateTime
14:12:22 WARN NodeValue :: Datatype format exception: "2014-06-05T10:10:10+0530"^^xsd:dateTime
14:12:22 WARN NodeValue :: Datatype format exception: "2014-06-05T10:10:10+0530"^^xsd:dateTime
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?x
WHERE
{ ?y <DATE:> ?x
FILTER ( ?x > "2014-06-05T10:10:10+0530"^^xsd:dateTime )
}
$ qparse --query query.rq # the updated query, no warnings
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?x
WHERE
{ ?y <DATE:> ?x
FILTER ( ?x > "2014-06-05T10:10:10+05:30"^^xsd:dateTime )
}

关于java - xsd :dateTime in SPARQL query with Jena? 的数据类型格式异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24166518/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com