Querying OWL File using SPARQL - sparql

I have an OWL file describing a simple ontology at http://purl.org/net/cnyt-literature. It has a couple of instances which have owl:sameAs property referring to DBpedia and Wikidata items. What I want to do is to have a federated SPARQL query for both obtaining information from my ontology and the related entities described in DBpedia and Wikidata.
First, I want to query my ontology in an external SPARQL endpoint (Wikidata or DBpedia), using SERVICE or FROM keywords.
Second, I want to make a federated query described as above.
How can I achieve these?
Here is my owl file :
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#"
xml:base="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature"
xmlns:literature="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#character -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#character">
<rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Play"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#writerOf -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#writerOf">
<rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Writer"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Play"/>
</owl:ObjectProperty>
<!-- http://www.w3.org/2002/07/owl#sameAs -->
<owl:ObjectProperty rdf:about="http://www.w3.org/2002/07/owl#sameAs">
<rdfs:domain rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
<rdfs:range rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#name -->
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#name">
<rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Literary_Work"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Politician"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Writer"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#uri -->
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#uri"/>
<!-- http://www.w3.org/2002/07/owl#sameAs -->
<owl:DatatypeProperty rdf:about="http://www.w3.org/2002/07/owl#sameAs"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem -->
<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human -->
<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human"/>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Literary_Work -->
<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Literary_Work"/>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Play -->
<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Play">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Literary_Work"/>
</owl:Class>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Politician -->
<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Politician">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human"/>
</owl:Class>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Writer -->
<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Writer">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human"/>
</owl:Class>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar">
<rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Politician"/>
<character rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar"/>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia.org/resource/Julius_Caesar</owl:sameAs>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q1048</owl:sameAs>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_DbPedia -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_DbPedia">
<rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
<uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/page/Julius_Caesar</uri>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play">
<rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Play"/>
<character rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar"/>
<writerOf rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play"/>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia.org/page/Julius_Caesar_(play)</owl:sameAs>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q1048</owl:sameAs>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play_DbPedia -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play_DbPedia">
<rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
<uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/resource/Julius_Caesar_(play)</uri>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play_Wikidata -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play_Wikidata">
<rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
<uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q215750</uri>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Wikidata -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Wikidata">
<rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
<uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q1048</uri>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare">
<rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Writer"/>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia.org/page/William_Shakespeare</owl:sameAs>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q692</owl:sameAs>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare_Dbpedia -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare_Dbpedia">
<rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
<uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia.org/page/William_Shakespeare</uri>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare_Wikidata -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare_Wikidata">
<rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
<uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q692</uri>
</owl:NamedIndividual>
UPDATE:
And here is the query (not a federated one) I tried for obtaining some results but received none:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX literature: <http://purl.org/net/cnyt-literature#>
select * from <http://purl.org/net/cnyt-literature> where {?x literature:writerOf ?z}
I also tried to put ?y instead of literature:writerOf; still no results.

Related

Custom ontology and RDFs

I created a custom OWL ontology using Protege which is serialized in a tree-based RDF/XML format.
What I want to do is create RDF triples from my predefined classes in custom ontology and store them in RDF file. And query those triples using SPARQL. How can I do this?
=== Update ===
This is what my custom ontology looks like, which has Comment class and
isAbout object property.
<?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 reviews_2 "http://review-analyzer.local/ontologies/reviews_2.owl#" >
]>
<rdf:RDF xmlns="http://review-analyzer.local/ontologies/reviews_2.owl#"
xml:base="http://review-analyzer.local/ontologies/reviews_2.owl"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:reviews_2="http://review-analyzer.local/ontologies/reviews_2.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#">
<owl:Ontology rdf:about="http://review-analyzer.local/ontologies/reviews_2.owl"/>
<!--
//
// Object Properties
//
-->
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#isAbout -->
<owl:ObjectProperty rdf:about="&reviews_2;isAbout">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:range rdf:resource="&reviews_2;Feature"/>
<rdfs:domain rdf:resource="&reviews_2;Review"/>
</owl:ObjectProperty>
<!--
//
// Data properties
//
-->
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#comment -->
<owl:DatatypeProperty rdf:about="&reviews_2;comment">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:domain rdf:resource="&reviews_2;Review"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#rating -->
<owl:DatatypeProperty rdf:about="&reviews_2;rating">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:domain rdf:resource="&reviews_2;Review"/>
<rdfs:range rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#type -->
<owl:DatatypeProperty rdf:about="&reviews_2;type">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:domain rdf:resource="&reviews_2;Feature"/>
</owl:DatatypeProperty>
<!--
//
// Classes
//
-->
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#Battery -->
<owl:Class rdf:about="&reviews_2;Battery">
<rdfs:subClassOf rdf:resource="&reviews_2;Feature"/>
</owl:Class>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#Body -->
<owl:Class rdf:about="&reviews_2;Body">
<rdfs:subClassOf rdf:resource="&reviews_2;Feature"/>
</owl:Class>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#Camera -->
<owl:Class rdf:about="&reviews_2;Camera">
<rdfs:subClassOf rdf:resource="&reviews_2;Feature"/>
</owl:Class>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#Display -->
<owl:Class rdf:about="&reviews_2;Display">
<rdfs:subClassOf rdf:resource="&reviews_2;Feature"/>
</owl:Class>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#Feature -->
<owl:Class rdf:about="&reviews_2;Feature"/>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#Memory -->
<owl:Class rdf:about="&reviews_2;Memory">
<rdfs:subClassOf rdf:resource="&reviews_2;Feature"/>
</owl:Class>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#Platform -->
<owl:Class rdf:about="&reviews_2;Platform">
<rdfs:subClassOf rdf:resource="&reviews_2;Feature"/>
</owl:Class>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#Review -->
<owl:Class rdf:about="&reviews_2;Review"/>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#front -->
<owl:Class rdf:about="&reviews_2;front">
<rdfs:subClassOf rdf:resource="&reviews_2;Camera"/>
</owl:Class>
<!--
//
// Individuals
//
-->
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#Battery -->
<owl:NamedIndividual rdf:about="&reviews_2;Battery">
<rdf:type rdf:resource="&reviews_2;Battery"/>
<type rdf:datatype="&xsd;string">battery</type>
</owl:NamedIndividual>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#OLED -->
<owl:NamedIndividual rdf:about="&reviews_2;OLED">
<rdf:type rdf:resource="&reviews_2;Display"/>
<type rdf:datatype="&xsd;string">OLED</type>
</owl:NamedIndividual>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#amoled -->
<owl:NamedIndividual rdf:about="&reviews_2;amoled">
<rdf:type rdf:resource="&reviews_2;Display"/>
<type rdf:datatype="&xsd;string">amoled</type>
</owl:NamedIndividual>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#fCameraReview -->
<owl:NamedIndividual rdf:about="&reviews_2;fCameraReview">
<rdf:type rdf:resource="&reviews_2;Review"/>
<rating rdf:datatype="&xsd;integer">3</rating>
<comment rdf:datatype="&xsd;string">awesome</comment>
<isAbout rdf:resource="&reviews_2;frontCamera"/>
</owl:NamedIndividual>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#frontCamera -->
<owl:NamedIndividual rdf:about="&reviews_2;frontCamera">
<rdf:type rdf:resource="&reviews_2;front"/>
<type rdf:datatype="&xsd;string">front camera</type>
</owl:NamedIndividual>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#review -->
<owl:NamedIndividual rdf:about="&reviews_2;review">
<rdf:type rdf:resource="&reviews_2;Review"/>
<rating rdf:datatype="&xsd;integer">3</rating>
<comment rdf:datatype="&xsd;string">great</comment>
<isAbout rdf:resource="&reviews_2;amoled"/>
</owl:NamedIndividual>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#tt -->
<owl:NamedIndividual rdf:about="&reviews_2;tt">
<rdf:type rdf:resource="&reviews_2;Review"/>
<rating rdf:datatype="&xsd;integer">3</rating>
<comment rdf:datatype="&xsd;string">nice one</comment>
<isAbout rdf:resource="&reviews_2;amoled"/>
</owl:NamedIndividual>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#tt2 -->
<owl:NamedIndividual rdf:about="&reviews_2;tt2">
<rdf:type rdf:resource="&reviews_2;Review"/>
<rating rdf:datatype="&xsd;integer">2</rating>
<comment rdf:datatype="&xsd;string">dfgh</comment>
<isAbout rdf:resource="&reviews_2;amoled"/>
</owl:NamedIndividual>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#xx -->
<owl:NamedIndividual rdf:about="&reviews_2;xx">
<rdf:type rdf:resource="&reviews_2;Review"/>
<rating rdf:datatype="&xsd;integer">4</rating>
<comment rdf:datatype="&xsd;string">great battery</comment>
<isAbout rdf:resource="&reviews_2;Battery"/>
</owl:NamedIndividual>
<!-- http://review-analyzer.local/ontologies/reviews_2.owl#xx2 -->
<owl:NamedIndividual rdf:about="&reviews_2;xx2">
<rdf:type rdf:resource="&reviews_2;Review"/>
<rating rdf:datatype="&xsd;integer">1</rating>
<comment rdf:datatype="&xsd;string">fghjk</comment>
<isAbout rdf:resource="&reviews_2;frontCamera"/>
</owl:NamedIndividual>
<!--
//
// General axioms
//
-->
<rdf:Description>
<rdf:type rdf:resource="&owl;AllDisjointClasses"/>
<owl:members rdf:parseType="Collection">
<rdf:Description rdf:about="&reviews_2;Battery"/>
<rdf:Description rdf:about="&reviews_2;Body"/>
<rdf:Description rdf:about="&reviews_2;Camera"/>
<rdf:Description rdf:about="&reviews_2;Display"/>
<rdf:Description rdf:about="&reviews_2;Memory"/>
<rdf:Description rdf:about="&reviews_2;Platform"/>
</owl:members>
</rdf:Description>
</rdf:RDF>
And my RDF file looks like
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:cmnt="http://review-analyzer.local/ontologies/reviews_2.owl#"
xmlns:admin="http://webns.net/mvcb/">
<cmnt:Comment rdf:ID="me">
<cmnt:review>Great one!</cmnt:review>
<cmnt:raitng>5</cmnt:raitng>
<cmnt:isAbout>
<cmnt:Display rdf:ID="amoled">
<cmnt:type>amoled</cmnt:type>
</cmnt:Display>
</cmnt:isAbout>
</cmnt:Comment>
</rdf:RDF>
So i can't figure it out a way to comment which is created from Comment class.
can't I write something like ?
select *
where {
?Comment rdf:type ns:Review ;
}
RDF/XML is RDF. Any repository or library that accepts SPARQL queries should also accept the file as it is, through whichever loading mechanism the library supports. For example, Jena and ARQ would be able to deal with that as libraries, and Fuseki as a SPARQL endpoint.

