这个SPARQL查询有什么问题?

时间:2010-12-02 22:50:51

标签: c# web-services sparql

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 
}

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

2 个答案:

答案 0 :(得分:3)

所有示例here都将字符串参数(例如示例中的McCabe)放在引号中。这可能是吗?

答案 1 :(得分:0)

我还找到了一个验证器,它提示了查询的错误:

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