0

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 &quot;Information assets classification and control&quot; 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.

  1. How can I fix this so that I can fetch all the policies which are type of local_policies?
  2. Also I would like to narrow down the search query where polices which apply to particular focusArea such as <apply rdf:resource="http://mywebsite.com/module/ontologies/focusArea1"/>. If so how can I extend this query policies which has a focusArea as well ?
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Techie
  • 44,706
  • 42
  • 157
  • 243
  • What are you extracting and what are you expecting to extract? This query is alright. The only thing that comes to mind is that the policies you are not retrieving have different URIs than `http://mywebsite.com/module/ontologies/`. – Artemis Apr 13 '15 at 12:54
  • I extract nothing. Query returned nothing. I just want to extract above mentioned set of owl:NamedIndividual(Policies) – Techie Apr 13 '15 at 13:01

1 Answers1

1

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.

Artemis
  • 3,271
  • 2
  • 20
  • 33
  • +1, Thank you very much but it only fetch title which is `http://mywebsite.com/module/ontologies/policy1`, how can I fetch the other details such as PolicyDesc, PolicyConsulted, PolicyMaturityLevel etc – Techie Apr 13 '15 at 14:20
  • What's `a` mean in the query? Please be kind enough to explain the query since I'm new the SPARQL. – Techie Apr 13 '15 at 14:26
  • 1
    `a` replaces `rdf:type`. To fetch everything you need to add more `?x ?w ?z`. For each replace ?z with what you are looking for. – Artemis Apr 13 '15 at 14:33
  • I don't know whether I'm being stupid but where does the `a` comes from? And I tried you as proposed but it does work and I don't know why. `PREFIX rdf: prefix rdfs: prefix owl: prefix : SELECT ?x, ?w WHERE { ?x a :local_policy . ?w a :PolicyName }` – Techie Apr 13 '15 at 14:43
  • Also I tried this as well but the same result `PREFIX rdf: prefix rdfs: prefix owl: prefix : SELECT ?x ?PolicyName WHERE { ?x a :local_policy . }` – Techie Apr 13 '15 at 14:45
  • 1
    Basically `rdf:type`and `a` are equivalent. Nothing else can be replaced by `a`. Your `?policyName` is not a type but a restriction. I'll edit my answer. – Artemis Apr 13 '15 at 14:46
  • Okay thanks but why doesn't it work when I add `PolicyName` as you proposed? Where am I going wrong? – Techie Apr 13 '15 at 14:48
  • 1
    `local_policy` is a super class, but `PolicyName` is a restriction. – Artemis Apr 13 '15 at 14:50
  • Thanks for the updating the answer but I still have only one question. What I want to do is retrieve all the data under `policy1 `. I mean the whole dataset such as ` 1.1.1 CIO Information Security ` etc. All the nodes – Techie Apr 13 '15 at 15:00
  • Please see the above comments for what I have tried. I hope that will give you an idea what I want to do – Techie Apr 13 '15 at 15:01
  • 1
    Try replace your where part with `WHERE { ?subject a :local_policy. ?subject ?a ?b}`. This should give you all the information about every `?subject` and if you want only to find out a specific `?subject` try: `WHERE {?subject a :local_policy. ?subject ?a ?b. filter (?subject= :policy1}` – Artemis Apr 13 '15 at 15:10