Ich habe diesen Code in package oopn.ontology
Last owl Datei Java-Code unter Verwendung von jena api
public class Ontology {
private static Ontology ontology = new Ontology();
public static OntModel ontologyModel; //this is the main of Ontology model
public static File ontologyFile; //this is the file of owl
public static String ontologyFilePath; //this is the path of owl file
public static JTree ontologyModelTree;
public static int saveAction;
public static String copiedText;
public static JTree tree;
private Ontology() {
}
public static Ontology getInstance() {
return ontology;
}
public void resetOntology() {
ontologyModel = null;
ontologyFile = null;
ontologyFilePath = null;
ontologyModelTree = null;
}
diesen Code dann Ontologie-Modell zu erstellen:
public OntModel createOntologyModelFromFile(String owlFile) {
InputStream in;
in = FileManager.get().open(owlFile);
OntModel model1 = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
OntModel model2 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
model1.read(in, "");
ontologyModel = model1;
return model1;
}
Datei zu öffnen Ich habe diese ein:
File openOntologyFile() {
JFileChooser fileChooser;
File chosenFile;
fileChooser = new JFileChooser(new File("mpasi.owl"));
fileChooser.showOpenDialog(fileChooser);
chosenFile = fileChooser.getSelectedFile();
if (chosenFile != null) {
//loadOntologyFile(chosenFile);
} else {
JOptionPane.showMessageDialog(fileChooser, this);
}
//enableControls(true);
Ontology.ontologyFilePath = chosenFile.getAbsolutePath();
return chosenFile;
}
In Hauptklasse dieses:
public class Dss_mpasi extends javax.swing.JFrame {
JFileChooser fileDialog;
public Dss_mpasi() {
initComponents();
if (Ontology.ontologyFile != null) {
Model tempModel ;
if (Ontology.ontologyModel == null) {
tempModel = Ontology.getInstance().createOntologyModelFromFile(Ontology.ontologyFilePath);
} else {
tempModel = Ontology.ontologyModel;
}
StringWriter writer = new StringWriter();
tempModel.write(writer, "RDF/XML");
}
}
aber es funktioniert immer noch nicht ... Ich hoffe, jemand kann mir helfen, damit es funktioniert?
und was genau ist das Problem/Fehler, die Sie bekommen? – Shiva
aaah ... es kann immer noch nicht meine Eulen-Datei laden ... – user3805222
Können Sie die Eulen-Datei immer noch nicht laden? Sehen Sie meine Antwort und lassen Sie mich wissen, ob das Problem weiterhin besteht. – ishmaelMakitla