Datatype format exception for xsd:dateTime in SPARQL query with Jena?

你离开我真会死。 提交于 2020-01-04 01:58:17

问题


I am trying to apply a range query on a property of the RDF which is of xsd:dateTime format. This is my query:

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

It gives warning and nothing as result:

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

I don't understand what the problem is? I have stored the property in xsd:dateTime format only.


回答1:


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

The simple answer is that no, you have not stored the value as an xsd:dateTime. The standard xsd:dateTime says:

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

Part of your dateTime matches that, viz., 2014-06-05T10:10:10. However,

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

When we look below, we see

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.

Your timezone doesn't match that. I think you probably meant +05:30. and thus should have

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

Sure enough, if we use Jena's command line tool 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 )
  }


来源:https://stackoverflow.com/questions/24166518/datatype-format-exception-for-xsddatetime-in-sparql-query-with-jena

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