That is not the error in the query I pointed out. It makes a difference
in the query.
On 09/01/17 15:45, javed khan wrote:
I used std:Englishscore in my query and is also in my ontology. If I wrote
somewhere EnglishScore, it will be a typo error.
On Mon, Jan 9, 2017 at 6:41 PM, Andy Seaborne <[email protected]> wrote:
On 09/01/17 15:05, javed khan wrote:
Hello Lorenz, I think the problem is in the query itself inside Jena
code(probably the syntax of the query). Because a very simple query
like *?student
std:EnglishScore ?score*
works.
The querystring is:
prefix std:<http://www.semanticweb.org/ontologies#>PREFIX rdfs:<
http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf:<
http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE { {select (max(?score) as ?highScore) { ?student
std:Englishscore ?score } } ?student std:Englishsscore ?highScore}
std:Englishscore vs std:Englishsscore
spelt differently.
On Mon, Jan 9, 2017 at 5:40 PM, Lorenz Buehmann <
[email protected]> wrote:
Inline images are not allowed here, thus we can't see anything. And a
screenshot of Protege is not really helpful.
Prefixes might be wrong. We neither know the final query, nor your code.
Please show a sample of the data in best case in Turtle format. And the
final query - please not again as Java concatenated String but as the
output from System.out.println(query2)
On 09.01.2017 15:06, javed khan wrote:
Inline image 1
It shows the result in Protege: Mac is student name and 6 is highscore
of English category scored by him.
On Mon, Jan 9, 2017 at 4:34 PM, Andy Seaborne <[email protected]
<mailto:[email protected]>> wrote:
Maybe there are no results.
This is not a complete, minimal example. Unseen details probably
matter.
Andy
On 09/01/17 13:28, javed khan wrote:
Hello Lorenz, yes I need student and highscore.
I just tried this , no exception but it does not display the
message in
JOptionPane.showMessageDialog()
Query query2 = QueryFactory.create(queryString2);
QueryExecution qexec = QueryExecutionFactory.create(query2,
model) ;
ResultSet results2 = qexec.execSelect() ;
RDFNode r;
while(results2.hasNext()){
QuerySolution sol= results2.nextSolution();
r=sol.get("student");
JOptionPane.showMessageDialog(null,"high score is" + r
);
}
On Mon, Jan 9, 2017 at 1:42 PM, Lorenz Buehmann <
[email protected]
<mailto:[email protected]>> wrote:
@ As per the previous discussion, I guess he also wants to
have the
student - and of course the highest score,
As Chris said, you have to distinguish between literals
and URIs/blank
nodes.
Which finally leads me to the suggestion to read an RDF
tutorial +
SPARQL tutorial first. Most questions are really basic.
On 09.01.2017 09:38, Chris Dollin wrote:
On 08/01/17 18:32, javed khan wrote:
This query gives me exception:
Exception in thread "AWT-EventQueue-0"
com.hp.hpl.jena.rdf.model.LiteralRequiredException:
http://www.semanticweb.org/t/ontologies#Smith
<http://www.semanticweb.org/t/ontologies#Smith>
"SELECT * " +
" WHERE {" + " {"+ "select
(max(?score) as
?highScore)"
+ " { ?student std:Englishscore ?score" +
" }" +
" } " +
"?student std:Englishscore ?highScore" +
"}";
The variable ?subject will be the subject of a triple.
Subjects may be blank nodes or resources with URIs.
Query query2 =
QueryFactory.create(queryString2);
QueryExecution qexec =
QueryExecutionFactory.create(query2, model) ;
ResultSet results2 = qexec.execSelect() ;
Literal
l2=results2.next().get("student").asLiteral();
get("student") will return the value of "student",
which will
be a resource or blank node, but NOT a literal.
asLiteral
expects a Literal.
BOOM.
My pre-caffeine guess is that you want "highscore" not
"student".
As others have said, offer complete minimal examples.
Chris