Then I think you must have changed your code. The original code does not show any space between the “?y” and the “WHERE” - which was the cause of the problem. However, you now have a space there.
Is this code still generating the error message about "”xWHERE"? Andy D ——————————————————— On 21 Aug 2015, at 10:29, kumar rohit <kumar.en...@gmail.com> wrote: I did with System.out.print(querystring) and the output is: PREFIX ss:<http://www.semanticweb.org>SELECT ?y WHERE { ?y ss:hasson ss:zia } On Fri, Aug 21, 2015 at 9:59 AM, Lorenz Bühmann < buehm...@informatik.uni-leipzig.de> wrote: > Hello Kumar, > > why don't you print the query string in Java first to the console using > System.out.println(queryString); ? Then you will see how your concatenated > string looks like and that there is a missing space after ?y resp. before > WHERE. > > Kind regards, > Lorenz > > Thank you the syntax error removes but it gives me error "xWHERE".. I know >> very minor mistake but not sure where it is. >> >> __________________________________________________________________________ >> *String querystring="PREFIX ss:<http://www.semanticweb.org >> <http://www.semanticweb.org>>" +"SELECT ?y" +* >> * "WHERE {" + " ?y ss:hasson ss:zia " + "}";* >> >> >> ___________________________________________________________________________ >> >> On Thu, Aug 20, 2015 at 9:48 PM, Andy Seaborne <a...@apache.org> wrote: >> >> On 20/08/15 21:19, aj...@virginia.edu wrote: >>> >>> This may or may not be the entire problem, but in the line: >>>> >>>> String querystring="PREFIX ss:<http://www.semanticweb.org" +"SELECT ?x" >>>> >>>>> + "WHERE {" + "?x ss:hasson ss:zia" + "}"; >>>>> >>>>> you opened the angle-brackets around your namespace without closing >>>> them. >>>> >>>> Exactly. >>> >>> Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: >>>>> Encountered " "<" "< "" at line 1, column 11. >>>>> >>>> >>> Put some newlines into the string! >>> >>> ... and then the next error is at "SELECT ?x" + "WHERE whch is >>> "SELECT ?xWHERE {" >>> >>> i.e a variable called "xWHERE" >>> >>> >>> >>> --- >>>> A. Soroka >>>> The University of Virginia Library >>>> >>>> On Aug 20, 2015, at 4:15 PM, kumar rohit <kumar.en...@gmail.com> wrote: >>>> >>>> import java.io.InputStream; >>>> >>>>> 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.ResultSet; >>>>> import com.hp.hpl.jena.query.ResultSetFormatter; >>>>> import com.hp.hpl.jena.rdf.model.ModelFactory; >>>>> import com.hp.hpl.jena.util.FileManager; >>>>> >>>>> >>>>> public class famtree { >>>>> static final String inputfile =("C://Users//asad >>>>> ali//Desktop//Project//protege//relation.owl"); >>>>> >>>>> public static void main(String[] args) { >>>>> OntDocumentManager mgr=new OntDocumentManager(); >>>>> >>>>> OntModelSpec spec=new OntModelSpec(OntModelSpec.OWL_DL_MEM); >>>>> >>>>> spec.setDocumentManager(mgr); >>>>> >>>>> OntModel m = ModelFactory.createOntologyModel(spec,null); >>>>> >>>>> InputStream in=FileManager.get().open(inputfile); >>>>> if (in==null) >>>>> { >>>>> throw new IllegalArgumentException("File" + inputfile + "not found"); >>>>> } >>>>> m.read(in,""); >>>>> >>>>> String querystring="PREFIX ss:<http://www.semanticweb.org" +"SELECT >>>>> ?x" >>>>> + >>>>> "WHERE {" + "?x ss:hasson ss:zia" + "}"; >>>>> >>>>> Query query=QueryFactory.create(querystring); >>>>> >>>>> QueryExecution qe = QueryExecutionFactory.create(query, m); >>>>> >>>>> ResultSet results = qe.execSelect(); >>>>> >>>>> ResultSetFormatter.out(System.out, results, query); >>>>> >>>>> qe.close(); >>>>> } >>>>> } >>>>> >>>>> The following error displays in Eclipse >>>>> ___________________________________ >>>>> >>>>> Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: >>>>> Encountered " "<" "< "" at line 1, column 11. >>>>> Was expecting: >>>>> <IRIref> ... >>>>> >>>>> at >>>>> >>>>> >>>>> com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:102) >>>>> at >>>>> >>>>> com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53) >>>>> at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34) >>>>> at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148) >>>>> at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80) >>>>> at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53) >>>>> at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41) >>>>> at familytree.famtree.main(famtree.java:37) >>>>> >>>>> >>>> -- > Lorenz Bühmann > AKSW group, University of Leipzig > Group: http://aksw.org - semantic web research center > >