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 <[email protected]> wrote:

> On 20/08/15 21:19, [email protected] 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 <[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