Make a query in SPARQL with DataType Property

强颜欢笑 提交于 2020-01-05 04:26:08

问题


I'm working with an ontology OWL and making a query about it.

My query is:

"PREFIX a: http://www.owl-ontologies.com/Indoor.owl# " + "SELECT ?X " + "WHERE { ?X a:hasDay a:" + day + " . " + " ?X a:hasRoom a:" + room + " . " + " ?X a:hasStartTime a:" + startTime +" }";

At the moment to make the query, the console of NetBeans throw me:

Undefined object property used in query: http://www.owl-ontologies.com/Indoor.owl#hasStartTime

But hasStartTime in the ontology isn't an object property, it is a data type (int).


回答1:


Assuming that the value of the Java variable startTime is e.g. 420 (7am), if you look at your SPARQL query, the last triple pattern is made by

?X a:hasStartTime a: plus value of ``startTime,

i.e. it results in

?X a:hasStartTime a:420

RDF literals have to be put in quotes without a prefix - it's a literal and not a prefixed URI, e.g.

?X a:hasStartTime 420

or to make the datatype more explicit (for integer values the above is just a shortcut)

?X a:hasStartTime "420"^^<http://www.w3.org/2001/XMLSchema#integer>



来源:https://stackoverflow.com/questions/44036787/make-a-query-in-sparql-with-datatype-property

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