SPARQL : Passing parameter from main query to SERVICE query

In the below query, I'd like to pass the ?wid parameter to the SERVICE query, but it is not passed and processed as another empty variable(like ?child) so the query returns undesired results(meaning that it behaves ?wid as an empty variable because this code runs on wikidata server so it returns all possible results for that variable). I'm firing this query from my local jena fuseki server.
PREFIX lit: <http://purl.org/net/cnyt-literature#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT distinct ?writer ?play ?character ?uri ?wid ?type ?child ?childLabel WHERE {
{
?writer lit:writerOf ?play .
?play lit:character ?character .
?character lit:dbpediaUri ?db_uri . BIND (IRI(?uri) AS ?dbpedia_uri)
?character lit:wikidataUri ?uri . BIND (IRI(CONCAT(str(wd:),?uri)) as ?wid)
}
SERVICE <http://query.wikidata.org/sparql> {
select distinct ?child ?childLabel where {
?wid wdt:P40 ?child.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
}
}
LIMIT 50
Basically, what I want to do is to fetch also label name of entities from wikipedia by adding the line
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
to the select statement.
When I don't use SELECT statement it works as expected and ?wid parameter is passed, so the problem is with the passing of this parameter to WHERE statement, not to SERVICE. In this query it returns three childs of Julius Caesar for wid(Q1048) which is true.
SERVICE <http://query.wikidata.org/sparql> {
?wid wdt:P40 ?child.
}
My data is :
Individuals
Writer William Shakespeare
Play JuliusCaesarPlay
Politican JuliusCaesar
Triples
WilliamShakespeare writerOf JuliusCaesarPlay
JuliusCaesarPlay character JuliusCaesar
JuliusCaesar wikidataUri "Q1048"
And this is the whole owl file :
<?xml version="1.0"?>
<rdf:RDF xmlns="http://purl.org/net/cnyt-literature#"
xml:base="http://purl.org/net/cnyt-literature"
xmlns:literature="http://purl.org/net/cnyt-literature#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:literature1="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://purl.org/net/cnyt-literature"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://purl.org/net/cnyt-literature#character -->
<owl:ObjectProperty rdf:about="http://purl.org/net/cnyt-literature#character">
<rdfs:domain rdf:resource="http://purl.org/net/cnyt-literature#Play"/>
<rdfs:range rdf:resource="http://purl.org/net/cnyt-literature#Human"/>
</owl:ObjectProperty>
<!-- http://purl.org/net/cnyt-literature#wikidataId -->
<owl:ObjectProperty rdf:about="http://purl.org/net/cnyt-literature#wikidataId"/>
<!-- http://purl.org/net/cnyt-literature#writerOf -->
<owl:ObjectProperty rdf:about="http://purl.org/net/cnyt-literature#writerOf">
<rdfs:domain rdf:resource="http://purl.org/net/cnyt-literature#Writer"/>
<rdfs:range rdf:resource="http://purl.org/net/cnyt-literature#Play"/>
</owl:ObjectProperty>
<!-- http://www.w3.org/2002/07/owl#sameAs -->
<owl:ObjectProperty rdf:about="http://www.w3.org/2002/07/owl#sameAs">
<rdfs:domain rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
<rdfs:range rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://purl.org/net/cnyt-literature#dbpediaUri -->
<owl:DatatypeProperty rdf:about="http://purl.org/net/cnyt-literature#dbpediaUri">
<rdfs:subPropertyOf rdf:resource="http://www.w3.org/2002/07/owl#topDataProperty"/>
</owl:DatatypeProperty>
<!-- http://purl.org/net/cnyt-literature#name -->
<owl:DatatypeProperty rdf:about="http://purl.org/net/cnyt-literature#name">
<rdfs:domain rdf:resource="http://purl.org/net/cnyt-literature#Human"/>
<rdfs:domain rdf:resource="http://purl.org/net/cnyt-literature#Literary_Work"/>
<rdfs:domain rdf:resource="http://purl.org/net/cnyt-literature#Politician"/>
<rdfs:domain rdf:resource="http://purl.org/net/cnyt-literature#Writer"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<!-- http://purl.org/net/cnyt-literature#nn -->
<owl:DatatypeProperty rdf:about="http://purl.org/net/cnyt-literature#nn"/>
<!-- http://purl.org/net/cnyt-literature#source -->
<owl:DatatypeProperty rdf:about="http://purl.org/net/cnyt-literature#source"/>
<!-- http://purl.org/net/cnyt-literature#wikidataUri -->
<owl:DatatypeProperty rdf:about="http://purl.org/net/cnyt-literature#wikidataUri"/>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#uri -->
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#uri"/>
<!-- http://www.w3.org/2002/07/owl#sameAs -->
<owl:DatatypeProperty rdf:about="http://www.w3.org/2002/07/owl#sameAs"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://purl.org/net/cnyt-literature#ExternalItem -->
<owl:Class rdf:about="http://purl.org/net/cnyt-literature#ExternalItem"/>
<!-- http://purl.org/net/cnyt-literature#Human -->
<owl:Class rdf:about="http://purl.org/net/cnyt-literature#Human"/>
<!-- http://purl.org/net/cnyt-literature#Literary_Work -->
<owl:Class rdf:about="http://purl.org/net/cnyt-literature#Literary_Work"/>
<!-- http://purl.org/net/cnyt-literature#Novel -->
<owl:Class rdf:about="http://purl.org/net/cnyt-literature#Novel">
<rdfs:subClassOf rdf:resource="http://purl.org/net/cnyt-literature#Literary_Work"/>
</owl:Class>
<!-- http://purl.org/net/cnyt-literature#Play -->
<owl:Class rdf:about="http://purl.org/net/cnyt-literature#Play">
<rdfs:subClassOf rdf:resource="http://purl.org/net/cnyt-literature#Literary_Work"/>
</owl:Class>
<!-- http://purl.org/net/cnyt-literature#Politician -->
<owl:Class rdf:about="http://purl.org/net/cnyt-literature#Politician">
<rdfs:subClassOf rdf:resource="http://purl.org/net/cnyt-literature#Human"/>
</owl:Class>
<!-- http://purl.org/net/cnyt-literature#Writer -->
<owl:Class rdf:about="http://purl.org/net/cnyt-literature#Writer">
<rdfs:subClassOf rdf:resource="http://purl.org/net/cnyt-literature#Human"/>
</owl:Class>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://purl.org/net/cnyt-literature#JackLondon -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#JackLondon">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#Writer"/>
<writerOf rdf:resource="http://purl.org/net/cnyt-literature#WhiteFang"/>
<name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Jack London</name>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#JuliusCaesar -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#JuliusCaesar">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#Politician"/>
<dbpediaUri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/resource/Julius_Caesar</dbpediaUri>
<wikidataUri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Q1048</wikidataUri>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/resource/Julius_Caesar</owl:sameAs>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q1048</owl:sameAs>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#JuliusCaesarDbpedia -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#JuliusCaesarDbpedia">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#ExternalItem"/>
<source rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia</source>
<literature1:uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/page/Julius_Caesar</literature1:uri>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#JuliusCaesarPlay -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#JuliusCaesarPlay">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#Play"/>
<character rdf:resource="http://purl.org/net/cnyt-literature#JuliusCaesar"/>
<dbpediaUri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/page/Julius_Caesar_(play)</dbpediaUri>
<wikidataUri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q1048</wikidataUri>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/page/Julius_Caesar_(play)</owl:sameAs>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q1048</owl:sameAs>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#JuliusCaesarPlayDbpedia -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#JuliusCaesarPlayDbpedia">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#ExternalItem"/>
<source rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia</source>
<literature1:uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/resource/Julius_Caesar_(play)</literature1:uri>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#JuliusCaesarPlayWikidata -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#JuliusCaesarPlayWikidata">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#ExternalItem"/>
<source rdf:datatype="http://www.w3.org/2001/XMLSchema#string">wikidata</source>
<literature1:uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q215750</literature1:uri>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#JuliusCaesarWikidata -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#JuliusCaesarWikidata">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#ExternalItem"/>
<source rdf:datatype="http://www.w3.org/2001/XMLSchema#string">wikidata</source>
<literature1:uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q1048</literature1:uri>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#WhiteFang -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#WhiteFang">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#Novel"/>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#WilliamShakespeare -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#WilliamShakespeare">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#Writer"/>
<writerOf rdf:resource="http://purl.org/net/cnyt-literature#JuliusCaesarPlay"/>
<dbpediaUri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/page/William_Shakespeare</dbpediaUri>
<wikidataUri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q692</wikidataUri>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/page/William_Shakespeare</owl:sameAs>
<owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q692</owl:sameAs>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#WilliamShakespeareDbpedia -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#WilliamShakespeareDbpedia">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#ExternalItem"/>
<source rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia</source>
<literature1:uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia.org/page/William_Shakespeare</literature1:uri>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#WilliamShakespeareWikidata -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#WilliamShakespeareWikidata">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#ExternalItem"/>
<source rdf:datatype="http://www.w3.org/2001/XMLSchema#string">wikidata</source>
<literature1:uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q692</literature1:uri>
</owl:NamedIndividual>
<!-- http://purl.org/net/cnyt-literature#wd:Q1048 -->
<owl:NamedIndividual rdf:about="http://purl.org/net/cnyt-literature#wd:Q1048">
<rdf:type rdf:resource="http://purl.org/net/cnyt-literature#ExternalItem"/>
</owl:NamedIndividual>
</rdf:RDF>
<!-- Generated by the OWL API (version 4.2.6.20160910-2108) https://github.com/owlcs/owlapi -->

