How to validate datetime object in SPARQL? (Virtuoso 22007 Error DT006)

荒凉一梦 提交于 2019-12-23 12:36:28

问题


I get the following error.

Virtuoso 22007 Error DT006: Cannot convert -0359 to datetime : Incorrect month field length

SPARQL query:
define sql:big-data-const 0 
#output-format:text/html
define sql:signal-void-variables 1 select ?item  bif:year(xsd:dateTime( str(?dob))) as ?m{
?item <h://f.cm/ns/common/topic/notable_types> <h://f.cm/ns/people/person> .
?item <h://f.cm/ns/people/person/date_of_birth> ?dob 
} limit 675

If I change the limit to 674, it works.

What I suspected was that some datetime field is wrong somewhere and printed ?dob, which revealed that one of the values is -0359.

Solution is to validate the value before applying bif function.

But, how can we validate datetime in SPARQL?


回答1:


Well, I found this question via Google because I had the same problem. Looking elsewhere for help, I found the following solution:

SELECT * {

  ?s ?p ?o

  FILTER ( datatype(?o) = xsd:datetime )
  FILTER ( coalesce(xsd:datetime(str(?o)), '!') != '!')

}

This worked for me.

Note that I found the answer to this at SemanticWeb.



来源:https://stackoverflow.com/questions/13896118/how-to-validate-datetime-object-in-sparql-virtuoso-22007-error-dt006

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