这个 SPARQL 查询有什么问题?

发布于 2024-10-05 17:18:46 字数 1138 浏览 5 评论 0原文

String sparql = "";
            sparql+= "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n";
            sparql+= "PREFIX i: <http://evolizer.org/ontologies/seon/2010/09/softwaremetrics.owl#>\n";
            sparql+= "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n";
            sparql+="SELECT ?metric ?value\n";
            sparql+="WHERE {\n";
            sparql+="?metric rdf:type i:SoftwareDesignMetric .\n";
            sparql+="?metric i:hasName McCabe .\n";
            sparql+= "?metric i:hasValue ?value \n";
            sparql+="}\n";

通过执行我得到这个异常:

A first chance exception of type 'System.Net.WebException' occurred in System.dll
exception when sending query: 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX i: <http://evolizer.org/ontologies/seon/2010/09/softwaremetrics.owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?metric ?value
WHERE {
?metric rdf:type i:SoftwareDesignMetric .
?metric i:hasName McCabe .
?metric i:hasValue ?value 
}

问题必须是查询本身,因为对同一服务器的其他查询正在工作。

String sparql = "";
            sparql+= "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n";
            sparql+= "PREFIX i: <http://evolizer.org/ontologies/seon/2010/09/softwaremetrics.owl#>\n";
            sparql+= "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n";
            sparql+="SELECT ?metric ?value\n";
            sparql+="WHERE {\n";
            sparql+="?metric rdf:type i:SoftwareDesignMetric .\n";
            sparql+="?metric i:hasName McCabe .\n";
            sparql+= "?metric i:hasValue ?value \n";
            sparql+="}\n";

By executing i get this exception:

A first chance exception of type 'System.Net.WebException' occurred in System.dll
exception when sending query: 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX i: <http://evolizer.org/ontologies/seon/2010/09/softwaremetrics.owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?metric ?value
WHERE {
?metric rdf:type i:SoftwareDesignMetric .
?metric i:hasName McCabe .
?metric i:hasValue ?value 
}

The problem has to be the query itself, because other queries to the same server are working.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮世清欢 2024-10-12 17:18:46

所有示例此处都放置字符串参数(例如示例中的 McCabe)用引号引起来。会是这样吗?

All of the examples here place the string arguments (such as McCabe in your example) in quotes. Could this be it?

允世 2024-10-12 17:18:46

我还找到了一个验证器,它提示查询有什么问题:

http://sparql.org/query -validator.html

I also found a validator that gives hint on what is wrong with a query:

http://sparql.org/query-validator.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文