Précédent   Forum du club des développeurs et IT Pro > Webmasters - Développement Web > Web sémantique > SPARQL
SPARQL Forum d'entraide sur SPARQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 11/04/2012, 02h02   #1
lilyou
Nouveau Membre du Club
 
Femme lylia
Inscription : mars 2012
Messages : 43
Détails du profil
Informations personnelles :
Nom : Femme lylia
Localisation : France

Informations forums :
Inscription : mars 2012
Messages : 43
Points : 25
Points : 25
Mon ontologie est sous format RDF. Je veux extraire les données avec SPARQL mais ça m'affiche en bas Null lors de l'exécution avant BUILDSUCC...
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
try
   {  String URI="http://www.semanticweb.org/ontologies/2012/3/untitled-ontology-59";
       OntModel model = ModelFactory.createOntologyModel(); 
       InputStream is = new BufferedInputStream(new FileInputStream("C:\\Users\\SEVEN7\\Desktop\\ontology.owl"));
       model.read(is,URI);
 
 
   model.write(System.out);     
    FileOutputStream fichierSortie = null ;
    model.read(is,URI);
    ontClass A=model.getOntClass(URI+"#chercheur");
	   DatatypeProperty nom= model.getDatatypeProperty(URI+"#Nom");
    is.close();
 
                String rdfPrefix   = "PREFIX rdf: <"+RDF.getURI()+">" ;
                String myOntologyPrefix = "PREFIX "+myOntologyName+": <"+URI+">" ;
 
 
                // Construction de la requete
                String queryString =   myOntologyPrefix +rdfPrefix +
                    "SELECT ?nom ?adresse " +
	           "WHERE {" + "?individu  rdf:type untitled-ontology-59 ?nom. " + " ?individu rdf:type untitled-ontology-59 ?prenom."+
	                             "}";
 
       // Affichage de la requete sur la sortie standard.
                Query query = QueryFactory.create(queryString);
 
                System.out.println() ;
 
                 QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
 
                // Execution de la requete 
                        ResultSet rs = qexec.execSelect() ;
 
                        // Affichage des resultats
                        for ( ; rs.hasNext() ; ){
                                QuerySolution rb = rs.nextSolution() ;
                                RDFNode y = rb.get("individu");
                                System.out.print("uri : "+y+"--- ");
                                Resource z = (Resource) rb.getResource("individu");
                                System.out.println("plus simplement "+z.getLocalName());
                        }
 
 
                //sérialiser l'ontology
 
try {
    fichierSortie = new FileOutputStream (new File ("C:\\Users\\SEVEN7\\Desktop\\ontology.owl"));
}
catch (FileNotFoundException ex)
{
Logger.getLogger (Main.class.getName ()).log (Level.SEVERE, null, ex);
}
model.write (fichierSortie);
 
} // fin du try final 
catch (Exception e){System.out.print(e.getCause());}
 
 
  } 
 
   }
Ca doit générer un résultat car mon ontology contient des individus. Ca ne peut pas être null. Merci de m'aider.

ou bien quelquin connait un bon lien pour me guider merci
lilyou est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 10h44.


 
 
 
 
Partenaires

Hébergement Web