SPARQL query not displaying results

I'm very new to Semantic Web programming. I have an OWL file that I've loaded into Virtuoso server at the URI http://myexample.com. Now when I open the Virtuoso SPARQL query editor (http://localhost:8890/sparql), and run the following query, I get no results:
SELECT ?class FROM <myexample.com> WHERE{?class a owl:class} Order By ?class
Here is my OWL file:
<?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 owl2xml "http://www.w3.org/2006/12/owl2-xml#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY Antibiotics "http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#" >
<!ENTITY Antibiotics2 "http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#2" >
<!ENTITY Antibiotics3 "http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#1" >
<!ENTITY Antibiotics4 "http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#3" >
<!ENTITY Traveler "http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Traveler'" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#"
xml:base="http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#"
xmlns:Antibiotics2="&Antibiotics;2"
xmlns:Traveler="&Antibiotics;Traveler'"
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:Antibiotics="http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#"
xmlns:Antibiotics3="&Antibiotics;1"
xmlns:Antibiotics4="&Antibiotics;3">
<owl:Ontology rdf:about=""/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#cures_disease -->
<owl:ObjectProperty rdf:about="#cures_disease">
<rdfs:label>cures_disease</rdfs:label>
<rdfs:domain rdf:resource="#Antibiotics"/>
<rdfs:range rdf:resource="#Diseases"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#has_SideEffects -->
<owl:ObjectProperty rdf:about="#has_SideEffects">
<rdfs:label>has_SideEffects</rdfs:label>
<rdfs:domain rdf:resource="#Antibiotics"/>
<rdfs:range rdf:resource="#SideEffects"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#1st_Generation -->
<owl:Class rdf:about="#1st_Generation">
<rdfs:label>1st_Generation</rdfs:label>
<rdfs:subClassOf rdf:resource="#Antibiotics"/>
</owl:Class>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#2nd_Generation -->
<owl:Class rdf:about="#2nd_Generation">
<rdfs:label>2nd_Generation</rdfs:label>
<rdfs:subClassOf rdf:resource="#Antibiotics"/>
</owl:Class>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#3rd_Generation -->
<owl:Class rdf:about="#3rd_Generation">
<rdfs:label>3rd_Generation</rdfs:label>
<rdfs:subClassOf rdf:resource="#Antibiotics"/>
</owl:Class>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Aminopenicillins -->
<owl:Class rdf:about="#Aminopenicillins">
<rdfs:label
>Aminopenicillins</rdfs:label>
<rdfs:subClassOf rdf:resource="#Antibiotics"/>
</owl:Class>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Antibiotics -->
<owl:Class rdf:about="#Antibiotics">
<rdfs:label>Antibiotics</rdfs:label>
<rdfs:subClassOf rdf:resource="&owl;Thing"/>
</owl:Class>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Diseases -->
<owl:Class rdf:about="#Diseases">
<rdfs:label>Diseases</rdfs:label>
<rdfs:subClassOf rdf:resource="&owl;Thing"/>
</owl:Class>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Lincosamide -->
<owl:Class rdf:about="#Lincosamide">
<rdfs:label>Lincosamide</rdfs:label>
<rdfs:subClassOf rdf:resource="#Antibiotics"/>
</owl:Class>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#SideEffects -->
<owl:Class rdf:about="#SideEffects">
<rdfs:label>SideEffects</rdfs:label>
<rdfs:subClassOf rdf:resource="&owl;Thing"/>
</owl:Class>
<!-- http://www.w3.org/2002/07/owl#Thing -->
<owl:Class rdf:about="&owl;Thing"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Acne -->
<Diseases rdf:about="#Acne">
<rdf:type rdf:resource="&owl;Thing"/>
<rdfs:label>Acne</rdfs:label>
</Diseases>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Allergic_Reactions -->
<owl:Thing rdf:about="#Allergic_Reactions">
<rdf:type rdf:resource="#SideEffects"/>
<rdfs:label
>Allergic_Reactions</rdfs:label>
</owl:Thing>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Amoxicillin -->
<owl:Thing rdf:about="#Amoxicillin">
<rdf:type rdf:resource="#Aminopenicillins"/>
<rdfs:label>Amoxicillin</rdfs:label>
<has_SideEffects rdf:resource="#Diarrhea"/>
<cures_disease rdf:resource="#Wide_Range_Of_Infections"/>
</owl:Thing>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Cefalexin -->
<owl:Thing rdf:about="#Cefalexin">
<rdf:type rdf:resource="#1st_Generation"/>
<rdfs:label>Cephalexin</rdfs:label>
<cures_disease rdf:resource="#Gram_positive_infections"/>
<has_SideEffects rdf:resource="#Nausea"/>
</owl:Thing>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Cefazolin -->
<Antibiotics3:st_Generation rdf:about="#Cefazolin">
<rdf:type rdf:resource="&owl;Thing"/>
<rdfs:label>Cefazolin</rdfs:label>
<has_SideEffects rdf:resource="#Allergic_Reactions"/>
<cures_disease rdf:resource="#Gram_positive_infections"/>
</Antibiotics3:st_Generation>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Cefepime -->
<owl:Thing rdf:about="#Cefepime">
<rdf:type rdf:resource="#3rd_Generation"/>
<rdfs:label>Cefepime</rdfs:label>
<has_SideEffects rdf:resource="#Nausea"/>
<cures_disease rdf:resource="#Pseudomonal_Infections"/>
</owl:Thing>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Cefoxitin -->
<Antibiotics2:nd_Generation rdf:about="#Cefoxitin">
<rdf:type rdf:resource="&owl;Thing"/>
<rdfs:label>Cefoxitin</rdfs:label>
<has_SideEffects rdf:resource="#Allergic_Reactions"/>
<cures_disease rdf:resource="#Gram_negative_cover"/>
</Antibiotics2:nd_Generation>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Clindamycin -->
<owl:Thing rdf:about="#Clindamycin">
<rdf:type rdf:resource="#Lincosamide"/>
<rdfs:label>Clindamycin</rdfs:label>
<cures_disease rdf:resource="#Acne"/>
<has_SideEffects rdf:resource="#Diarrhea"/>
</owl:Thing>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Diarrhea -->
<owl:Thing rdf:about="#Diarrhea">
<rdf:type rdf:resource="#SideEffects"/>
<rdfs:label>Diarrhea</rdfs:label>
</owl:Thing>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Gastrointestinal_Upset -->
<SideEffects rdf:about="#Gastrointestinal_Upset">
<rdf:type rdf:resource="&owl;Thing"/>
<rdfs:label
>Gastrointestinal_Upset</rdfs:label>
</SideEffects>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Gram_negative_cover -->
<owl:Thing rdf:about="#Gram_negative_cover">
<rdf:type rdf:resource="#Diseases"/>
<rdfs:label
>Gram_negative_cover</rdfs:label>
</owl:Thing>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Gram_positive_infections -->
<owl:Thing rdf:about="#Gram_positive_infections">
<rdf:type rdf:resource="#Diseases"/>
<rdfs:label
>Gram_positive_infections</rdfs:label>
<cures_disease rdf:resource="#Gram_positive_infections"/>
<has_SideEffects rdf:resource="#Nausea"/>
</owl:Thing>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Nausea -->
<owl:Thing rdf:about="#Nausea">
<rdf:type rdf:resource="#SideEffects"/>
<rdfs:label>Nausea</rdfs:label>
</owl:Thing>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Pseudomonal_Infections -->
<Diseases rdf:about="#Pseudomonal_Infections">
<rdf:type rdf:resource="&owl;Thing"/>
<rdfs:label
>Pseudomonal_Infections</rdfs:label>
</Diseases>
<!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Wide_Range_Of_Infections -->
<owl:Thing rdf:about="#Wide_Range_Of_Infections">
<rdf:type rdf:resource="#Diseases"/>
<rdfs:label
>Wide_Range_Of_Infections</rdfs:label>
</owl:Thing>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// General axioms
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<rdf:Description>
<rdf:type rdf:resource="&owl;AllDisjointClasses"/>
<owl:members rdf:parseType="Collection">
<rdf:Description rdf:about="#Antibiotics"/>
<rdf:Description rdf:about="#Diseases"/>
<rdf:Description rdf:about="#SideEffects"/>
</owl:members>
</rdf:Description>
<rdf:Description>
<rdf:type rdf:resource="&owl;AllDisjointClasses"/>
<owl:members rdf:parseType="Collection">
<rdf:Description rdf:about="#1st_Generation"/>
<rdf:Description rdf:about="#2nd_Generation"/>
<rdf:Description rdf:about="#3rd_Generation"/>
<rdf:Description rdf:about="#Aminopenicillins"/>
<rdf:Description rdf:about="#Lincosamide"/>
</owl:members>
</rdf:Description>
</rdf:RDF>
<!-- Generated by the OWL API (version 2.2.1.1138) http://owlapi.sourceforge.net -->
IRIs are case sensitive. Notice that in your ontology owl:Class uses a majuscule C:
<owl:Class rdf:about="#1st_Generation">
<rdfs:label>1st_Generation</rdfs:label>
<rdfs:subClassOf rdf:resource="#Antibiotics"/>
</owl:Class>
That needs to be the case in your SPARQL query as well. And, if you haven't elsewhere, you'll need to define the prefix. If you stored the data in a graph named http://myexample.com, then you might need to select from that, exactly, with from <http://myexample.com>. Don't drop the http:// prefix. I downloaded your data, and this query produces the following results:
prefix owl: <http://www.w3.org/2002/07/owl#>
select ?class where {
?class a owl:Class
}
---------------------------------------------------------------------------------------------
| class |
=============================================================================================
| owl:Thing |
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#SideEffects> |
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Lincosamide> |
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Diseases> |
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Antibiotics> |
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Aminopenicillins> |
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#3rd_Generation> |
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#2nd_Generation> |
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#1st_Generation> |
---------------------------------------------------------------------------------------------

