j'ai crée une fonction de filter extension de sparql mais lors de l'éxécution de la requete n'affiche aucune résultat
ou est le prob ??
code de la fonction :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
import java.*;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.rdf.model.StmtIterator;
import org.apache.jena.sparql.expr.NodeValue;
import org.apache.jena.sparql.function.Function;
import org.apache.jena.sparql.function.FunctionBase2;
import org.apache.jena.sparql.function.FunctionFactory;
public  class haschild extends FunctionBase2 implements FunctionFactory{
    private Map _cache;
 
	public haschild()
	{
		_cache = new HashMap();
	}
 
 
 
    @Override
    public NodeValue exec(NodeValue v1, NodeValue v2) {
        String value = v2.asString();
       Model model = ModelFactory.createDefaultModel();
	InputStream is = null;
        try {
            is = new BufferedInputStream(
                    new FileInputStream( "C:\\fichier rdf/journal.webscience.org-vivo.rdf"));
        } catch (FileNotFoundException ex) {
            Logger.getLogger(haschild.class.getName()).log(Level.SEVERE, null, ex);
        }
	 model.read(new InputStreamReader(is), "");
 
 
	 StmtIterator it=model.listStatements();
	               while (it.hasNext()) {
	            Statement p=it.next();
 
	           Property prop = p.getPredicate(); 
	           Resource res2 = p.getSubject();
	           RDFNode node =p.getObject();
                     System.out.println(res2.toString());
 
   System.out.println(" " + prop.toString() + " ");
    System.out.println(" " + node.toString() + " ");
 
 
                             if((v1.toString().equals(res2.toString()))&&(node.toString().equals(value))&&(prop.toString().equals("http://www.w3.org/2000/01/rdf-schema#HasChild")))
                                /*return    (NodeValue) _cache.put(v1,true);*/
                             return NodeValue.TRUE;
 
 
                 return NodeValue.FALSE;
 
 
 
                       }
        return null;
 
    }
 
 
    @Override
    public Function create(String uri) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
 
 
	}
requete:
Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
SELECT *
 WHERE {?Person foaf:name ?x. FILTER(f:haschild(?Person,"Librarian")) }