Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 遇到Sparql词法错误:“”(32),在“not”之后_Java_Rdf_Sparql_Jena - Fatal编程技术网

Java 遇到Sparql词法错误:“”(32),在“not”之后

Java 遇到Sparql词法错误:“”(32),在“not”之后,java,rdf,sparql,jena,Java,Rdf,Sparql,Jena,使用Jena创建sparql查询时出现词法错误。 下面是我的源代码。错误是 com.hp.hpl.jena.query.QueryParseException:第5行第92列出现词法错误。遇到:32,在:not之后 package mas; import agent.core.onto.Ontology; import com.hp.hpl.jena.ontology.OntDocumentManager; import com.hp.hpl.jena.ontol

使用Jena创建sparql查询时出现词法错误。 下面是我的源代码。错误是 com.hp.hpl.jena.query.QueryParseException:第5行第92列出现词法错误。遇到:32,在:not之后

    package mas;
    import agent.core.onto.Ontology;
    import com.hp.hpl.jena.ontology.OntDocumentManager;
    import com.hp.hpl.jena.ontology.OntModel;
    import com.hp.hpl.jena.ontology.OntModelSpec;
    import com.hp.hpl.jena.query.Query;
    import com.hp.hpl.jena.query.QueryExecution;
    import com.hp.hpl.jena.query.QueryExecutionFactory;
    import com.hp.hpl.jena.query.QueryFactory;
    import com.hp.hpl.jena.query.QuerySolution;
    import com.hp.hpl.jena.query.ResultSet;
    import com.hp.hpl.jena.rdf.model.Model;
    import com.hp.hpl.jena.rdf.model.ModelFactory;
    import com.hp.hpl.jena.rdf.model.ModelMaker;
    import java.io.FileInputStream;

    /**
    *
    * @author Naveed Khan
    */
    public class NewClass {

      public static void main(String arg[])
       {
        NewClass obj=new NewClass(); 
        String PREFIX="PREFIX seo:            <http://www.seontology.org/test/specificOnto.owl#> 
       PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
       PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
        Model m = obj.getModel();
        String querystr=PREFIX + 
                " \n SELECT  ?individualaff ?uc "
                        + "WHERE { "
                        + "?individualaff  seo:Requirements_Content ?c. "
                        + "filter not exists {?individualaff seo:hasUsecase ?uc } "
                        + "}";
        try 
        {
            Query query = QueryFactory.create(querystr) ;
            QueryExecution qexec = QueryExecutionFactory.create(query, m) ;
            ResultSet results = qexec.execSelect() ;
            QuerySolution soln = results.nextSolution() ;
        }catch(Exception ex) { 
         ex.printStackTrace(); }



}
private OntModel getModel()
{
    OntModel model = null;
    if (model == null) {

    model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
    try {

        model.read(new FileInputStream(agent.core.onto.Config.SOURCE_FILE), Ontology.BASE);

    } catch (Exception e) {
        System.out.println("Loading Model failed:"+ e);
    }
  } 
        if (model != null)
          return model;
        else
          return null;
        }
        }

The error says
com.hp.hpl.jena.query.QueryParseException: Lexical error at line 5, column 92.     Encountered: " " (32), after : "not".

实际查询:选择?fr?uc,其中{?fr seo:Requirements_Content?c.过滤器不存在{?fr seo:hausecase?uc}对我有效。您使用的是哪种版本的jena?谢谢,我通过获取最新版本的jenaget和最新版本的Jena2.0.13解决了这个问题,并且对于FILTER?location=dbpedia:葡萄牙或?location=dbpedia:Spain-第1行第261列的词法错误有相同的错误。遇到:32,之后:或