2014-11-16 16 views
1

나는이 같은 RDF/XML 파일이 :(초보자)

<rdf:RDF 
xmlns:go="http://www.geneontology.org/dtds/go.dtd#" 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> 
     <go:term rdf:about="http://www.geneontology.org/go#GO:0000001"> 
      <go:accession>GO:0000001</go:accession> 
      <go:name>mitochondrion inheritance</go:name> 
      <go:synonym>mitochondrial inheritance</go:synonym> 
      <go:definition>The distribution of mitochondria, including the mitochondrial genome, into daughter cells after mitosis or meiosis, mediated by interactions between mitochondria and the cytoskeleton.</go:definition> 
      <go:is_a rdf:resource="http://www.geneontology.org/go#GO:0048308" /> 
      <go:is_a rdf:resource="http://www.geneontology.org/go#GO:0048311" /> 
     </go:term> 
</rdf:RDF> 

그럼 난에이 RDF/XML을 변환 할 필요를 N-Triples 형식을 사용했고 Jena와 함께이 작업을 자동으로 수행했습니다.

FileManager.get().addLocatorClassLoader(Converter.class.getClassLoader()); 
    Model model = FileManager.get().loadModel("smallfacts.rdf"); 
    try { 

      File file= new File("outputsmall.txt"); 
      model.write(new FileOutputStream(file), "N-Triples"); 
     } catch (IOException e) { 
      e.printStackTrace(); 

하지만 각 접두사는 접두어로 줄여야합니다. 나는 약 getNSPrefix()을 읽고 몇 가지 시도를했다

<http://www.geneontology.org/go#GO:2000391> is_a <http://www.geneontology.org/go#GO:2000389>. 
<http://www.geneontology.org/go#GO:2000391> accession "GO:2000391". 

같은 :

FileManager.get().addLocatorClassLoader(Converter.class.getClassLoader()); 
    Model model = FileManager.get().loadModel("smallfacts.rdf"); 
    try { 

      File file= new File("outputsmall.txt"); 
      model.getNsPrefixURI("http://www.geneontology.org/dtds/go.dtd#"); 
      model.write(new FileOutputStream(file), "N-Triples", "http://www.geneontology.org/dtds/go.dtd#"); 
     } catch (IOException e) { 
      e.printStackTrace(); 

가 어떻게이 경우 getNsPrefixURI() 사용합니까 나는 이런 식으로 뭔가를 얻을 수 있나요? 다른 방법을 사용해야합니까?

+1

n-triples 형식에는 iri 접두어가 없습니다. IRI는 항상 전체로 작성됩니다. –

답변

2

RDFDataMgr 및 RDFFormat.TURTLE_FLAT를 사용하여 RDF 데이터를 작성해보십시오. https://jena.apache.org/documentation/io/rdf-output.html

+0

감사합니다 AndyS, 이것이 정확히 무엇입니까? –

+0

@AriWijayanti 이것이 필요한 경우 [수락]합니다 (http://meta.stackexchange.com/q/5234/225437). –