Stocker des triplets et les afficher
Salut,
Je suis en train de faire la création de mon magasin de triplets qui contient mon ontologie puis de faire son affichage. Mais j'ai eu des erreurs dans mon code.
Voila le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
//On crée un modèle Jena de données TDB dans un répertoire nommé
String directory = "mydatabase/bd" ;
Model model = TDBFactory.createModel(directory);
Model modelTemp = null;
String inputFileName = "dir/onto";
InputStream file = FileManager.get().open(inputFileName );
if (file == null) {
throw new IllegalArgumentException("File: " + inputFileName
+ " not found");
}
model.read(file, "", "RDF/XML");
// write it to standard out
model.write(System.out);
//On lit le modele rdf existant (lors de la premiere utilisation)
System.out.println("affichage de l'ontologie:");
Iterator stmtIter = modelTemp.listStatements();
while(stmtIter.hasNext()){
Statement stmt = (Statement) stmtIter.next();
//System.out.println(stmt);
model.add(stmt);
}
model.close();
//Récupération du modèle
Dataset dataset = TDBFactory.createDataset("mydatabase/bd") ;
Model m2=dataset.getDefaultModel();
System.out.println("Liste de l'ontologie :");
Iterator classIter = m2.listObjects();
while(classIter.hasNext()){
Object rdfn = (Object) classIter.next();
System.out.println(rdfn);
}
} |
Et voila l'erreur :
Citation:
Exception in thread "main" java.util.NoSuchElementException
at org.openjena.riot.tokens.TokenizerText.next(TokenizerText.java:90)
at com.hp.hpl.jena.tdb.nodetable.NodecSSE.decode(NodecSSE.java:91)
at com.hp.hpl.jena.tdb.lib.NodeLib.decode(NodeLib.java:89)
at com.hp.hpl.jena.tdb.lib.NodeLib.fetchDecode(NodeLib.java:71)
at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.readNodeByNodeId(NodeTableNative.java:158)
at com.hp.hpl.jena.tdb.nodetable.NodeTableNative._retrieveNodeByNodeId(NodeTableNative.java:85)
at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.getNodeForNodeId(NodeTableNative.java:58)
at com.hp.hpl.jena.tdb.nodetable.NodeTableWrapper.getNodeForNodeId(NodeTableWrapper.java:44)
at com.hp.hpl.jena.tdb.nodetable.NodeTableInline.getNodeForNodeId(NodeTableInline.java:55)
at com.hp.hpl.jena.tdb.lib.TupleLib.tupleNodes(TupleLib.java:86)
at com.hp.hpl.jena.tdb.lib.TupleLib$1.convert(TupleLib.java:40)
at com.hp.hpl.jena.tdb.lib.TupleLib$1.convert(TupleLib.java:36)
at org.openjena.atlas.iterator.Iter$4.next(Iter.java:267)
at com.hp.hpl.jena.tdb.sys.ConcurrencyPolicyMRSW$IteratorCheckNotConcurrent.next(ConcurrencyPolicyMRSW.java:113)
at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.readPrefixMap(DatasetPrefixesTDB.java:157)
at com.hp.hpl.jena.sparql.graph.GraphPrefixesProjection.getNsPrefixMap(GraphPrefixesProjection.java:51)
at com.hp.hpl.jena.shared.impl.PrefixMappingImpl.setNsPrefixes(PrefixMappingImpl.java:100)
at com.hp.hpl.jena.graph.compose.Dyadic.<init>(Dyadic.java:31)
at com.hp.hpl.jena.graph.compose.DisjointUnion.<init>(DisjointUnion.java:24)
at com.hp.hpl.jena.rdf.model.impl.ModelReifier.withHiddenStatements(ModelReifier.java:57)
at com.hp.hpl.jena.rdf.model.ModelFactory.withHiddenStatements(ModelFactory.java:130)
at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:468)
at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:458)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.write(ModelCom.java:271)
at jena.com.test.TestOnto.main(TestOnto.java:62)
C'est quoi ce problème et comment je peux le résoudre ?
Merci d'avance.