Bonjour, je travaille avec protégé 3.4.8, je viens d'ajouter des nouveaux individus à mon ontologie. Voilà 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import com.hp.hpl.jena.iri.impl.Main;
import com.hp.hpl.jena.ontology.DatatypeProperty;
import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.util.FileManager;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.sparql.function.library.namespace;
import com.hp.hpl.jena.vocabulary.XSD;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
 
public class Updatee {
 OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF);
//     public static final String had="http://www.owl-ontologies.com/Ontology1336082009.owl#";
//     model.createOntology (namespace);
   public static final String NL      = System.getProperty("line.separator") ;
//   public static final String URIB="http://www.semanticweb.org/SEVEN7/ontologies/2012/2/Ontology1331977184905.owl#";
   public static final String had="http://www.owl-ontologies.com/Ontology1336082009.owl#";
 
   public void Insert() throws FileNotFoundException
   {  
 
 
 
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF); 
 
InputStream is = new BufferedInputStream(new FileInputStream("C://PPPP//PPPPCC.owl"));
OntModel ontology = ModelFactory.createOntologyModel();
model.read(is, "RDF/XML");
 
OntModel mod = ModelFactory.createOntologyModel();
 
OntClass Analyse_de_besoins = ontology.getOntClass("http://www.owl-ontologies.com/Ontology1336082009.owl#Analyse_de_besoins");
DatatypeProperty datededebut = ontology.getDatatypeProperty("http://www.owl-ontologies.com/Ontology1336082009.owl#datededebut");
DatatypeProperty datedefin = ontology.getDatatypeProperty("http://www.owl-ontologies.com/Ontology1336082009.owl#datedefin");
 
 
Individual Analyse_de_besoins_3 = mod.createIndividual("http://www.owl-ontologies.com/Ontology1336082009.owl#Analyse_de_besoins",Analyse_de_besoins);
// on peut éventuellement mettre un langageTag:
Literal n = mod.createLiteral("date de début");
Literal p = mod.createLiteral("date de fin");
 
//Literal p = mod.createLiteral("sefti"); // idem
 
 
mod.createStatement(Analyse_de_besoins_3,datededebut,n);
mod.createStatement(Analyse_de_besoins_3,datedefin,p);
 
 
 
 
 
 
 
 
}
 
 
 
 
 
 
 
 
    public static void main(String[]  args)throws Exception {
 
 Updatee ajout=new Updatee ();
 ajout.Insert();
 
 
 
    }
 
 
    }

Lorsque j'exécute le résultat est:

WARN [main] (RDFDefaultErrorHandler.java:49) - unknown-source: {W136} Relative URIs are not permitted in RDF: specifically <RDF/XML>
WARN [main] (RDFDefaultErrorHandler.java:49) - file:///C:/Documents%20and%20Settings/Administrateur/Mes%20documents/NetBeansProjects/JavaApplication6/RDF/XML(line 605 column 44): {W116} No primary language subtags of length greater than 3 are currently defined.
WARN [main] (RDFDefaultErrorHandler.java:49) - file:///C:/Documents%20and%20Settings/Administrateur/Mes%20documents/NetBeansProjects/JavaApplication6/RDF/XML(line 636 column 44): {W116} No primary language subtags of length greater than 3 are currently defined.
Exception in thread "main" java.lang.NullPointerException
at com.hp.hpl.jena.rdf.model.impl.StatementImpl.<init>(StatementImpl.java:43)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.createStatement(ModelCom.java:1310)
at Updatee.Insert(Updatee.java:58)
at Updatee.main(Updatee.java:80)
Java Result: 1
Je sais pas quel format accepte cette version de protégé.
Merci d'avance