在耶拿

时间:2019-06-02 14:09:21

标签: sparql jena

我想在查询中添加MINUS过滤器,但是当我添加查询时,它根本不会执行,但是当我删除MINUS过滤器时,查询将正常执行。

这是我使用减号时的代码:

Query sparql = QueryFactory.create("PREFIX sosa: <http://www.w3.org/ns/sosa/>\r\n" + 
                "PREFIX owl: <http://www.w3.org/2002/07/owl#>\r\n" + 
                "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
                "SELECT ?s ?c ?p ?o FROM <http://147.27.60.65/sensorOntology> WHERE {?s rdf:type owl:NamedIndividual.\r\n" + 
                "?p rdf:type owl:ObjectProperty.\r\n" + 
                "?c rdf:type owl:Class.\r\n" + 
                "?s rdf:type ?c.\r\n" +
                "?s ?p ?o\r\n" + 
                "MINUS {?s rdf:type owl:Thing}\r\n" + 
                "}");
QueryExecution vqe = QueryExecutionFactory.create(sparql, inf);

这是我不使用减号时正确执行的代码:

Query sparql = QueryFactory.create("PREFIX sosa: <http://www.w3.org/ns/sosa/>\r\n" + 
                "PREFIX owl: <http://www.w3.org/2002/07/owl#>\r\n" + 
                "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
                "SELECT ?s ?c ?p ?o FROM <http://147.27.60.65/sensorOntology> WHERE {?s rdf:type owl:NamedIndividual.\r\n" + 
                "?p rdf:type owl:ObjectProperty.\r\n" + 
                "?c rdf:type owl:Class.\r\n" + 
                "?s rdf:type ?c.\r\n" +
                "?s ?p ?o}");
         QueryExecution vqe = QueryExecutionFactory.create(sparql, inf);

语法是否有问题?也许我查询的是InfModel类型吗?

0 个答案:

没有答案