【发布时间】:2016-10-13 16:07:50
【问题描述】:
我想知道如何使用 dotNetRDF 将 RDF(下载这样的字符串)插入 Virtuoso。
例如,我已经阅读了您在此链接上找到的 RDF 数据:“http://publications.europa.eu/resource/cellar/fdc34ca7-6cbf-4f81-8bbd-e7255ccfa0c2.0005/rdf/object/full”
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:j.0="http://publications.europa.eu/ontology/cdm#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:j.1="http://www.w3.org/2004/02/skos/core#"
xmlns:j.2="http://publications.europa.eu/ontology/annotation#"
xmlns:j.3="http://publications.europa.eu/ontology/cdm/cmr#" >
<rdf:Description rdf:about="http://publications.europa.eu/resource/cellar/fdc34ca7-6cbf-4f81-8bbd-e7255ccfa0c2.0005.02">
<owl:sameAs rdf:resource="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007.FRA.print"/>
</rdf:Description>
<rdf:Description rdf:about="http://publications.europa.eu/resource/cellar/fdc34ca7-6cbf-4f81-8bbd-e7255ccfa0c2.0005">
<j.3:metsStructSuperDiv rdf:resource="http://publications.europa.eu/resource/cellar/fdc34ca7-6cbf-4f81-8bbd-e7255ccfa0c2"/>
<j.3:lang rdf:datatype="http://www.w3.org/2001/XMLSchema#language">fr</j.3:lang>
<j.3:lang rdf:datatype="http://www.w3.org/2001/XMLSchema#language">fra</j.3:lang>
<owl:sameAs rdf:resource="http://publications.europa.eu/resource/celex/31998R2278.FRA"/>
<owl:sameAs rdf:resource="http://publications.europa.eu/resource/uriserv/OJ.L_.1998.286.01.0013.01.FRA"/>
<owl:sameAs rdf:resource="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007.FRA"/>
<j.3:lastModificationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2014-04-04T10:21:30.312+02:00</j.3:lastModificationDate>
</rdf:Description>
<rdf:Description rdf:about="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007.FRA">
<j.0:uses rdf:resource="http://publications.europa.eu/resource/authority/language/FRA"/>
<j.0:expression_title_information_additional rdf:datatype="http://www.w3.org/2001/XMLSchema#string">CELEX1</j.0:expression_title_information_additional>
<j.0:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Règlement (CE) n° 2278/98 de la Commission du 22 octobre 1998 déterminant la mesure dans laquelle les demandes de certificats d'importation introduites en octobre 1998 pour certains produits du secteur de la viande de porc peuvent être acceptées dans le cadre du régime prévu par le règlement (CE) n° 774/94 du Conseil portant ouverture et mode de gestion de certains contingents tarifaires communautaires pour la viande porcine et certains autres produits agricoles</j.0:title>
<j.0:title_information_additional rdf:datatype="http://www.w3.org/2001/XMLSchema#string">CELEX1</j.0:title_information_additional>
<j.0:expression_belongs_to_work rdf:resource="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007"/>
<j.0:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">CELEX1</j.0:title>
<j.0:expression_manifested_by_manifestation rdf:resource="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007.FRA.print"/>
<rdf:type rdf:resource="http://publications.europa.eu/ontology/cdm#expression"/>
<j.0:expression_title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Règlement (CE) n° 2278/98 de la Commission du 22 octobre 1998 déterminant la mesure dans laquelle les demandes de certificats d'importation introduites en octobre 1998 pour certains produits du secteur de la viande de porc peuvent être acceptées dans le cadre du régime prévu par le règlement (CE) n° 774/94 du Conseil portant ouverture et mode de gestion de certains contingents tarifaires communautaires pour la viande porcine et certains autres produits agricoles</j.0:expression_title>
<j.0:expression_uses_language rdf:resource="http://publications.europa.eu/resource/authority/language/FRA"/>
<j.2:build_info>cdm:CDM_2.1.7 tdm:1523 xslt:3945 saxon:9.0.0.1J JVM:1.6.0_29 metaconvJar:1.2.0 builddate:04/04/2014 01:00:03</j.2:build_info>
<j.0:expression_manifested_by_manifestation rdf:resource="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007.FRA.pdf"/>
<j.0:belongs_to rdf:resource="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007"/>
</rdf:Description>
<rdf:Description rdf:about="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007">
<rdf:type rdf:resource="http://publications.europa.eu/ontology/cdm#legislation_secondary"/>
<rdf:type rdf:resource="http://publications.europa.eu/ontology/cdm#work"/>
<rdf:type rdf:resource="http://publications.europa.eu/ontology/cdm#resource_legal"/>
<rdf:type rdf:resource="http://publications.europa.eu/ontology/cdm#regulation"/>
</rdf:Description>
<rdf:Description rdf:about="http://publications.europa.eu/resource/authority/language/FRA">
<rdf:type rdf:resource="http://publications.europa.eu/ontology/cdm#language"/>
<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
<j.1:inScheme rdf:resource="http://publications.europa.eu/resource/authority/language"/>
<j.0:language_used_by_expression rdf:resource="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007.FRA"/>
</rdf:Description>
<rdf:Description rdf:about="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007.FRA.pdf">
<rdf:type rdf:resource="http://publications.europa.eu/ontology/cdm#manifestation"/>
</rdf:Description>
<rdf:Description rdf:about="http://publications.europa.eu/resource/cellar/fdc34ca7-6cbf-4f81-8bbd-e7255ccfa0c2">
<owl:sameAs rdf:resource="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007"/>
<owl:sameAs rdf:resource="http://publications.europa.eu/resource/eli/reg/1998/2278/oj"/>
<owl:sameAs rdf:resource="http://publications.europa.eu/resource/celex/31998R2278"/>
</rdf:Description>
<rdf:Description rdf:about="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007.FRA.print">
<rdf:type rdf:resource="http://publications.europa.eu/ontology/cdm#manifestation_official-journal_part"/>
<rdf:type rdf:resource="http://publications.europa.eu/ontology/cdm#manifestation"/>
</rdf:Description>
<rdf:Description rdf:about="http://publications.europa.eu/resource/cellar/fdc34ca7-6cbf-4f81-8bbd-e7255ccfa0c2.0005.01">
<rdf:type rdf:resource="http://publications.europa.eu/ontology/cdm#manifestation"/>
<owl:sameAs rdf:resource="http://publications.europa.eu/resource/oj/JOL_1998_286_R_0013_007.FRA.pdf"/>
</rdf:Description>
</rdf:RDF>
我已经将它(通过使用 HttpWebRequest)存储在一个字符串中,但我不知道如何通过 dotNetRDF 将它插入到我的 Virtuoso 中。任何的想法?
另外,如何在QueryWithResultSet函数上设置UserAgent呢? 在这个 EndPoint 上:http://publications.europa.eu/webapi/rdf/sparql 我必须设置 UserAgent,否则我无法从中获取查询。
谢谢
PS:我无法直接从目标服务器加载 RDF,因为出现 502 Bad Gateway 错误。
【问题讨论】:
-
1.我不想编写 RDF 并保存在另一个文件或流中 2。我想将数据保存到现有图表,我不需要保存图表! 3. 这是我在 Virtuoso 的第三个项目,当然我知道 Virtuoso 以及如何通过 dotNetRDF 连接到它。 4. 无法将在线RDF直接写入服务器,因为dotNetRDF库中缺少UserAgent设置。
-
@TallTed 你有别的想法吗? virtuoso.UpdateGraph("example.org/graph", null, new Triple[] { t });可以帮助我,但我不知道如何将 RDF 字符串转换为 Triple 数组!
-
如果您需要自定义
HttpWebRequest,例如添加UserAgent标头,您可以扩展SparqlRemoteEndpoint并覆盖ApplyCustomRequestOptions()方法。 -
真的没那么难,加了一个答案来证明这一点
标签: .net rdf virtuoso triplestore dotnetrdf