I'm using Protege-5.0.0-beta-17
to develop an ontology and apache-jena-fuseki-2.0.0
to host the ontology. It has following individuals. Background of this scenario is that there are policy individuals under http://mywebsite.com/module/ontologies/local_policy
. Basically policies are type of the local_policies.
<!-- http://mywebsite.com/module/ontologies/policy1 -->
<owl:NamedIndividual rdf:about="http://mywebsite.com/module/ontologies/policy1">
<rdf:type rdf:resource="http://mywebsite.com/module/ontologies/local_policy"/>
<PolicyName rdf:datatype="&xsd;string">1.1.1</PolicyName>
<PolicyResponsibility rdf:datatype="&xsd;string">CIO</PolicyResponsibility>
<PolicyKeyword rdf:datatype="&xsd;string">Information Security</PolicyKeyword>
<PolicyMaturityLevel rdf:datatype="&xsd;string">Interactive-Information</PolicyMaturityLevel>
<PolicyConsulted rdf:datatype="&xsd;string">CERT</PolicyConsulted>
<PolicyDesc rdf:datatype="&xsd;string">The relevant sections of Information Security Policy which has been published by government should be used for classifying organizational data and information. The particular policies have been elaborated in "Information assets classification and control" of the Information Security (IS) policy (http://www.government.lk/images/secPolicy/Asset_Classification_and_Control.doc). The Assistance of Computer Emergency Readiness Team (CERT) could be obtained for this purpose.</PolicyDesc>
<apply rdf:resource="http://mywebsite.com/module/ontologies/focusArea1"/>
</owl:NamedIndividual>
<!-- http://mywebsite.com/module/ontologies/policy2 -->
<owl:NamedIndividual rdf:about="http://mywebsite.com/module/ontologies/policy2">
<rdf:type rdf:resource="http://mywebsite.com/module/ontologies/local_policy"/>
<PolicyName rdf:datatype="&xsd;string">2</PolicyName>
<PolicyResponsibility rdf:datatype="&xsd;string">CIO</PolicyResponsibility>
<PolicyKeyword rdf:datatype="&xsd;string">Information Security</PolicyKeyword>
<PolicyMaturityLevel rdf:datatype="&xsd;string">Interactive-Information</PolicyMaturityLevel>
<PolicyConsulted rdf:datatype="&xsd;string">CERT</PolicyConsulted>
<PolicyDesc rdf:datatype="&xsd;string">The policies defined under the “Privacy and Citizen Information Protection” of the IS policy which have been published by government should be implemented. The guidelines provided in the above section of IS policy could be accessed through (http://www.government.lk/images/secPolicy/Privacy__Citizen_Information_Protection.doc). The assistance of CERT could be obtained for achieving this purpose.</PolicyDesc>
<apply rdf:resource="http://mywebsite.com/module/ontologies/focusArea2"/>
</owl:NamedIndividual>
<!-- http://mywebsite.com/module/ontologies/policy3 -->
<owl:NamedIndividual rdf:about="http://mywebsite.com/module/ontologies/policy3">
<rdf:type rdf:resource="http://mywebsite.com/module/ontologies/local_policy"/>
<PolicyName rdf:datatype="&xsd;string">3</PolicyName>
<PolicyDesc rdf:datatype="&xsd;string">A matrix could be defined for identifying all possible audience and possible delivery channels of organizational data/information. The template given in Annex 001 could be used for this purpose. (refer Annex 001 – Information/Data classification matrix)</PolicyDesc>
<PolicyResponsibility rdf:datatype="&xsd;string">CIO</PolicyResponsibility>
<PolicyConsulted rdf:datatype="&xsd;string">government</PolicyConsulted>
<PolicyMaturityLevel rdf:datatype="&xsd;string">Initial Infomration</PolicyMaturityLevel>
<PolicyKeyword rdf:datatype="&xsd;string">Service Delivery Channels</PolicyKeyword>
<apply rdf:resource="http://mywebsite.com/module/ontologies/focusArea3"/>
</owl:NamedIndividual>
What I'm trying to do is query the ontology and fetch the these individuals. Also note that there are other individuals as well. Below is the query I'm using.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
SELECT ?x
WHERE {
?x rdf:type "http://mywebsite.com/module/ontologies/local_policy"
}
But it does nt fetch the individuals as expected.
<apply rdf:resource="http://mywebsite.com/module/ontologies/focusArea1"/>
. If so how can I extend this query policies which has a focusArea as well ?You need to change your query to this:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix : <http://mywebsite.com/module/ontologies/>
SELECT ?x
WHERE {
?x a :local_policy
}
The element you are lookig for is not a string, but a concept.
Also, to add another restriction you just need to add the equivalent of:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix : <http://mywebsite.com/module/ontologies/>
SELECT ?x
WHERE {
?x a :local_policy.
?x ?y :focusArea1.
?x ?w :PolicyName.
}
Here you are basically saying I am looking for ?x
that has type :local_policy
and it has the restrictions on properties :focusArea1
. If it doesn't work with :focusArea1
and :PolicyName
try replacing them with another variable such as ?s
and see where does focusArea1
appear. Does it appear in place of ?y
or ?s
. Then you know where to put your variable. But I suspect that you need to put it as the last element.