Sparql substract实例

时间:2012-10-10 10:35:52

标签: sparql ontology

我有一个选集,我创建了一个评估界面或者有一个提交按钮。这个按钮允许你计算旧值和值20之间的差异。我尝试用sparql选择一个实例,我会评估一个实例用值20减去旧值。

valider.addActionListener(new ActionListener()
    {
        public void actionPerformed(ActionEvent e)
        {
            Model m=ModelFactory.createMemModelMaker().createModel(null);
            FileManager.get().readModel( m, owlFile );
            String myOntologyName = "ProjetHela";
            String uri="file:///C:/Project/Krs1.owl";
            // Définition de prefixe pour simplifier l'utilisation de SPARQL
            String reuses = "maj: <"+RDF.getURI()+">" ;
            // String myOntologyPrefix = "PREFIX "+myOntologyName+": <"+myOntologyNS+">" ;
            String myOntologyPrefix = "PREFIX "+myOntologyName+": <"+uri+">" ;
            // if (liste.getSelectedItem().toString().equals("GMP: Puissance=60352 Watt,limite supérieure= 73500 Watt")) {
            String queryString= 
                "PREFIX maj: <http://www.owl-ontologies.com/reuses.owl#>"
                + "SELECT ?hasnameevaluated"
                + " WHERE "
                + "{"
                + "?Besoin maj:hasnameevaluated ?hasnameevaluated "
                +"FILTER (?hasnameevaluated - 20)  "
                + " } ";
            Query query = QueryFactory.create(queryString) ;

            QueryExecution qexec = QueryExecutionFactory.create(query, m) ;
            try  {
                ResultSet rs = qexec.execSelect() ;

                // Affichage des resultats
                for ( ; rs.hasNext() ; ){
                //System.out.print("");
                QuerySolution rb = rs.nextSolution() ;
                String y = rb.getLiteral("hasnameevaluated").getString();
                System.out.println( " " + y);
                }}  finally {
                    qexec.close() ;

                    }
                }   
            }


    );

但它不起作用 请帮帮我

1 个答案:

答案 0 :(得分:0)

  

FILTER(?hasnameevaluated - 20)

是测试,而不是值的赋值。

您的意思是使用:

  

BIND(?hasnameevaluated - 20 AS?newvalue)

  

SELECT?hasnameevaluated(?hasnameevaluated - 20 AS?newvalue)WHERE