0

As shown in the title, I read owl file which is generated by Protege to Jena, modified it by adding some NamedIndividuals, and I wanted to read the modified file by Protege. Things went on well until I open this owl file with Protege. Protege just can not read it! I tried every "RDF/XML", "RDF/XML - ABBREV", "N - TRIPLE", "TTL", and still nothing.

One good news is that when I use "RDF/XML - ABBREV" and delete all the NamedIndividual I added, Protege works. But I want my Individuals!!!

public class Pizza00 {

public static void main(String[] args) throws IOException{
    String SOURCE = "http://www.seaice.com/ontologies/seaice.owl";
    String NS = SOURCE + "#";
    OntModel m = ModelFactory.createOntologyModel();

    try {
        m.read(new FileInputStream("G:/Protege/owl files/SeaIce.owl"), null);
    } catch (FileNotFoundException e1) {
        e1.printStackTrace();
    }

    reason rec = new reason();
    rec = readFileByLines("G:/data/seaice_property.txt");

    int i;
    OntClass tmp = m.getOntClass(NS + "SeaIceProperty");

    for(i = 1; i <= rec.line - 1; i ++){
        m.createIndividual(NS + rec.s[i], tmp);
    }
    m.write(System.out);

    OutputStream out = new FileOutputStream("G:/Protege/owl files/SeaIce - by jena.owl");
    m.write(out, "RDF/XML-ABBREV", null);
    out.close();
}
static class reason{
    String[] s= new String[1000];
    int line;
}
public static reason readFileByLines(String fileName) {
    File file = new File(fileName);
    BufferedReader reader = null;
    reason x = new reason();
    try {
        reader = new BufferedReader(new FileReader(file));
        String tempString = null;
        // 一次读入一行,直到读入null为文件结束
        while ((tempString = reader.readLine()) != null) {
            // 显示行号
            x.s[x.line] = tempString;
            x.line++;
        }
        reader.close();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException e1) {
            }
        }
    }
    return x;
}

}

  • this line error occurs. – Julyana Lin Apr 11 '14 at 09:23
  • And the error by Protege is org.semanticweb.owlapi.rdf.syntax.RDFParserException: [line=30:column=101] IRI 'http://www.seaice.com/ontologies/seaice.owl#Optical Band Imagery' cannot be resolved against curent base IRI file:/G:/Protege/owl%20files/SeaIce%20-%20by%20jena.owl – Julyana Lin Apr 11 '14 at 09:28

1 Answers1

0

As you mention in the comments, the error is

this line <j.0:SeaIceProperty rdf:about="seaice.com/ontologies/seaice.owl#Optical Band Imagery"/> error occurs.

And the error by Protege is org.semanticweb.owlapi.rdf.syntax.RDFParserException: [line=30:column=101] IRI 'seaice.com/ontologies/seaice.owl#Optical Band Imagery' cannot be resolved against curent base IRI file:/G:/Protege/owl%20files/SeaIce%20-%20by%20jena.owl

The not-quite IRI seaice.com/ontologies/seaice.owl#Optical Band Imagery is relative, and can't be resolved against the current base IRI, which is a file IRI: file:/G:/Protege/owl%20files/SeaIce%20-%20by%20jena.owl. The easiest way to fix this is to use absolute IRIs when you are creating your named individuals.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Thank u very much for your kind help. I've seen you answering lots of Protege and Jena Questions, and I guess you must be efficient in them. – Julyana Lin Apr 17 '14 at 02:52
  • I did as you suggested, but it did't work. It turns out that the cause is the name of my Individuals contains spaces. – Julyana Lin Apr 17 '14 at 02:53