try{
q = q.replace("<","<").replace(">",">").replace(" WHERE","\nWHERE").replace(" SELECT","\nSELECT").replace(" FROM","\nFROM").replace(" PREFIX","\nPREFIX").replace("{ ","{\n").replace(". ",".\n\t").replace("; ",";\n\t\t");
OntModel ontModel = Util.getOntModel();
ResultSet rs = Util.executeSparqlQuery(ontModel ,q);
ResultSetFormatter rsf = new ResultSetFormatter();
result = rsf.asXMLString(rs);
//result = Integer.toString(rs.getRowNumber()) ;
result = result.replace("<","<").replace(">",">");
}catch (Exception ex){
result = "<font color=\"red\">" + ex.getMessage() + "</font>";