Extracting the actual value from sparql results

i am using dotnetrdf to write sparql query to get the type, id and explain attributes of an actuator saved in my ontology. im using the following select query.
"PREFIX AP0: <http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#> " +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#>" +
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>" +
"SELECT *"+
"WHERE {"+
"?Name rdf:type AP0:Actuating_Device."+
"?Name AP0:ActuatorID ?id."+
"?Name AP0:ActuatorExplain ?Explain."+
"?Name AP0:AcuatorCode "txtActuatorID.Text"}"
The results are displayed using this method
public void datadisplay1(IEnumerable<string> variables, SparqlResultSet srs)
{
dataGridView1.Columns.Clear();
int vn = 0;
foreach (string v in variables)
{
dataGridView1.Columns.Add(v, v); ;
this.dataGridView1.Columns[vn].Width = 300;
vn++;
}
foreach (SparqlResult r in srs)
{
int i = 0;
object[] items = new object[vn];
foreach (string s in variables)
{
items[i++] = r.Value(s);
}
dataGridView1.Rows.Add(items );
}
here is my owl file
<?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 ace_lexicon "http://attempto.ifi.uzh.ch/ace_lexicon#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY AP0 "http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider" >
<!ENTITY ActuatorProvider "http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#" >
]>
<rdf:RDF xmlns="&AP0;#"
xml:base="http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider"
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:AP0="http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider"
xmlns:ActuatorProvider="&AP0;#"
xmlns:ace_lexicon="http://attempto.ifi.uzh.ch/ace_lexicon#">
<owl:Ontology rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Annotation properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#CN_pl -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;CN_pl"/>
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#CN_sg -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;CN_sg"/>
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#PN_sg -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;PN_sg"/>
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#TV_pl -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;TV_pl"/>
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#TV_sg -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;TV_sg"/>
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#TV_vbg -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;TV_vbg"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ConnectsTo -->
<owl:ObjectProperty rdf:about="&AP0;#ConnectsTo">
<ace_lexicon:TV_pl>ConnectsTo</ace_lexicon:TV_pl>
<ace_lexicon:TV_sg>ConnectsToes</ace_lexicon:TV_sg>
<ace_lexicon:TV_vbg>ConnectsToed</ace_lexicon:TV_vbg>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Perform -->
<owl:ObjectProperty rdf:about="&AP0;#Perform">
<ace_lexicon:TV_pl>Perform</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>Performed</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>Performs</ace_lexicon:TV_sg>
<rdfs:domain rdf:resource="&AP0;#Actuator_Support_Toolbox"/>
<rdfs:range rdf:resource="&AP0;#Management"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Provide -->
<owl:ObjectProperty rdf:about="&AP0;#Provide">
<ace_lexicon:TV_sg>Provides</ace_lexicon:TV_sg>
<ace_lexicon:TV_pl>Provide</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>Provided</ace_lexicon:TV_vbg>
<rdfs:range rdf:resource="&AP0;#APServices"/>
<rdfs:domain rdf:resource="&AP0;#Actuator_Service_Provider"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Use -->
<owl:ObjectProperty rdf:about="&AP0;#Use">
<ace_lexicon:TV_pl>Use</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>Used</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>Uses</ace_lexicon:TV_sg>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#hasState -->
<owl:ObjectProperty rdf:about="&AP0;#hasState">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<ace_lexicon:TV_pl>hasState</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>hasStated</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>hasStates</ace_lexicon:TV_sg>
<rdfs:range rdf:resource="&AP0;#Actuator_State"/>
<rdfs:domain rdf:resource="&AP0;#Device"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorCode -->
<owl:DatatypeProperty rdf:about="&AP0;#ActuatorCode">
<ace_lexicon:TV_sg>ActuatorCodes</ace_lexicon:TV_sg>
<ace_lexicon:TV_pl>ActuatorCode</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>ActuatorCoded</ace_lexicon:TV_vbg>
<rdfs:domain rdf:resource="&AP0;#Actuating_Device"/>
<rdfs:range rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorExplain -->
<owl:DatatypeProperty rdf:about="&AP0;#ActuatorExplain">
<ace_lexicon:TV_vbg>ActuatorExplained</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>ActuatorExplains</ace_lexicon:TV_sg>
<ace_lexicon:TV_pl>ActuatorExplain</ace_lexicon:TV_pl>
<rdfs:domain rdf:resource="&AP0;#Actuating_Device"/>
<rdfs:range rdf:resource="&xsd;string"/>
<rdfs:subPropertyOf rdf:resource="&owl;topDataProperty"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorID -->
<owl:DatatypeProperty rdf:about="&AP0;#ActuatorID">
<ace_lexicon:TV_pl>ActuatorID</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>ActuatorIDed</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>ActuatorIDs</ace_lexicon:TV_sg>
<rdfs:domain rdf:resource="&AP0;#Actuating_Device"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorName -->
<owl:DatatypeProperty rdf:about="&AP0;#ActuatorName">
<ace_lexicon:TV_pl>ActuatorName</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>ActuatorNamed</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>ActuatorNames</ace_lexicon:TV_sg>
<rdfs:domain rdf:resource="&AP0;#Actuating_Device"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#MiddlewareCode -->
<owl:DatatypeProperty rdf:about="&AP0;#MiddlewareCode">
<ace_lexicon:TV_vbg>MiddlewareCoded</ace_lexicon:TV_vbg>
<ace_lexicon:TV_pl>MiddlewareCode</ace_lexicon:TV_pl>
<ace_lexicon:TV_sg>MiddlewareCodes</ace_lexicon:TV_sg>
<rdfs:domain rdf:resource="&AP0;#Actuator_Middleware"/>
<rdfs:range rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#MiddlewareID -->
<owl:DatatypeProperty rdf:about="&AP0;#MiddlewareID">
<ace_lexicon:TV_sg>MiddlewareIDs</ace_lexicon:TV_sg>
<ace_lexicon:TV_pl>MiddlewareID</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>MiddlewareIDed</ace_lexicon:TV_vbg>
<rdfs:domain rdf:resource="&AP0;#Actuator_Middleware"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#MiddlewareRight -->
<owl:DatatypeProperty rdf:about="&AP0;#MiddlewareRight">
<ace_lexicon:TV_vbg>MiddlewareRighted</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>MiddlewareRights</ace_lexicon:TV_sg>
<ace_lexicon:TV_pl>MiddlewareRight</ace_lexicon:TV_pl>
<rdfs:domain rdf:resource="&AP0;#Actuator_Middleware"/>
<rdfs:range rdf:resource="&xsd;boolean"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#PowerConsumption -->
<owl:DatatypeProperty rdf:about="&AP0;#PowerConsumption">
<ace_lexicon:TV_vbg>PowerConsumptioned</ace_lexicon:TV_vbg>
<ace_lexicon:TV_pl>PowerConsumption</ace_lexicon:TV_pl>
<ace_lexicon:TV_sg>PowerConsumptions</ace_lexicon:TV_sg>
<rdfs:domain rdf:resource="&AP0;#Actuating_Device"/>
<rdfs:range rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#APServices -->
<owl:Class rdf:about="&AP0;#APServices">
<ace_lexicon:CN_pl>APServiceses</ace_lexicon:CN_pl>
<ace_lexicon:CN_sg>APServices</ace_lexicon:CN_sg>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuating_Device -->
<owl:Class rdf:about="&AP0;#Actuating_Device">
<rdfs:subClassOf rdf:resource="&AP0;#Device"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#hasState"/>
<owl:onClass rdf:resource="&AP0;#Actuator_State"/>
<owl:qualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:qualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_sg>Actuating_Device</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuating_Devices</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Content_Service -->
<owl:Class rdf:about="&AP0;#Actuator_Content_Service">
<rdfs:subClassOf rdf:resource="&AP0;#APServices"/>
<ace_lexicon:CN_pl>Actuator_Content_Services</ace_lexicon:CN_pl>
<ace_lexicon:CN_sg>Actuator_Content_Service</ace_lexicon:CN_sg>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Control_Service -->
<owl:Class rdf:about="&AP0;#Actuator_Control_Service">
<rdfs:subClassOf rdf:resource="&AP0;#APServices"/>
<ace_lexicon:CN_sg>Actuator_Control_Service</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_Control_Services</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Info_Management -->
<owl:Class rdf:about="&AP0;#Actuator_Info_Management">
<rdfs:subClassOf rdf:resource="&AP0;#Management"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#Use"/>
<owl:someValuesFrom rdf:resource="&AP0;#Actuator_Content_Service"/>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_sg>Actuator_Info_Management</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_Info_Managements</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Middleware -->
<owl:Class rdf:about="&AP0;#Actuator_Middleware">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#ConnectsTo"/>
<owl:onClass rdf:resource="&AP0;#Actuator_Service_Provider"/>
<owl:maxQualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxQualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#Use"/>
<owl:someValuesFrom rdf:resource="&AP0;#Actuator_Control_Service"/>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_sg>Actuator_Middleware</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_Middlewares</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Provider_Service -->
<owl:Class rdf:about="&AP0;#Actuator_Provider_Service">
<rdfs:subClassOf rdf:resource="&AP0;#APServices"/>
<ace_lexicon:CN_sg>Actuator_Provider_Service</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_Provider_Services</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Service_Provider -->
<owl:Class rdf:about="&AP0;#Actuator_Service_Provider">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#ConnectsTo"/>
<owl:someValuesFrom rdf:resource="&AP0;#Actuator_Support_Toolbox"/>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_sg>Actuator_Service_Provider</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_Service_Providers</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_State -->
<owl:Class rdf:about="&AP0;#Actuator_State">
<ace_lexicon:CN_sg>Actuator_State</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_States</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Support_Toolbox -->
<owl:Class rdf:about="&AP0;#Actuator_Support_Toolbox">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#Perform"/>
<owl:someValuesFrom rdf:resource="&AP0;#Management"/>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_pl>Actuator_Support_Toolboxes</ace_lexicon:CN_pl>
<ace_lexicon:CN_sg>Actuator_Support_Toolbox</ace_lexicon:CN_sg>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Device -->
<owl:Class rdf:about="&AP0;#Device">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#hasState"/>
<owl:onClass rdf:resource="&AP0;#Actuator_State"/>
<owl:qualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:qualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#ConnectsTo"/>
<owl:onClass rdf:resource="&AP0;#Actuator_Middleware"/>
<owl:maxQualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxQualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_sg>Device</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Devices</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Management -->
<owl:Class rdf:about="&AP0;#Management">
<ace_lexicon:CN_sg>Management</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Managements</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Middleware_Access_Management -->
<owl:Class rdf:about="&AP0;#Middleware_Access_Management">
<rdfs:subClassOf rdf:resource="&AP0;#Management"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#Use"/>
<owl:someValuesFrom rdf:resource="&AP0;#Actuator_Content_Service"/>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_pl>Middleware_Access_Managements</ace_lexicon:CN_pl>
<ace_lexicon:CN_sg>Middleware_Access_Management</ace_lexicon:CN_sg>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Service_Info_Management -->
<owl:Class rdf:about="&AP0;#Service_Info_Management">
<rdfs:subClassOf rdf:resource="&AP0;#Management"/>
<ace_lexicon:CN_sg>Service_Info_Management</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Service_Info_Managements</ace_lexicon:CN_pl>
</owl:Class>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatingDevice1 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatingDevice1">
<rdf:type rdf:resource="&AP0;#Actuating_Device"/>
<ActuatorName rdf:datatype="&xsd;string">"Fan"</ActuatorName>
<ActuatorID rdf:datatype="&xsd;string">"SD01"</ActuatorID>
<ActuatorExplain rdf:datatype="&xsd;string">"TemperatureControl"</ActuatorExplain>
<ActuatorCode rdf:datatype="&xsd;integer">1</ActuatorCode>
<PowerConsumption rdf:datatype="&xsd;integer">400</PowerConsumption>
<ace_lexicon:PN_sg>ActuatingDevice1</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorMiddleware1"/>
<hasState rdf:resource="&AP0;#Offline"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatingDevice2 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatingDevice2">
<rdf:type rdf:resource="&AP0;#Actuating_Device"/>
<ActuatorExplain rdf:datatype="&xsd;string">"AirConditioner"</ActuatorExplain>
<ActuatorID rdf:datatype="&xsd;string">"DS02"</ActuatorID>
<ActuatorName rdf:datatype="&xsd;string">"LabConditioner"</ActuatorName>
<PowerConsumption rdf:datatype="&xsd;integer">1300</PowerConsumption>
<ActuatorCode rdf:datatype="&xsd;integer">2</ActuatorCode>
<ace_lexicon:PN_sg>ActuatingDevice2</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorMiddleware1"/>
<hasState rdf:resource="&AP0;#Online"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatingDevice3 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatingDevice3">
<rdf:type rdf:resource="&AP0;#Actuating_Device"/>
<ace_lexicon:PN_sg>ActuatingDevice3</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorMiddleware2"/>
<hasState rdf:resource="&AP0;#Waiting"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorMiddleware1 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatorMiddleware1">
<rdf:type rdf:resource="&AP0;#Actuator_Middleware"/>
<MiddlewareID rdf:datatype="&xsd;string">"MW101"</MiddlewareID>
<MiddlewareCode rdf:datatype="&xsd;integer">1</MiddlewareCode>
<MiddlewareRight rdf:datatype="&xsd;boolean">false</MiddlewareRight>
<ace_lexicon:PN_sg>ActuatorMiddleware1</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorServiceProvider1"/>
<Use rdf:resource="&AP0;#ControlService1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorMiddleware2 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatorMiddleware2">
<rdf:type rdf:resource="&AP0;#Actuator_Middleware"/>
<MiddlewareID rdf:datatype="&xsd;string">"MW102"</MiddlewareID>
<MiddlewareCode rdf:datatype="&xsd;integer">2</MiddlewareCode>
<MiddlewareRight rdf:datatype="&xsd;boolean">true</MiddlewareRight>
<ace_lexicon:PN_sg>ActuatorMiddleware2</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorServiceProvider1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorServiceProvider1 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatorServiceProvider1">
<rdf:type rdf:resource="&AP0;#Actuator_Service_Provider"/>
<ace_lexicon:PN_sg>ActuatorServiceProvider1</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorSupportToolbox1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorSupportToolbox1 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatorSupportToolbox1">
<rdf:type rdf:resource="&AP0;#Actuator_Support_Toolbox"/>
<ace_lexicon:PN_sg>ActuatorSupportToolbox1</ace_lexicon:PN_sg>
<Perform rdf:resource="&AP0;#Management1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ControlService1 -->
<owl:NamedIndividual rdf:about="&AP0;#ControlService1">
<ace_lexicon:PN_sg>ControlService1</ace_lexicon:PN_sg>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Management1 -->
<owl:NamedIndividual rdf:about="&AP0;#Management1">
<ace_lexicon:PN_sg>Management1</ace_lexicon:PN_sg>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Offline -->
<owl:NamedIndividual rdf:about="&AP0;#Offline">
<rdf:type rdf:resource="&AP0;#Actuator_State"/>
<ace_lexicon:PN_sg>Offline</ace_lexicon:PN_sg>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Online -->
<owl:NamedIndividual rdf:about="&AP0;#Online">
<rdf:type rdf:resource="&AP0;#Actuator_State"/>
<ace_lexicon:PN_sg>Online</ace_lexicon:PN_sg>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Waiting -->
<owl:NamedIndividual rdf:about="&AP0;#Waiting">
<rdf:type rdf:resource="&AP0;#Actuator_State"/>
<ace_lexicon:PN_sg>Waiting</ace_lexicon:PN_sg>
</owl:NamedIndividual>
</rdf:RDF>
Im using a gridview in c# to display the results in. Its giving me the results in this form
http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatingDevice1
TemperatureControl^^http://www.w3.org/2001/XMLSchema#anyURI
SD01^^http://www.w3.org/2001/XMLSchema#anyURI
How can i remove the URI from the results.
Well you haven't shown a complete example so we can't tell how you display the SPARQL results so it is hard to answer for your specific problem (because you haven't stated one!). However I can attempt to provide some general pointers.
The data you are seeing is the full form of the INode instances that occur in each column so the first thing you need to do if you want to access only parts of the value is get as the actual node. This can be done in several ways:
//Assuming your result row is in a variable r
//With Named Indexing
INode value = r["var"];
//With Indexing
INode value = r[0];
//With method
INode value = r.Value("var");
Pick whichever is most suitable for your use case, once you have the node we can then check what kind of node it is and act accordingly:
String text;
switch (value.NodeType)
{
case NodeType.Literal:
// Cast to more specific ILiteralNode in order to extract just the text
// excluding the data type or language specifier if present
ILiteralNode lit = (ILiteralNode)value;
text = lit.Value;
break;
case NodeType.Uri:
// Case to more specific IUriNode in order to extract final segment of URI
IUriNode uri = (IUriNode)value;
// Depending on the URI format this might be in the Fragment,
// the last Path Segment or just the URI
text = !String.IsNullOrEmpty(uri.Uri.Fragment) ? uri.Uri.Fragment : (uri.Uri.Segments.Length > 0 ? uri.Uri.Segments[uri.Uri.Segments.Length - 1] : uri.Uri.ToString());
break;
default:
// For anything else default to ToString()
text = value.ToString();
}
// Now do what you want with the text
You may need to encapsulate this in a reusable class/method depending on where and how you need to invoke it.
Note that if you are binding it to some kind of control in a GUI application then there are usually ways to customise how the data is presented while maintaining the actual data under the hood.
Adding what I believe to be the best solution:
just use .AsValuedNode(), and then AsInteger() or any other function that gives you your preferred value type, e.g.:
//Assuming we have a Node in the variable n already
IValuedNode value = n.AsValuedNode();
//Get the integer value
int i = value.AsInteger();
I believe to be significantly better than the switch case in #RobV's answer (kudos to that answer though, as it led me in the right direction).
I got the answer using the following in my query
SELECT ?ind (str(?Name) as ?name) (str(?Explain)as ?explain) (str(?id) as ?actid)
WHERE {.....}.

How should I traverse my ontology model?

How can I traverse my ontology file? I want to get the subclasses of the class Shape and the properties associated with it. I have seen the example of traversing the Pizza ontology file but I'm not able to manipulate for my purpose. I'm getting a lot of errors.
<?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 SBIRS "http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#"
xml:base="http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:SBIRS="http://www.semanticweb.org/ontologies/2012/0/SBIRS.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#">
<owl:Ontology rdf:about="http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasArmBone -->
<owl:ObjectProperty rdf:about="&SBIRS;hasArmBone">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasShape"/>
<owl:inverseOf rdf:resource="&SBIRS;isArmBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasCranialBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasCranialBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasSkullBone"/>
<owl:inverseOf rdf:resource="&SBIRS;isFacialBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasEthmoidBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasEthmoidBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasCranialBones"/>
<owl:inverseOf rdf:resource="&SBIRS;isTemporalBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasFacialBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasFacialBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasSkullBone"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasForeArmsBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasForeArmsBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasArmBone"/>
<owl:inverseOf rdf:resource="&SBIRS;isForeArmBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasFrontalBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasFrontalBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasCranialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasHumerusBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasHumerusBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasArmBone"/>
<owl:inverseOf rdf:resource="&SBIRS;isArmBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasInferiornasalBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasInferiornasalBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasFacialBones"/>
<owl:inverseOf rdf:resource="&SBIRS;isFacialBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasLacrimalBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasLacrimalBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasFacialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasMandibleBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasMandibleBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasFacialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasMaxilaBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasMaxilaBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasFacialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasNasalBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasNasalBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasFacialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasOccipitalBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasOccipitalBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasCranialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasParietalBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasParietalBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasCranialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasRadiusBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasRadiusBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasForeArmsBones"/>
<owl:inverseOf rdf:resource="&SBIRS;isRadiusBoneof"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasRibsBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasRibsBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;haschestBone"/>
<owl:inverseOf rdf:resource="&SBIRS;isSternumboneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasShape -->
<owl:ObjectProperty rdf:about="&SBIRS;hasShape">
<owl:inverseOf rdf:resource="&SBIRS;isShapeOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasShenoidBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasShenoidBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasCranialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasSkullBone -->
<owl:ObjectProperty rdf:about="&SBIRS;hasSkullBone">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasShape"/>
<owl:inverseOf rdf:resource="&SBIRS;isSkullBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasSternumBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasSternumBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;haschestBone"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasTemporalBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasTemporalBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasCranialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasUlnabones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasUlnabones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasForeArmsBones"/>
<owl:inverseOf rdf:resource="&SBIRS;isUlnaBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasVomerBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasVomerBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasFacialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasZygomativBones -->
<owl:ObjectProperty rdf:about="&SBIRS;hasZygomativBones">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasFacialBones"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#haschestBone -->
<owl:ObjectProperty rdf:about="&SBIRS;haschestBone">
<rdfs:subPropertyOf rdf:resource="&SBIRS;hasShape"/>
<owl:inverseOf rdf:resource="&SBIRS;isChestBoneOf"/>
<owl:inverseOf rdf:resource="&SBIRS;isSkullBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isArmBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isArmBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isShapeOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isChestBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isChestBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isShapeOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isCranialBonOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isCranialBonOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isSkullBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isEthmoidboneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isEthmoidboneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isCranialBonOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isFacialBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isFacialBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isSkullBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isForeArmBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isForeArmBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isArmBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isFrontalBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isFrontalBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isCranialBonOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isHumerusBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isHumerusBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isArmBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isInferiornasalBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isInferiornasalBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isFacialBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isLacrimalBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isLacrimalBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isFacialBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isMandiblBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isMandiblBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isFacialBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isMaxilaBoneOF -->
<owl:ObjectProperty rdf:about="&SBIRS;isMaxilaBoneOF">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isFacialBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isNasalBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isNasalBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isFacialBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isOccipitalBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isOccipitalBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isCranialBonOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isParietalBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isParietalBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isCranialBonOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isRadiusBoneof -->
<owl:ObjectProperty rdf:about="&SBIRS;isRadiusBoneof">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isForeArmBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isRibBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isRibBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isChestBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isShapeOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isShapeOf"/>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isShenoidBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isShenoidBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isCranialBonOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isSkullBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isSkullBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isShapeOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isSternumboneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isSternumboneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isChestBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isTemporalBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isTemporalBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isCranialBonOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isUlnaBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isUlnaBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isForeArmBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isVomerBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isVomerBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isFacialBoneOf"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isZygomaticBoneOf -->
<owl:ObjectProperty rdf:about="&SBIRS;isZygomaticBoneOf">
<rdfs:subPropertyOf rdf:resource="&SBIRS;isFacialBoneOf"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Arm -->
<owl:Class rdf:about="&SBIRS;Arm">
<rdfs:subClassOf rdf:resource="&SBIRS;Shape"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Chest -->
<owl:Class rdf:about="&SBIRS;Chest">
<rdfs:subClassOf rdf:resource="&SBIRS;Shape"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Cranial -->
<owl:Class rdf:about="&SBIRS;Cranial">
<rdfs:subClassOf rdf:resource="&SBIRS;Skull"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#FacialBones -->
<owl:Class rdf:about="&SBIRS;FacialBones">
<rdfs:subClassOf rdf:resource="&SBIRS;Skull"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#ForeArms -->
<owl:Class rdf:about="&SBIRS;ForeArms">
<rdfs:subClassOf rdf:resource="&SBIRS;Arm"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Humerus -->
<owl:Class rdf:about="&SBIRS;Humerus">
<rdfs:subClassOf rdf:resource="&SBIRS;Arm"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Ribs -->
<owl:Class rdf:about="&SBIRS;Ribs">
<rdfs:subClassOf rdf:resource="&SBIRS;Chest"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Shape -->
<owl:Class rdf:about="&SBIRS;Shape"/>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Skull -->
<owl:Class rdf:about="&SBIRS;Skull">
<rdfs:subClassOf rdf:resource="&SBIRS;Shape"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Sternum -->
<owl:Class rdf:about="&SBIRS;Sternum">
<rdfs:subClassOf rdf:resource="&SBIRS;Chest"/>
</owl:Class>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Ethmoid -->
<owl:NamedIndividual rdf:about="&SBIRS;Ethmoid">
<rdf:type rdf:resource="&SBIRS;Cranial"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#FrontalBones -->
<owl:NamedIndividual rdf:about="&SBIRS;FrontalBones">
<rdf:type rdf:resource="&SBIRS;Cranial"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Inferior_Nasal -->
<owl:NamedIndividual rdf:about="&SBIRS;Inferior_Nasal">
<rdf:type rdf:resource="&SBIRS;FacialBones"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Lacrimal -->
<owl:NamedIndividual rdf:about="&SBIRS;Lacrimal">
<rdf:type rdf:resource="&SBIRS;FacialBones"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Mandible -->
<owl:NamedIndividual rdf:about="&SBIRS;Mandible">
<rdf:type rdf:resource="&SBIRS;FacialBones"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Maxilla -->
<owl:NamedIndividual rdf:about="&SBIRS;Maxilla">
<rdf:type rdf:resource="&SBIRS;FacialBones"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Nasal -->
<owl:NamedIndividual rdf:about="&SBIRS;Nasal">
<rdf:type rdf:resource="&SBIRS;FacialBones"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Occipital -->
<owl:NamedIndividual rdf:about="&SBIRS;Occipital">
<rdf:type rdf:resource="&SBIRS;Cranial"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Parietal -->
<owl:NamedIndividual rdf:about="&SBIRS;Parietal">
<rdf:type rdf:resource="&SBIRS;Cranial"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Radius -->
<owl:NamedIndividual rdf:about="&SBIRS;Radius">
<rdf:type rdf:resource="&SBIRS;ForeArms"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Sphenoid -->
<owl:NamedIndividual rdf:about="&SBIRS;Sphenoid">
<rdf:type rdf:resource="&SBIRS;Cranial"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Temporal -->
<owl:NamedIndividual rdf:about="&SBIRS;Temporal">
<rdf:type rdf:resource="&SBIRS;Cranial"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Ulna -->
<owl:NamedIndividual rdf:about="&SBIRS;Ulna">
<rdf:type rdf:resource="&SBIRS;ForeArms"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Vomer -->
<owl:NamedIndividual rdf:about="&SBIRS;Vomer">
<rdf:type rdf:resource="&SBIRS;FacialBones"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Zygomatic -->
<owl:NamedIndividual rdf:about="&SBIRS;Zygomatic">
<rdf:type rdf:resource="&SBIRS;FacialBones"/>
</owl:NamedIndividual>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// General axioms
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<rdf:Description>
<rdf:type rdf:resource="&owl;AllDisjointClasses"/>
<owl:members rdf:parseType="Collection">
<rdf:Description rdf:about="&SBIRS;Arm"/>
<rdf:Description rdf:about="&SBIRS;ForeArms"/>
<rdf:Description rdf:about="&SBIRS;Humerus"/>
</owl:members>
</rdf:Description>
<rdf:Description>
<rdf:type rdf:resource="&owl;AllDisjointClasses"/>
<owl:members rdf:parseType="Collection">
<rdf:Description rdf:about="&SBIRS;Chest"/>
<rdf:Description rdf:about="&SBIRS;Ribs"/>
<rdf:Description rdf:about="&SBIRS;Sternum"/>
</owl:members>
</rdf:Description>
<rdf:Description>
<rdf:type rdf:resource="&owl;AllDisjointClasses"/>
<owl:members rdf:parseType="Collection">
<rdf:Description rdf:about="&SBIRS;Cranial"/>
<rdf:Description rdf:about="&SBIRS;FacialBones"/>
<rdf:Description rdf:about="&SBIRS;Skull"/>
</owl:members>
</rdf:Description>
<rdf:Description>
<rdf:type rdf:resource="&owl;AllDisjointClasses"/>
<owl:members rdf:parseType="Collection">
<rdf:Description rdf:about="&SBIRS;Arm"/>
<rdf:Description rdf:about="&SBIRS;Chest"/>
<rdf:Description rdf:about="&SBIRS;Shape"/>
<rdf:Description rdf:about="&SBIRS;Skull"/>
</owl:members>
</rdf:Description>
Was it really necessary to post all 700+ lines of your ontology to ask this question? A little help to trim the question down to its minimal form is always appreciated. Also, if your code has errors it's much easier for us to help you fix it if you, you know, actually show us the code.
Anyway, here's a simple program that:
finds the sbirs:Shape class
iterates through the sub-classes of that class
prints the declared properties of the sub-class
Code:
package example;
import java.util.Iterator;
import com.hp.hpl.jena.ontology.*;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;
public class SbirsExample
{
public static void main( String[] args ) {
new SbirsExample().run();
}
public void run() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
FileManager.get().readModel( m, "src/main/resources/sbirs.owl" );
String NS = "http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#";
OntClass shape = m.getOntClass( NS + "Shape" );
for (Iterator<OntClass> subs = shape.listSubClasses();
subs.hasNext(); ) {
OntClass sub = subs.next();
System.out.println( "sbirs:Shape has sub-class " + sub.getURI() +
" with declared properties:" );
for (Iterator<OntProperty> props = sub.listDeclaredProperties();
props.hasNext(); ) {
OntProperty declared = props.next();
System.out.println( " - " + declared );
}
}
}
}
Output:
sbirs:Shape has sub-class http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Skull with declared properties:
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasRadiusBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isRadiusBoneof
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasInferiornasalBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasCranialBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasVomerBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isMandiblBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasOccipitalBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isInferiornasalBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isCranialBonOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasArmBone
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isZygomaticBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasShape
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasFacialBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasNasalBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasHumerusBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isLacrimalBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isUlnaBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasForeArmsBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isSkullBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isOccipitalBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasFrontalBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isShenoidBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isMaxilaBoneOF
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasSternumBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasMaxilaBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isShapeOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasMandibleBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isArmBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isFrontalBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasZygomativBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasLacrimalBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasTemporalBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isRibBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasShenoidBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasSkullBone
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#haschestBone
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isChestBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isHumerusBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isParietalBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isTemporalBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isEthmoidboneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isFacialBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasUlnabones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasEthmoidBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasRibsBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isNasalBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasParietalBones
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isVomerBoneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isSternumboneOf
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#isForeArmBoneOf
sbirs:Shape has sub-class http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#Chest with declared properties:
- http://www.semanticweb.org/ontologies/2012/0/SBIRS.owl#hasRadiusBones
... etc ...