Unresolved prefixed name: rdfs:subClassOf in SPARQL query

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 15:00:46
William McCall
String queryString ="SELECT ?ds ?o WHERE {?ds  rdfs:subClassOf ?o }";

Should be

String queryString ="PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?ds ?o WHERE {?ds  rdfs:subClassOf ?o }";  

As William's succinct answer implies the problem is that you haven't defined what the rdfs prefix represents. Prefixed Names in SPARQL and other related RDF standards are purely a syntactic convenience for writing queries and data in a more compact and readable way. You can assign a prefix to represent any namespace URI you want so you must always explicitly define your prefixes using the mechanism of the format you are using.

In the case of SPARQL this is the PREFIX keyword which is used to define prefixes. These definitions must appear before the main body of your query and you can have as many definitions as you want present.

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