wie man mit Java bestimmte tagbezogene Informationen aus einer RDF-Datei erhält

Ich benutze Jena, um eine RDF-Datei zu lesen, aber ich möchte die Informationen nur über bestimmte Aussagen erhalten. Unten ist mein Beispielcode zum Lesensample.rdf.

sample.rdf:

<rdf:Description rdf:about="http://d.opencalais.com/dochash-1/6ee25504-ff98-34e4-af60-dde69f5ddf73/Instance/143">
    <c:length>4</c:length>
    <c:offset>6588</c:offset>
    <c:suffix> network, specific mechanisms for implementing</c:suffix>
    <c:exact>VoIP</c:exact>
    <c:prefix>applications. Topics include imple-menting a 
   </c:prefix>
    <c:detection>[applications. Topics include imple-
menting a ]VoIP[ network, specific mechanisms for implementing]</c:detection>
    <c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/1bc26b65-5ef5-306d-9203-fd0f8aa3ba18"/>
    <c:docId rdf:resource="http://d.opencalais.com/dochash-1/6ee25504-ff98-34e4-af60-dde69f5ddf73"/>
    <rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/>
  </rdf:Description>

<rdf:Description rdf:about="http://d.opencalais.com/dochash-1/6ee25504-ff98-34e4-af60-dde69f5ddf73/SocialTag/10">
    <c:originalValue>Cisco IOS</c:originalValue>
    <c:importance>2</c:importance>
    <c:name>Cisco IOS</c:name>
    <c:socialtag rdf:resource="http://d.opencalais.com/genericHasher-1/8ed51994-de69-3307-acf7-be18cc0d06e2"/>
    <c:docId rdf:resource="http://d.opencalais.com/dochash-1/6ee25504-ff98-34e4-af60-dde69f5ddf73"/>
    <rdf:type rdf:resource="http://s.opencalais.com/1/type/tag/SocialTag"/>
  </rdf:Description>

Java-Code, der geladen wirdsample.rdf in ein Jenaer Modell:

public class FirstRDFReader extends Object {
   public static void main (String args[]) {
       String inputFile="C://Sample.rdf";
      Model model = ModelFactory.createDefaultModel();
   try{
   InputStream in =new  FileInputStream(inputFile);
    if (in == null) {  
     System.out.println("File not found");
     }  
     model.read(in," ");
    model.write(System.out);
}catch(Exception e){}
  }
}

Gewünschte Ausgabe:

<rdf:Description rdf:about="http://d.opencalais.com/dochash-1/6ee25504-ff98-34e4-af60-dde69f5ddf73/SocialTag/10">
<c:importance>2</c:importance>
 <c:name>Cisco IOS</c:name>
</rdf:Description>

Vielen Dank

Antworten auf die Frage(1)

Ihre Antwort auf die Frage