2016-10-13 3 views
1

dotNetRDF를 사용하여 Virtuoso에 RDF (해당 문자열을 다운로드 한)를 어떻게 삽입 할 수 있는지 알고 싶습니다.C# .Net에서 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 : 502 잘못된 게이트웨이 오류가 있기 때문에 내가 대상 서버에서 직접 RDF를로드 할 수 없습니다.

+1

'dotnetrdf' 문서를 읽었습니까? [dotNetRDF로 RDF 작성하기] (https://github.com/dotnetrdf/dotnetrdf/wiki/UserGuide-Writing-RDF), [트리플 스토어로 작업하기] (https://github.com/dotnetrdf/dotnetrdf/wiki)/UserGuide-Working-With-Triple-Stores), [제 3 자 트리플 스토어 통합] (https://github.com/dotnetrdf/dotnetrdf/wiki/UserGuide-Triple-Store-Integration), [Virtuoso] (https : /github.com/dotnetrdf/dotnetrdf/wiki/UserGuide-Storage-Virtuoso), [VirtuosoManager Class] (https://dotnetrdf.github.io/api/html/T_VDS_RDF_Storage_VirtuosoManager.htm) – TallTed

+0

1. 나는 싫어. RDF를 작성하고 다른 파일 또는 스트림에 저장하십시오. 2. 기존의 그래프에 데이터를 저장하고 싶습니다. 그래프를 저장하지 않아도됩니다! 3. Virtuoso에서 제 3의 프로젝트입니다. 제가 Virtuoso를 알고 있고, 어떻게 dotNetRDF에서 연결할 수 있습니까? 4. dotNetRDF 라이브러리에서 UserAgent 설정이 누락 되었기 때문에 RDF를 서버에 직접 온라인으로 쓸 수 없습니다. – ali

+0

@TallTed 다른 아이디어가 있으십니까? virtuoso.UpdateGraph ("http://example.org/graph", null, new Triple [] {t}); 나를 도울 수는 있지만 어떻게 트리플의 배열로 RDF 문자열을 변환 할 수 있는지 모르겠습니다! – ali

답변

2

당신은 SparqlRemoteEndpoint를 확장하고 당신이 UserAgent 헤더 추가로 HttpWebRequest 등을 사용자 정의해야하는 경우 ApplyCustomRequestOptions() 방법을 대체 할 수 있습니다 다음 ApplyCustomRequestOptions() 방법은 이렇게하는 데 사용할 수있는 제출 된 각 HttpWebRequest 전에 호출됩니다

public class MyCustomEndpoint : SparqlRemoteEndpoint 
{ 
    // Define appropriate constructors with the parameters you need e.g. 
    public MyCustomEndpoint(Uri endpointUri) 
    : base(endpointUri) { }  

    protected override ApplyCustomRequestOptions(HttpWebRequest request) 
    { 
    request.UserAgent = "My Custom User Agent" 
    } 
} 

을 필요한 모든 사용자 정의 작업을 수행하십시오. 그런 다음 필요에 따라 SparqlRemoteEndpoint 대신 MyCustomEndpoint을 사용하십시오.

사용 가능한 방법과 속성에 대한 자세한 내용은 SparqlRemoteEndpoint 설명서를 참조하십시오.

+0

에 문제가 있음을 보여주는 답변이 추가되었습니다. BadGateway는 항상 문제가 있습니다. 내 쿼리와 관련이 없으며 쿼리를 수행하기 위해 Firwall을 추가했다고 생각합니다. – ali

+0

ISQL 작업 영역에서 가져 오기 데이터를 C# 구문으로 바꾸는 방법이 있습니까? – ali

+0

다른 질문이있는 경우 새로운 질문을 만들어야합니다! 의견은 질문/대답에 대한 설명을 위해서만 사용됩니다 – RobV

관련 문제