使用QueryWithResultSet dotnetrdf XML例外 [英] dotnetrdf xml exception using QueryWithResultSet

查看:279
本文介绍了使用QueryWithResultSet dotnetrdf XML例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net项目中,我想查询DBpedia中。
使用下面的代码,我得到一个错误:

 公共字符串testEndpoint()
{

// TEST02
SparqlRemoteEndpoint端点=新SparqlRemoteEndpoint(新URI(http://dbpedia.org/sparql),http://dbpedia.org);
字符串资源=;
//使对端点
SparqlResultSet结果= endpoint.QueryWithResultSet一个SELECT查询(选择今年在哪里办理?{DBpedia中:蕾哈娜DBpedia的猫头鹰:birthYear年});

的foreach(SparqlResult导致的结果)
{
解析度= result.ToString();
Console.WriteLine(result.ToString());}




错误消息:类型'System.Xml.XmlException'的异常出现在dotNetRDF.dll但在用户代码中没有处理。




即使我处理不能被执行的方法的异常。关于它说,有一个无效的XML-1.1版本的细节。



由于XML来自DBpedia中,我不知道如何改变XML版本还是怎么回事我可以处理这个问题。


解决方案

炫技,这是DBpedia中SPARQL端点背后使用的三联店,已经更新了其XML结果的产生。他们更换了XML 1.0版与1.1 这个提交。这将导致在dotNetRDF解析器除外。



后来上炫技恢复在XML头的变化。 。希望DBpedia中很快就会更新自己的二进制文件,所以旧XML头中的SPARQL结果再次出现



来源:的 http://github.com/openlink/virtuoso-opensource/issues/405


I have an asp.net project in which, I would like to query DBPedia. Using the following code I am getting an error:

public string testEndpoint()
    {

        //TEST02
        SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("http://dbpedia.org/sparql"), "http://dbpedia.org");
        string res = "";
        //Make a SELECT query against the Endpoint
        SparqlResultSet results = endpoint.QueryWithResultSet("SELECT ?year WHERE {dbpedia:Rihanna dbpedia-owl:birthYear ?year}");

        foreach (SparqlResult result in results)
        {
            res = result.ToString();    
            Console.WriteLine(result.ToString());}

Error message: "An exception of type 'System.Xml.XmlException' occurred in dotNetRDF.dll but was not handled in user code".

Even if I handle the exception the method cannot be executed. Regarding the details it says that there is an invalid XML-version 1.1.

As the XML comes from DBPedia I don't know how to change the xml version or how else I can handle this problem.

解决方案

Virtuoso, which is the triple store used behind the dbpedia SPARQL endpoint, has updated its XML result generation. They replaced the XML version 1.0 with 1.1 in this commit. This causes the exception in the dotNetRDF parser.

Later on Virtuoso reverted the changes in the XML header. Hopefully DBPedia will update their binaries soon, so the old XML header appears again in the SPARQL results.

Source: http://github.com/openlink/virtuoso-opensource/issues/405

这篇关于使用QueryWithResultSet dotnetrdf XML例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