asmaasmichou
Messages postés4Date d'inscriptionmardi 17 avril 2012StatutMembreDernière intervention25 avril 2012
-
25 avril 2012 à 15:17
michelatoutfox
Messages postés828Date d'inscriptionmardi 5 octobre 2004StatutMembreDernière intervention 7 mai 2013
-
25 avril 2012 à 16:49
slt tt le monde, je veut ajouter des individu(individuals+datatype)qui se trouve dans une base de donnè a une ontologie crèè dans protègè2000 voila le code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sara;
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.vocabulary.XSD;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
/**
*
* @author PC
*/
public class Sara {
/**
* @param args the command line arguments
*/
public void connect() throws FileNotFoundException
{
// TODO code application logic here
InputStream is = new BufferedInputStream(new FileInputStream("C://Documents and Settings//PC//Bureau//uml nutrition//Nutrition.owl"));
OntModel ontology = ModelFactory.createOntologyModel();
// si le fichier n'est pas enregistré en RDF/XML, changer le paramètre
ontology.read(is, "RDF/XML");
// on va mettre les données dans un autre modèle Jena
OntModel mod = ModelFactory.createOntologyModel();
OntClass Fruit1Class = ontology.getOntClass("http://www.owl-ontologies.com/Nutrition.owl#Fruit1");
DatatypeProperty typeprop = ontology.getDatatypeProperty("http://www.owl-ontologies.com/Nutrition.owl#type");
/*
Gestion des données soumises par l'intermédiaire de l'interface
*/
Individual c = mod.createIndividual("http://www.owl-ontologies.com/Nutrition.owl#Fruit1",Fruit1Class);
// on peut éventuellement mettre un langageTag:
Literal n = mod.createLiteral("type");
mod.createStatement(c,typeprop,n);
}
public static void main(String[] args)throws Exception {
Sara a=new Sara ();
a.connect();
}
}
et voila l'erreur:
run:
WARN [main] (RDFDefaultErrorHandler.java:49) - unknown-source: {W136} Relative URIs are not permitted in RDF: specifically <RDF/XML>
BUILD SUCCESSFUL (total time: 1 second)
svp aidé moi merci bcp