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.

---
A. Soroka
The University of Virginia Library

On Aug 20, 2015, at 4:15 PM, kumar rohit <[email protected]> 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)

Reply via email to