>> The prefixes are Ok because for simple queries (without Filter), it works.

So with

SELECT  *  WHERE { ?s rdf:type mo:Book.?s mo:BookCategory ?book }

you get something?  what?


If you do then ?book is not equal to (i.e. exactly) the string 'Semantic Web'.

In your original email, you had:

   ?book ='str'

(It is easy to run out of date code.)

    Andy


On 03/07/17 12:34, Sidra shah wrote:
I am giving the code after query, may be the problem exist in these lines.

   Query query = QueryFactory.create(str);
QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
ResultSet results = qexec.execSelect() ;
         while (results.hasNext())
{
QuerySolution binding = results.nextSolution();
Resource subj = (Resource) binding.get("s");
                 ss= subj.getLocalName().toString();

             System.out.println(ss);

On Mon, Jul 3, 2017 at 2:12 PM, Sidra shah <[email protected]> wrote:

Hello Lorenz, BookCategory is a data property whose value is string (Java
or Semantic Web).

The print out of the query is given:

PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX mo:<http://www.semanticweb.org/ontologies/2017/5/
untitled-ontology-758#>
  SELECT  *  WHERE { ?s rdf:type mo:Book.?s mo:BookCategory ?book.
FILTER ( ?book ='Semantic Web' ). }

The prefixes are Ok because for simple queries (without Filter), it works.

On Mon, Jul 3, 2017 at 11:12 AM, Lorenz Buehmann <[email protected]
leipzig.de> wrote:

Is it Java code?

Print the query string that is created.

Check the prefixes.

Make sure that you properly distinguish between literals and URIs -> is
a book category a literal or a resource? Is the value of str a URI or a
literal?


On 03.07.2017 07:12, Sidra shah wrote:
Hello

I have a Book class having Java and Semantic Web sub classes.
Java class have some instances: JSP, Java by Dietel, JDBC
Semantic Web has also some instances: SPARQL, Semantic Programming, etc.

I have a data property BookCategory for each instance which will be
either
Java or Semantic Web

I have a combo box where users if select Java, all java books will be
displayed and similarly for semantic web.

The following query does not work. (Display nothing)

  String str=jComboBox1.getSelectedItem().toString();

SELECT  *  WHERE { ?s rdf:type mo:Book.?s mo:BookCategory ?book FILTER (
?book ='str' ). }





Reply via email to