I'm querying an OWL ontology using SPARQL, but the results show links as well as data. I only want the data. How can I remove the link and show on the data? The output I'm getting is:
---------------------------------------------------------------------------------------------------------------------------
| Email | ind | ind1 |
===========================================================================================================================
| "5"^^<http://www.w3.org/2001/XMLSchema#decimal> | my:HotelCityPark | "Hotel"^^<http://www.w3.org/2001/XMLSchema#string> |
---------------------------------------------------------------------------------------------------------------------------
The output I desire is (note that parts like ^^<http://www.w3.org/2001/XMLSchema#decimal>
are no longer present.
---------------------------------
| Email | ind | ind1 |
=================================
| 5 | HotelCityPark | Hotel |
---------------------------------
Here is my Java code and my OWL ontology:
class jena_testing
{ public static void main(String[] args) {
String filename="modified2.owl";
Model model=ModelFactory.createDefaultModel();
OntModel model1=ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM,model);
try
{
File file=new File(filename);
FileInputStream reader=new FileInputStream(file);
model.read(reader,null);
String query1="PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
"PREFIX my: <http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#>"+
"SELECT ?Email ?ind ?ind1"+
" WHERE {"+
" ?ind rdf:type my:Accomodation ."+
"?ind my:hasStarRating ?Email."+
"?ind my:hasType ?ind1."+
"FILTER regex(str(?ind),'HotelCityPark')"+
"}";
com.hp.hpl.jena.query.Query query=QueryFactory.create(query1);
QueryExecution exe=QueryExecutionFactory.create(query, model1);
ResultSet RES=exe.execSelect();
ResultSetFormatter.out(System.out, RES, query);
}catch(Exception e)
{
e.printStackTrace();
}
}
}
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY untitled-ontology-20 "http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#"
xml:base="http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:untitled-ontology-20="http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#">
<owl:Ontology rdf:about="http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#hasLatitude -->
<owl:DatatypeProperty rdf:about="&untitled-ontology-20;hasLatitude"/>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#hasLongitude -->
<owl:DatatypeProperty rdf:about="&untitled-ontology-20;hasLongitude"/>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#hasStarRating -->
<owl:DatatypeProperty rdf:about="&untitled-ontology-20;hasStarRating"/>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#hasStreet -->
<owl:DatatypeProperty rdf:about="&untitled-ontology-20;hasStreet"/>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#hasType -->
<owl:DatatypeProperty rdf:about="&untitled-ontology-20;hasType"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Accomodation -->
<owl:Class rdf:about="&untitled-ontology-20;Accomodation"/>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Attractions -->
<owl:Class rdf:about="&untitled-ontology-20;Attractions"/>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Restuarants -->
<owl:Class rdf:about="&untitled-ontology-20;Restuarants"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#AkkalkotSwamiSamarthMaharaj_temple -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;AkkalkotSwamiSamarthMaharaj_temple">
<rdf:type rdf:resource="&untitled-ontology-20;Attractions"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Ambassador_Executive -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Ambassador_Executive">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">3</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#BalajiSarovarPremier -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;BalajiSarovarPremier">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">3.5</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#BhagwatBigCinemas -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;BhagwatBigCinemas">
<rdf:type rdf:resource="&untitled-ontology-20;Attractions"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Bhuikotfort -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Bhuikotfort">
<rdf:type rdf:resource="&untitled-ontology-20;Attractions"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#DhruvaHotel -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;DhruvaHotel">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">3</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Durga_Mangesh_Garden_Restuarant -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Durga_Mangesh_Garden_Restuarant">
<rdf:type rdf:resource="&untitled-ontology-20;Restuarants"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#GreatIndianBustardSancturay -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;GreatIndianBustardSancturay">
<rdf:type rdf:resource="&untitled-ontology-20;Attractions"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#HotelCityPark -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;HotelCityPark">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">5</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotelcitypark</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#HotelLotus -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;HotelLotus">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">3</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#HotelNila -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;HotelNila">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">1.2</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#HotelTripursundari -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;HotelTripursundari">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">1.6</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#HotelVaishnavi -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;HotelVaishnavi">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">4.5</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#KRAVINGS-THE-FOOD-WORLD -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;KRAVINGS-THE-FOOD-WORLD">
<rdf:type rdf:resource="&untitled-ontology-20;Restuarants"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Kamat -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Kamat">
<rdf:type rdf:resource="&untitled-ontology-20;Restuarants"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#NikitaPurVeg -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;NikitaPurVeg">
<rdf:type rdf:resource="&untitled-ontology-20;Restuarants"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Pandurang_temple -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Pandurang_temple">
<rdf:type rdf:resource="&untitled-ontology-20;Attractions"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Parasnath_Jain_Temple -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Parasnath_Jain_Temple">
<rdf:type rdf:resource="&untitled-ontology-20;Attractions"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#PrathamHotel -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;PrathamHotel">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">1.6</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#RevanSiddeshwar_temple -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;RevanSiddeshwar_temple">
<rdf:type rdf:resource="&untitled-ontology-20;Attractions"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#RiteshHotel -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;RiteshHotel">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">3.5</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel1</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Rukmini_temple -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Rukmini_temple">
<rdf:type rdf:resource="&untitled-ontology-20;Attractions"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Shivparvati_International_Hotel -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Shivparvati_International_Hotel">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">4</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#ShriSiddheshwar_temple -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;ShriSiddheshwar_temple">
<rdf:type rdf:resource="&untitled-ontology-20;Attractions"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Sips_and_Bites -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Sips_and_Bites">
<rdf:type rdf:resource="&untitled-ontology-20;Restuarants"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Spice_n_Ice -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Spice_n_Ice">
<rdf:type rdf:resource="&untitled-ontology-20;Restuarants"/>
<hasStarRating rdf:datatype="&xsd;decimal">3.5</hasStarRating>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Srikamal_International_Hotel -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Srikamal_International_Hotel">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">4.8</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Supraja_Pav_Bhaji -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Supraja_Pav_Bhaji">
<rdf:type rdf:resource="&untitled-ontology-20;Restuarants"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#SuryaInternational -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;SuryaInternational">
<rdf:type rdf:resource="&untitled-ontology-20;Accomodation"/>
<hasStarRating rdf:datatype="&xsd;decimal">5</hasStarRating>
<hasType rdf:datatype="&xsd;string">Hotel</hasType>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/rohit/ontologies/2014/4/untitled-ontology-20#Temptations -->
<owl:NamedIndividual rdf:about="&untitled-ontology-20;Temptations">
<rdf:type rdf:resource="&untitled-ontology-20;Restuarants"/>
</owl:NamedIndividual>
</rdf:RDF>