I have this kind of structure
<ontology:Louvre>
<rdf:type ontology:Museum/>
<ontology:preserves rdf:Gioconda/>
<ontology:locatedIn rdf:Paris/>
<ontology:name>Louvre</ontology:name>
<ontology:Gioconda>
<rdf:type ontology:Artwork/>
<ontology:preserved rdf:Louvre/>
<ontology:author rdf:Leonardo/>
<nomeOpera>Gioconda</nomeOpera>
<rdf:Leonardo_Da_Vinci>
<rdf:type ontology:Painter"/>
<ontology:paint ontology:Gioconda"/>
<ontology:paint ontology:Ultima_cena"/>
<name>Leonardo Da Vinci</name>
...(other museum, artist and artwork)
I use "ontology" to indicate my prefix
Is it possible to recover the exclusive artists of a museum?
I found the solution.
This is the query that i'm looking for
SELECT DISTINCT * WHERE {
?museum ontology:preserves ?artwork .
?museum ontology:name "Louvre" .
?artwork ontology:author ?author.
FILTER NOT EXISTS{
?museum2 ontology:preserves ?artwork2 .
?artwork2 ontology:author ?author .
FILTER (?museum2 != ?museum)
}
}
I tried to make a SPARQL query but I failed.
I have three properties which I need to ask for like that:
SELECT DISTINCT ?locality ?museRes ?calendar ?category
FROM <http://opendata.cs.pub.ro/repo/context/TTT>
WHERE {
{
?museRes vCard:locality ?locality FILTER (regex(?museRes, "odaia_bunicii", "i")) .
?museRes vCard:category ?category FILTER (regex(?museRes, "odaia_bunicii", "i")).
?museRes vCard:hasCalendarRequest ?calendar FILTER (regex(?museRes, "odaia_bunicii", "i"))
}
}
in Romanian OpenData SPARQL endpoint
The problem is that three properties are part from another three super-properties (dcterms:spatials, dcterms:description and opendata:MuseumTour) and that approach doesn't work. I tried with OPTION operator but it show me only ?museRes and ?locality values even ?calendar and ?category are not empty.
In the end, I tried to use UNION instead of OPTION, but it works only with one UNION and I need to use two UNION operators.
How may I ask for vCard:locality vCard:category and vCard:hasCalendarRequest in the above RDF?
<rdf:RDF
xmlns:marcrel="http://www.loc.gov/loc.terms/relators/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcmitype="http://purl.org/dc/dcmitype/"
xmlns:opendata="http://opendata.cs.pub.ro/property/"
xmlns:vCard="http://www.w3.org/2006/vcard/ns#"
xmlns:dbPedia="http://dbpedia.org/ontology/"
xmlns:cdtype="http://purl.org/cld/cdtype/"
xmlns:cld="http://purl.org/cld/terms/">
<dbPedia:Museum rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/">
<dcterms:description>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Info/">
<dc:identifier>7172383</dc:identifier>
<opendata:FoundingYear>2016</opendata:FoundingYear>
<dc:title xml:lang="en"></dc:title>
<dcterms:isReferencedBy></dcterms:isReferencedBy>
<marcrel:OWN>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Info/Own/">
<dc:identifier></dc:identifier>
<dc:title></dc:title>
</rdf:Description>
</marcrel:OWN>
<opendata:Accreditation></opendata:Accreditation>
<dc:subject>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Info/Subject/">
<vCard:value xml:lang="en"></vCard:value>
<vCard:label xml:lang="en">Specific (Principal) profile</vCard:label>
<vCard:label>Profil specific (principal)</vCard:label>
<vCard:value>Etnografie</vCard:value>
<vCard:label>Profil general</vCard:label>
</rdf:Description>
</dc:subject>
<dc:title>"Odaia Bunicii" - Centrul Folcloric Grădiniţa, Galicea Mare</dc:title>
<vCard:hasCategory>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Info/Category/">
<opendata:MainCategory xml:lang="en">Museum</opendata:MainCategory>
<opendata:MainCategory>Muzeu</opendata:MainCategory>
<vCard:category xml:lang="en"></vCard:category>
<vCard:category>Muzeu Comunal</vCard:category>
</rdf:Description>
</vCard:hasCategory>
<dcterms:description>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Info/Description/">
<opendata:Historic xml:lang="en"></opendata:Historic>
<opendata:Historic></opendata:Historic>
<dcterms:abstract xml:lang="en"></dcterms:abstract>
<dcterms:abstract></dcterms:abstract>
<dcterms:description xml:lang="en"></dcterms:description>
<dcterms:description>Centrul folcloric al grădiniţei Galicea Mare este situat în incinta Grădiniţei nr.1, structură a Şcolii Gimnaziale Galicea Mare, judeţul Dolj, pe drumul european E56. Pentru a readuce la viaţă şi a reînvia atât tradiţiile cât şi portul popular românesc, a luat naştere „Odaia bunicii”, un loc in care obiectele prind viaţă şi creează o atmosferă caldă, plina de dragostea ţaranilor de altadată. Expoziţia permanentă, deschisă în 2016, este concepută într-o manieră tradiţională, fiecare obiect aşteptând să fie folosit pentru a-şi arata maiestria, astfel: patul cu tablii de lemn şi saltea de paie aşteaptă să odihnească omul, măsuţa din lemn şi scaunelele aşteaptă cu nerăbdare să fie servită cina, dar şi războiul ţăranesc unde femeile ţeseau macate ne reamintesc nouă, celor mari, şi îi învaţă pe cei mici despre obiceiurile şi tradiţiile româneşti de altădată.</dcterms:description>
<opendata:Relevance xml:lang="en">Local</opendata:Relevance>
<opendata:Relevance>Locală</opendata:Relevance>
</rdf:Description>
</dcterms:description>
</rdf:Description>
</dcterms:description>
<dbPedia:Building>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Building/">
<dbPedia:HistoricBuilding></dbPedia:HistoricBuilding>
<dcterms:abstract xml:lang="en"></dcterms:abstract>
<dcterms:abstract></dcterms:abstract>
<dc:identifier></dc:identifier>
<dc:type xml:lang="en">Building</dc:type>
<dc:type>Cladire</dc:type>
</rdf:Description>
</dbPedia:Building>
<opendata:MuseumTour>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Tour/">
<vCard:hasCalendarRequest xml:lang="en">Unspecified</vCard:hasCalendarRequest>
<vCard:hasCalendarRequest>luni-vineri 8:00-13:00</vCard:hasCalendarRequest>
<opendata:VirtualTour></opendata:VirtualTour>
</rdf:Description>
</opendata:MuseumTour>
<opendata:Contact>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/">
<vCard:url>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/URI/">
<opendata:SocialMediaUri>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/URI/SocialMediaUri/">
<vCard:label>Link-uri social media.</vCard:label>
<vCard:hasValue></vCard:hasValue>
</rdf:Description>
</opendata:SocialMediaUri>
<opendata:CimecUri>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/URI/CimecUri/">
<vCard:label>Link-ul catre portalul CIMEC.</vCard:label>
<vCard:hasValue>http://ghidulmuzeelor.cimec.ro/id.asp?k=2030&-„Odaia-bunicii”-Centrul-folcloric-Gradinita,-Galicea-Mare-GALICEA-MARE-Dolj</vCard:hasValue>
</rdf:Description>
</opendata:CimecUri>
<opendata:WebUri>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/URI/WebUri/">
<vCard:label>Link-ul catre site-ul muzeului.</vCard:label>
<vCard:hasValue></vCard:hasValue>
</rdf:Description>
</opendata:WebUri>
</rdf:Description>
</vCard:url>
<vCard:Individual>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/Individual/">
<opendata:Employee>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/Individual/Employee/">
<vCard:hasName>Gologan Veronica</vCard:hasName>
<vCard:hasRole>Profesor</vCard:hasRole>
</rdf:Description>
</opendata:Employee>
<opendata:Manager>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/Individual/Manager/">
<vCard:hasName>Văduva Cristian</vCard:hasName>
<vCard:hasRole>Director</vCard:hasRole>
</rdf:Description>
</opendata:Manager>
</rdf:Description>
</vCard:Individual>
<vCard:hasEmail></vCard:hasEmail>
<vCard:hasTelephone>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/Telephone/">
<vCard:Fax>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/Telephone/Fax/">
<vCard:rev></vCard:rev>
<vCard:value></vCard:value>
</rdf:Description>
</vCard:Fax>
<vCard:Work>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Contact/Telephone/Work/">
<vCard:rev></vCard:rev>
<vCard:value>0251.316.006; 0762.278.850</vCard:value>
</rdf:Description>
</vCard:Work>
</rdf:Description>
</vCard:hasTelephone>
</rdf:Description>
</opendata:Contact>
<dcterms:spatials>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Spatials/">
<vCard:hasAddress>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Spatials/Address/">
<vCard:postal-code>207270</vCard:postal-code>
<vCard:region>Dolj</vCard:region>
<dbPedia:AdministrativeRegion>Galicea Mare</dbPedia:AdministrativeRegion>
<vCard:hasLocality>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Spatials/Locality/">
<opendata:Siruta></opendata:Siruta>
<vCard:locality>Galicea Mare</vCard:locality>
</rdf:Description>
</vCard:hasLocality>
<vCard:street-address>Str. Calafatului nr. 10</vCard:street-address>
</rdf:Description>
</vCard:hasAddress>
<opendata:Access xml:lang="en"></opendata:Access>
<opendata:Access></opendata:Access>
<vCard:hasGeo>
<rdf:Description rdf:about="http://opendata.cs.pub.ro/resource/_Odaia_Bunicii-Centrul_Folcloric_Gradinita_Galicea_Mare_Dolj/Spatials/GeoPos/">
<vCard:longitude>23.3</vCard:longitude>
<vCard:latitude>44.1</vCard:latitude>
<vCard:label>Localitate</vCard:label>
</rdf:Description>
</vCard:hasGeo>
</rdf:Description>
</dcterms:spatials>
</dbPedia:Museum>
</rdf:RDF>
A better answer...
SELECT DISTINCT ?o ?museum_res ?locality ?calendar ?category ?importanta
FROM <http://opendata.cs.pub.ro/repo/context/TTT>
WHERE {
{
?museum_res ?p ?o.
?e dc:title ?title.
?a vCard:locality ?locality.
?b vCard:category ?category.
?c vCard:hasCalendarRequest ?calendar.
?d openDataP:Relevance ?importanta.
FILTER (
UCASE(?o) = UCASE("http://dbpedia.org/ontology/Museum") &&
contains(?title, "Odaia") &&
contains(?e, ?museum_res) &&
contains(?a, ?museum_res) && langMatches(lang(?locality),"") &&
contains(?b, ?museum_res) && langMatches(lang(?category),"") &&
contains(?c, ?museum_res) && langMatches(lang(?calendar),"") &&
contains(?d, ?museum_res) &&langMatches(lang(?importanta),"")
)
}
}
ORDER BY ?museum_res
LIMIT 1200
After 3-4 hours I found the solution:
SELECT DISTINCT ?locality ?category ?calendar ?importanta
FROM <http://opendata.cs.pub.ro/repo/context/ilie>
WHERE {
?a vCard:locality ?locality. FILTER (regex(?a, "odaia_bunicii", "i")).
?b vCard:category ?category. FILTER (regex(?b, "odaia_bunicii", "i")).
?c vCard:hasCalendarRequest ?calendar. FILTER (regex(?c, "odaia_bunicii", "i")).
?d openDataP:Relevance ?importanta. FILTER (regex(?d, "odaia_bunicii", "i")).
}
Actually I want to display 3 individuals from the same type of class and also their datatype. I have try some code but still it doesn't work. Where it could be wrong?
Here,the code in my jsp file
<%
model=FileManager.get().loadModel("data.rdf");
out.print("<tr><th scope='row'><b>Sarapan Pagi</b></th>");
out.print("<th scope='row'>");
queryString=
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax=ns#>"+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>" +
"prefix owl: <http://www.w3.org/2002/07/owl#>" +
"prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>" +
"prefix ab: <http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#>" +
"SELECT ?x " +
"WHERE{"+
" ?x rdf:type ab:KumpBijirin." +
" FILTER (? x= :BiskutKrimKraker)." +
"}";
query=QueryFactory.create(queryString);
qexec=QueryExecutionFactory.create(query,model);
try{
ResultSet results=qexec.execSelect();
while (results.hasNext()){
QuerySolution soln=results.nextSolution();
Literal name=soln.getLiteral("x");
out.print(name);
}
}finally{
qexec.close();
}out.print("</th></tr>"); %>
This is some of my data.rdf file.
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#AcarTimun">
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#JenisMakanMalam"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#JenisMakanTengahHari"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#KumpSayur"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#MenuHidanganSampingan"/>
<hasKalori rdf:datatype="http://www.w3.org/2001/XMLSchema#float">33.3</hasKalori>
<hasKarbohidrat rdf:datatype="http://www.w3.org/2001/XMLSchema#float">7.7</hasKarbohidrat>
<hasLemak rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</hasLemak>
<hasProtein rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.7</hasProtein>
<hasSaizHidangan rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1hidangan</hasSaizHidangan>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#AirKosong -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#AirKosong">
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#JenisMakanMalam"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#JenisMakanTengahHari"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#JenisMinumMalam"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#JenisMinumPagi"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#MenuMinuman"/>
<hasKalori rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.0</hasKalori>
<hasKarbohidrat rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.0</hasKarbohidrat>
<hasLemak rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.0</hasLemak>
<hasProtein rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.0</hasProtein>
<hasSaizHidangan rdf:datatype="http://www.w3.org/2001/XMLSchema#float">1gelas</hasSaizHidangan>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#Anggur -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#Anggur">
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#JenisMakanMalam"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#JenisMakanTengahHari"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#KumpBuah"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#MenuPencuciMulut"/>
<hasKalori rdf:datatype="http://www.w3.org/2001/XMLSchema#float">63.2</hasKalori>
<hasKarbohidrat rdf:datatype="http://www.w3.org/2001/XMLSchema#float">15.0</hasKarbohidrat>
<hasLemak rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.0</hasLemak>
<hasProtein rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.8</hasProtein>
<hasSaizHidangan rdf:datatype="http://www.w3.org/2001/XMLSchema#int">8biji</hasSaizHidangan>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#AsamLaksaPenang -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#AsamLaksaPenang">
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#JenisMakanMalam"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#JenisMakanTengahHari"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#KumpBijirin"/>
<rdf:type rdf:resource="http://www.semanticweb.org/user/ontologies/2016/3/untitled-ontology-23#MenuHidanganUtama"/>
<hasKalori rdf:datatype="http://www.w3.org/2001/XMLSchema#float">432.0</hasKalori>
<hasKarbohidrat rdf:datatype="http://www.w3.org/2001/XMLSchema#float">53.0</hasKarbohidrat>
<hasLemak rdf:datatype="http://www.w3.org/2001/XMLSchema#float">2.0</hasLemak>
<hasProtein rdf:datatype="http://www.w3.org/2001/XMLSchema#float">21.1</hasProtein>
<hasSaizHidangan rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1mangkuk</hasSaizHidangan>
</owl:NamedIndividual>
The following is a subquestion to my previous question: available here.
How to modify the following SPARQL query:
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?dt ?element ?elementType {
?dt a rdfs:Datatype ;
owl:oneOf/rdf:rest*/rdf:first ?element .
bind(datatype(?element) as ?elementType)
}
in order to to get a result of only A and C? I would like to obtain { "a1" "a2" "c1" "c2" }. The above query returns all enumeration values from the ontology, I mean: { "a1" "a2" "b1" "b2" "c1" "c2" }
We are given the ontology (A and B are equivalent but presented in different style syntax):
Variant A) in the functional style syntax:
Prefix(ont:=<http://www/ont.owl#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Ontology(<http://www/ont.owl>
DatatypeDefinition( ont:A DataOneOf( "a1" "a2" ) )
DatatypeDefinition( ont:B DataOneOf( "b1" "b2" ) )
DatatypeDefinition( ont:C DataOneOf( "c1" "c2" ) )
)
Variant B) in the RDF/XML style syntax:
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY ont "http://www/ont.owl#" >
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY xml "http://www.w3.org/XML/1998/namespace" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www/ont.owl#"
xml:base="http://www/ont.owl"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:ont="http://www/ont.owl#"
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:xml="http://www.w3.org/XML/1998/namespace">
<owl:Ontology rdf:about="http://www/ont.owl"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Datatypes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www/ont.owl#A -->
<rdfs:Datatype rdf:about="&ont;A">
<owl:equivalentClass>
<rdfs:Datatype>
<owl:oneOf>
<rdf:Description>
<rdf:type rdf:resource="&rdf;List"/>
<rdf:first>a1</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="&rdf;List"/>
<rdf:first>a2</rdf:first>
<rdf:rest rdf:resource="&rdf;nil"/>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</owl:oneOf>
</rdfs:Datatype>
</owl:equivalentClass>
</rdfs:Datatype>
<!-- http://www/ont.owl#B -->
<rdfs:Datatype rdf:about="&ont;B">
<owl:equivalentClass>
<rdfs:Datatype>
<owl:oneOf>
<rdf:Description>
<rdf:type rdf:resource="&rdf;List"/>
<rdf:first>b1</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="&rdf;List"/>
<rdf:first>b2</rdf:first>
<rdf:rest rdf:resource="&rdf;nil"/>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</owl:oneOf>
</rdfs:Datatype>
</owl:equivalentClass>
</rdfs:Datatype>
<!-- http://www/ont.owl#C -->
<rdfs:Datatype rdf:about="&ont;C">
<owl:equivalentClass>
<rdfs:Datatype>
<owl:oneOf>
<rdf:Description>
<rdf:type rdf:resource="&rdf;List"/>
<rdf:first>c1</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="&rdf;List"/>
<rdf:first>c2</rdf:first>
<rdf:rest rdf:resource="&rdf;nil"/>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</owl:oneOf>
</rdfs:Datatype>
</owl:equivalentClass>
</rdfs:Datatype>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.4.2) http://owlapi.sourceforge.net -->
As I said in the comments on the previous answer:
#Annabelle I was basing the retrieval methods on the ontology that I provided. There are certainly other ways to select the data types if they're identified by IRIs. In your case, it looks like it would be values ?dt {:A :B } if you only want ?dt to be A or B.
and
In this case, note that the axiom is encoded by saying that :A is owl:equivalentClass to the datatype class expression. That's the extra link you need between the class IRI and the expression.
That gives us:
select ?dt ?element ?elementType {
values ?dt { ont:A ont:B }
?dt owl:equivalentClass/a rdfs:Datatype ;
owl:oneOf/rdf:rest*/rdf:first ?element .
bind(datatype(?element) as ?elementType)
}
This really isn't much different from the previous answer. You just need to add on the specific values that you're looking for, and then add the equivalentClass link.
I am new to Jena but now encountered with some problems. I have a superclass Query Processing and its four subclasses:
Query Processing
— Query intent
— Query reformulation
— Query representation
— Query suggestion
When I use:
PREFIX Article: <http://www.semanticweb.org/aero/ontologies/computer-science#>
SELECT ?paper ?category
WHERE
{
?paper Article:inQueryIntent ?category .
}
Or with any the other 3 subclasses as the predicate like inQueryReformulation I can get the correct answer.
However when I used ?article Article:inQueryProcessing ?category which should return all the individuals related to the sub-classes QueryProcessing I got nothing. inQueryIntent (and the other 3) and inQueryProcessing are the object properties.
Here is my code:
Dataset dataset = TDBFactory.createDataset(directory);
Model model = dataset.getNamedModel(modelName);
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, model);
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, ontModel);
Query query = QueryFactory.create(queryString);
QueryExecution queryExe = QueryExecutionFactory.create(query, infModel);
here is the ontology snippet :
object properties:
<!-- http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#inQueryIntent -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#inQueryIntent">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Query_intent"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#article"/>
<rdfs:subPropertyOf rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#inInformationRetrievalQueryProcessing"/>
</owl:ObjectProperty>
class:
<owl:Class rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Query_intent">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Information_retrieval_query_processing"/>
</owl:Class>
individual:
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Classifying_Web_Queries_by_Topic_and_User_Intent">
<rdf:type rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#article"/>
<hasAuthor rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Bernard_J._Jansen"/>
<inQueryIntent rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Query_intent"/>
</owl:NamedIndividual>
I just build a domain ontology in ComputerScience, all the classes are concepts (like query processing is a superclass and query intent/reformulation/… are subclasses) in hierarchy and, all the papers and their corresponding authors are the individuals