I have (almost) the same problem as here. But I couldn't figure out how to apply it to my problem. I want to convert a SPARQL query to its algebra expression. So the example code:
Query query = QueryFactory.create(args[0]);
Op op = Algebra.compile(query) ;
System.out.println(op);
However, as Joshua said: Virtuoso accepts non-standard SPARQL and Jena does not.. error is:
Exception in thread "main" org.apache.jena.query.QueryParseException: Encountered " "<" "< "" at line 1, column 14.
manually correcting the query isn't really a solution, as I want to do this with a few hundred queries... Thanks for your help
EDIT:
sample query:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE
{
{?city rdfs:label 'Tapiramutá'@en.}
UNION
{ ?alias <http://dbpedia.org/property/redirect> ?city;
rdfs:label 'Tapiramutá'@en. }
UNION
{?alias <http://dbpedia.org/property/disambiguates> ?city;
rdfs:label 'Tapiramutá'@en. }
OPTIONAL { ?city <http://dbpedia.org/ontology/abstract> ?abstract}
OPTIONAL { ?city geo:lat ?latitude; geo:long ?longitude}
OPTIONAL { ?city foaf:depiction ?image }
OPTIONAL { ?city rdfs:label ?name }
OPTIONAL { ?city foaf:homepage ?home }
OPTIONAL { ?city <http://dbpedia.org/ontology/populationTotal> ?population }
OPTIONAL { ?city <http://dbpedia.org/ontology/thumbnail> ?thumbnail } FILTER (langMatches( lang(?abstract), 'en'))}