Sesame 2.8.4 subquery limit bug fix? - sparql

It seems that there is bug in Sesame 2.8.4.
If I have the following data set:
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
#prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
#prefix : <http://example.org/>.
:a rdf:type :AClass .
:a :hasName "a"^^xsd:string .
:a :hasProperty :xa .
:a :hasProperty :ya .
:a :hasProperty :za .
:b rdf:type :AClass .
:b :hasName "b"^^xsd:string .
:b :hasProperty :xb .
:b :hasProperty :yb .
:c rdf:type :AClass .
:c :hasName "c"^^xsd:string .
:c :hasProperty :xc .
and run the following query on it:
prefix : <http://example.org/>
select ?s ?p ?o {
#-- first, select two instance of :AClass
{ select ?s { ?s a :AClass } limit 2 }
#-- then, select all the triples of
#-- which they are subjects
?s ?p ?o
}
The result I get back is this:
--------------------------------------------------------------------
| s | p | o |
====================================================================
| :a | <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> | :AClass |
| :a | :hasName | "a" |
--------------------------------------------------------------------
Instead of this one which is the correct result:
--------------------------------------------------------------------
| s | p | o |
====================================================================
| :a | <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> | :AClass |
| :a | :hasName | "a" |
| :a | :hasProperty | :xa |
| :a | :hasProperty | :ya |
| :a | :hasProperty | :za |
| :b | <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> | :AClass |
| :b | :hasName | "b" |
| :b | :hasProperty | :xb |
| :b | :hasProperty | :yb |
--------------------------------------------------------------------
Does anyone know about this bug? Has anybody encountered the same problem? Or is there another version of Sesame with this bug fixed?
The next line was added after my question was answered:
To avoid any confusions: The bug is in the Workbench and NOT the query engine.
The query engine works perfectly.

The problem you are seeing is not a bug in the query engine, but a bug in the Workbench client application (which also explains why I couldn't reproduce it earlier, as I was using the commandline client). For some reason Workbench incorrectly renders the result, showing only 2 rows (despite saying in the header that there are 9 results to be shown):
The problem is related to the result paging functionality in the Workbench, because when you change that setting it suddenly does show the complete result:
This issue has now been logged as a bug in Sesame's issue tracker: SES-2307.

Related

Why does this SPARQL query return certain items as subjects?

I have the following data graph:
#prefix hr: <http://learningsparql.com/ns/humanResources#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix sch: <http://schema.org/> .
#prefix xml: <http://www.w3.org/XML/1998/namespace> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
hr:Another a rdfs:Class .
hr:Employee a rdfs:Class ;
rdfs:label "model" ;
rdfs:comment "a good employee" .
hr:Longer a hr:Employee ;
rdfs:label "model" ;
rdfs:comment "a good employee" .
hr:freestanding a rdf:Property ;
sch:rangeIncludes sch:Text .
hr:missing rdfs:comment "some comment about missing" .
hr:name a rdf:Property ;
sch:domainIncludes hr:Employee .
hr:nosuper a rdf:Property ;
sch:domainIncludes hr:Uncreated ;
sch:rangeIncludes sch:Text .
hr:randomtype a hr:invalidtype ;
rdfs:label "some label about randomtype" ;
rdfs:comment "some comment about randomtype" .
hr:typo a rdfs:Classs ;
rdfs:label "some label about typo" ;
rdfs:comment "some comment about typo" .
The only subjects defined in the triples are hr:Another, hr:Employee, hr:Longer, hr:freestanding, hr:missing, hr:name, hr:nosuper, hr:randomtype, and hr:typo. As proof, when I run the query:
SELECT DISTINCT ?s
WHERE {
?s ?p ?o .
}
I get the result:
--------------------------------------------------------------
| s |
==============================================================
| <http://learningsparql.com/ns/humanResources#freestanding> |
| <http://learningsparql.com/ns/humanResources#Another> |
| <http://learningsparql.com/ns/humanResources#typo> |
| <http://learningsparql.com/ns/humanResources#nosuper> |
| <http://learningsparql.com/ns/humanResources#Employee> |
| <http://learningsparql.com/ns/humanResources#randomtype> |
| <http://learningsparql.com/ns/humanResources#Longer> |
| <http://learningsparql.com/ns/humanResources#missing> |
| <http://learningsparql.com/ns/humanResources#name> |
--------------------------------------------------------------
However, if I execute this SPARQL query:
SELECT DISTINCT ?s
WHERE {
{
?s rdf:type* ?o .
}
}
I get the following results:
--------------------------------------------------------------
| s |
==============================================================
| <http://learningsparql.com/ns/humanResources#Longer> |
| rdfs:Class |
| sch:Text |
| "some comment about typo" |
| "some label about typo" |
| <http://learningsparql.com/ns/humanResources#nosuper> |
| "a good employee" |
| <http://learningsparql.com/ns/humanResources#Uncreated> |
| <http://learningsparql.com/ns/humanResources#missing> |
| "some comment about randomtype" |
| "model" |
| <http://learningsparql.com/ns/humanResources#freestanding> |
| "some label about randomtype" |
| "some comment about missing" |
| <http://learningsparql.com/ns/humanResources#Another> |
| <http://learningsparql.com/ns/humanResources#invalidtype> |
| <http://learningsparql.com/ns/humanResources#typo> |
| <http://learningsparql.com/ns/humanResources#randomtype> |
| <http://learningsparql.com/ns/humanResources#Employee> |
| rdfs:Classs |
| rdf:Property |
| <http://learningsparql.com/ns/humanResources#name> |
--------------------------------------------------------------
I am not sure why items like rdf:Property, "a good employee", sch:Text, etc. are being returned as subjects when they are not subjects in the data graph.
Why are they?
Clearly, this has something to do with how SPARQL handles property paths which I do not yet understand.
You are using a property path with a zero-or-more wildcard ('*'). Effectively, the pattern ?s rdf:type* ?o means "every value ?s connected through zero or more type relations to any value ?o".
Every value that appears in your graph (in fact every value in any graph) matches that, because every value has at least zero type relations. Therefore, a value like "some comment about typo" get returned, because although it never occurs as a subject in your data, it is true that it is a value that has zero type relations to something else.

SPARQL filter/aggregate results by subgraph

I would like to write a query which filters out some results by using some other properties of the graph. I explain with this example.
I am modelling a permissions system. There are some subjects, resources and permissions. Subjects have certain permissions on resources. Some permissions imply other permissions. A simplified example with 3 permissions, and 3 resources that the single subject has one (two in one case) of those permissions on.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://schema#>
PREFIX d: <http://data#>
INSERT DATA {
:Permission rdf:type rdf:Property .
:Read rdf:type rdf:Property ;
rdfs:subPropertyOf :Permission .
:Write rdf:type rdf:Property ;
rdfs:subPropertyOf :Permission ;
:implies :Read .
:Admin rdf:type rdf:Property ;
rdfs:subPropertyOf :Permission ;
:implies :Write ,
:Read .
d:s1 rdf:type :Subject .
d:r1 rdf:type :Resource .
d:r2 rdf:type :Resource .
d:r3 rdf:type :Resource .
d:s1 :Admin d:r1 .
d:s1 :Read d:r1 .
d:s1 :Write d:r2 .
d:s1 :Read d:r3 .
}
I can easily write a query to see for a given subject, what the implied permissions are on some resources.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://schema#>
PREFIX d: <http://data#>
SELECT DISTINCT ?subject ?resource ?implied (?permission AS ?implied_by)
WHERE {
BIND(d:s1 AS ?subject)
?resource rdf:type :Resource .
?subject rdf:type :Subject .
?permission rdfs:subPropertyOf :Permission ;
:implies* ?implied .
?subject ?permission ?resource .
}
This will give some results like:
+----------------+----------------+---------------------+---------------------+
| subject | resource | implied | implied_by |
+----------------+----------------+---------------------+---------------------+
| http://data#s1 | http://data#r1 | http://schema#Admin | http://schema#Admin |
| http://data#s1 | http://data#r1 | http://schema#Read | http://schema#Admin |
| http://data#s1 | http://data#r1 | http://schema#Write | http://schema#Admin |
| http://data#s1 | http://data#r1 | http://schema#Read | http://schema#Read |
| http://data#s1 | http://data#r3 | http://schema#Read | http://schema#Read |
| http://data#s1 | http://data#r2 | http://schema#Write | http://schema#Write |
| http://data#s1 | http://data#r2 | http://schema#Read | http://schema#Write |
+----------------+----------------+---------------------+---------------------+
What I would like to do is write a query which only returns the minimum list of permissions per resource which imply all the others. Any ideas on how I would achieve this efficiently would be most welcome. This seems a bit like a MAX aggregation, but where a graph is actually needed to determine the results. For example, the ideal results would be:
+----------------+----------------+---------------------+---------------------+
| subject | resource | implied | implied_by |
+----------------+----------------+---------------------+---------------------+
| http://data#s1 | http://data#r1 | http://schema#Admin | http://schema#Admin |
| http://data#s1 | http://data#r3 | http://schema#Read | http://schema#Read |
| http://data#s1 | http://data#r2 | http://schema#Write | http://schema#Write |
+----------------+----------------+---------------------+---------------------+
Note that the data and queries are actually more complicated that this so it is absolutely necessary for me to use the parameter path even though I then want to get rid of most of the information it introduces.
?permission rdfs:subPropertyOf :Permission ;
:implies* ?implied .
Note also that I thought of adding an integer value to each permission so that I could simply get the minimum value of this field, but my permission structure is not single rooted in reality, so sometimes this would not be appropriate.
Effectively the question is how to remove any permissions (for a resource) which are implied by other results (for that resource)

Can't infer an interesting pizza

I have loaded the pizza ontology into Stardog and Blazegraph, along with some triples I authored, including a pizza with four toppings. I have tried to make the toppings distinct, as #AKSW suggested.
The pizza ontology defines an interesting pizza as a pizza with at least three toppings. I'm pretty sure I have OWL reasoning enabled, but neither triplestore says that my pizza is interesting.
Can anybody show me settings that enable this inference in any freely available triplestore or point out what I've done wrong with my triples?
Especially, should I be able to infer that pizza instances, pizza classes, or both are "interesting"?
Interesting pizza definition:
pizza:InterestingPizza rdf:type owl:Class ;
owl:equivalentClass [ owl:intersectionOf ( pizza:Pizza
[ rdf:type owl:Restriction ;
owl:onProperty pizza:hasTopping ;
owl:minCardinality "3"^^xsd:nonNegativeInteger
]
) ;
rdf:type owl:Class
] ;
rdfs:label "PizzaInteressante"#pt .
My additional triples:
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#> .
<http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaClass>
a owl:Class ;
owl:equivalentClass [
a owl:Restriction ;
owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#CaperTopping>
], [
a owl:Restriction ;
owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#JalapenoPepperTopping>
], [
a owl:Restriction ;
owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#LeekTopping>
], [
a owl:Restriction ;
owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#MozzarellaTopping>
], [
a owl:Restriction ;
owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#PineKernels>
] ;
rdfs:subClassOf <http://www.co-ode.org/ontologies/pizza/pizza.owl#Pizza> ;
rdfs:label "mark's pizza class" .
<http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaClassMember>
a owl:NamedIndividual, <http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaClass> ;
rdfs:label "a member of the mark's pizza class" .
<http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaInstance>
a owl:NamedIndividual, <http://www.co-ode.org/ontologies/pizza/pizza.owl#Pizza> ;
pizza:hasTopping pizza:marksPeppers, pizza:topping1, pizza:topping2, pizza:topping3, pizza:topping4 ;
rdfs:label "mark's pizza instance" .
pizza:marksPeppers
a owl:NamedIndividual, pizza:JalapenoPepperTopping ;
rdfs:label "mark's special spicy jalapenos" .
pizza:topping1
a owl:NamedIndividual, pizza:MozzarellaTopping ;
rdfs:label "mark's semi secret topping one" .
pizza:topping2
a owl:NamedIndividual, pizza:PineKernels ;
rdfs:label "mark's semi secret topping two" .
pizza:topping3
a owl:NamedIndividual, pizza:CaperTopping ;
rdfs:label "mark's semi secret topping three" .
pizza:topping4
a owl:NamedIndividual, pizza:LeekTopping ;
rdfs:label "mark's semi secret topping four" .
[]
a owl:AllDifferent ;
owl:distinctMembers (
pizza:marksPeppers
pizza:topping1
pizza:topping2
pizza:topping3
pizza:topping4
) .
Query for any knowledge about a pizza instance with five distinct toppings:
prefix pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
select *
where
{ pizza:marksPizzaInstance ?p ?o }
Result from Stardog (I have manually replaced full URIs with prefixed URIs):
+---------------------+----------------------------+
| p | o |
+---------------------+----------------------------+
| pizza:hasIngredient | pizza:topping1 |
| pizza:hasIngredient | pizza:topping2 |
| pizza:hasIngredient | pizza:topping3 |
| pizza:hasIngredient | pizza:topping4 |
| pizza:hasIngredient | pizza:marksPeppers |
| pizza:hasTopping | pizza:topping1 |
| pizza:hasTopping | pizza:topping2 |
| pizza:hasTopping | pizza:topping3 |
| pizza:hasTopping | pizza:topping4 |
| pizza:hasTopping | pizza:marksPeppers |
| rdfs:label | mark's pizza instance |
| rdf:type | owl:Thing |
| rdf:type | pizza:DomainConcept |
| rdf:type | pizza:Food |
| rdf:type | pizza:Pizza |
| rdf:type | pizza:SpicyPizza |
| rdf:type | pizza:SpicyPizzaEquivalent |
| rdf:type | pizza:CheeseyPizza |
| rdf:type | pizza:marksPizzaClass |
+---------------------+----------------------------+
Stardog has inferred that my pizza has ingredients (because it has toppings), that my pizza is a food, and even that my pizza is spicy because it has Mark's jalapeno peppers as a topping. But it hasn't inferred membership in the interesting pizza class.
Here are my Stardog reasoning settings:
Reasoning type: SL
Reasoning approximate: ON
SameAs reasoning: FULL
TBox named graph: *
I played a bit with Stardog 5.0 and got some more insights:
From an OWL DL view, the ontology is expressive enough to infer that
pizza:marksPizzaInstance rdf:type pizza:InterestingPizza .
This can be evaluated with Protege for example. A sample explanation that can be computed with the pretty cool Protege feature would be:
I could achieve the same in Stardog by enabling DL reasoning:
bin/stardog-admin db offline pizzaDB
bin/stardog-admin metadata set -o reasoning.type=DL pizzaDB
bin/stardog-admin db online pizzaDB
Result:
+-------------------+-------------------------+
| p | o |
+-------------------+-------------------------+
| pizza:hasTopping | pizza:topping1 |
| pizza:hasTopping | pizza:topping2 |
| pizza:hasTopping | pizza:marksPeppers |
| pizza:hasTopping | pizza:topping3 |
| pizza:hasTopping | pizza:topping4 |
| rdf:type | pizza:Pizza |
| rdf:type | owl:Thing |
| rdf:type | pizza:InterestingPizza |
+-------------------+-------------------------+
For the Stardog profile SL it doesn't work because the axiom is not in the profile. This can be recognized when looking into the Stardog log file which reports all ignored axioms:
WARN 2017-07-03 09:54:51,219 [XNIO-1 task-6] com.clarkparsia.blackout.ProfileFilterBase:apply(39):
Not a valid SL axiom:
EquivalentClasses(pizza:InterestingPizza, and(pizza:Pizza, min(pizza:hasTopping,3,owl:Thing)))
What I tried then is to add an SWRL rule since it's supported by the SL profile:
Pizza(?x), hasTopping(?x, ?y1), hasTopping(?x, ?y2), hasTopping(?x, ?y3),
DifferentFrom (?y1, ?y2), DifferentFrom (?y1, ?y3), DifferentFrom (?y2, ?y3)
-> InterestingPizza(?x)
Surprisingly, this did not work either. I guess I missed some important thing and I'm still investigating why this doesn't work.
Lastly, I tried a Stardog rule instead of SWRL which has a pretty neat syntax close to SPARQL (BGPs are basically used):
[] a rule:SPARQLRule ;
rule:content """
PREFIX :<http://www.co-ode.org/ontologies/pizza/pizza.owl#>
IF {
?p a :Pizza ;
:hasTopping ?t1 , ?t2, ?t3
FILTER(?t1 != ?t2 && ?t1 != ?t3 && ?t2 != ?t3)
}
THEN {
?p a :InterestingPizza
}""" .
This works as expected and the SPARQL query returns the desired inferred triple.

Following namespaces in SPARQL query

Given this data structure
#prefix core <http://www.w3.org/2004/02/skos/core#>
<http://localhost/myvocab/1> core#notation 1 .
<http://localhost/myvocab/1> <http://www.w3.org/2006/time#inDateTime> <http://localhost/myvocab/item1#DateDescription> .
<http://localhost/myvocab/item1#DateDescription> <http://www.w3.org/2006/time#year> 2016 ;
<http://www.w3.org/2006/time#month> "June"
If I run
select * where {?s ?p ?o .
<http://www.w3.org/2004/02/skos/core#notation> 1 . }
then only the first 2 triples (:hasID and :hasTime) are returned. Is there a sparql query (preferably not using a regex filter for matching the id) to return all triples from the child namespaces too?
I'm hoping I can achieve a result something along the lines of
-------------------------------------------------------------------------------------------------------------------------------------------------------
| s | p | o |
=======================================================================================================================================================
| <http://localhost/myvocab/item1> | <http://www.w3.org/2006/time#inDateTime> | <http://localhost/myvocab/item1#DateDescription |
| <http://localhost/myvocab/item1> | <http://www.w3.org/2004/02/skos/core#notation> | 1 |
| <http://localhost/myvocab/item1#DateDescription> | <http://www.w3.org/2006/time#month> | "June" |
| <http://localhost/myvocab/item1#DateDescription> | <http://www.w3.org/2006/time#year> | 2016 |
-------------------------------------------------------------------------------------------------------------------------------------------------------
It always helps if you provide data that we can actually load and property formed queries that you've tried. The data that you've shown isn't actually legal, nor is the query that you provided. Here's some sample data that's actually loadable:
#prefix core: <http://www.w3.org/2004/02/skos/core#>
<http://localhost/myvocab/1> core:notation 1 ;
<http://www.w3.org/2006/time#inDateTime> <http://localhost/myvocab/item1#DateDescription> .
<http://localhost/myvocab/item1#DateDescription> <http://www.w3.org/2006/time#year> 2016 ;
<http://www.w3.org/2006/time#month> "June"
If I understand you, you want to follow the :item1_DateTime object's properties too. You can do that with a property path that follows :item1's properties and value, and so on. In this query, I use (:|!:) as a wildcard, since every property is either : or it isn't. The * at the end means to follow paths of arbitrary length.
prefix core: <http://www.w3.org/2004/02/skos/core#>
select ?s ?p ?o where {
?s_ core:notation 1 ;
(<>|!<>)* ?s .
?s ?p ?o .
}
--------------------------------------------------------------------------------------------------------------------------------------------------
| s | p | o |
==================================================================================================================================================
| <http://localhost/myvocab/1> | <http://www.w3.org/2006/time#inDateTime> | <http://localhost/myvocab/item1#DateDescription> |
| <http://localhost/myvocab/1> | core:notation | 1 |
| <http://localhost/myvocab/item1#DateDescription> | <http://www.w3.org/2006/time#month> | "June" |
| <http://localhost/myvocab/item1#DateDescription> | <http://www.w3.org/2006/time#year> | 2016 |
--------------------------------------------------------------------------------------------------------------------------------------------------

SPARQL Get all the properties from a Class or an Individual

What I want to do is to get the property list from the Individual1 or from a class,
Get all properties from "something"
The result should be something like this (for Secret_Data):
| Asset_has_Confidentiality_Importance | High |
| Asset_has_Availability_Importance....| Moderate |
| Asset_has_Integrity_Importance.......| Moderate |
| Asset_threatenedBy_ThreatEvent.......| Compromise_sensitive_information |
| Asset_threatenedBy_ThreatEvent.......| Disclosure_of_sensitive_information |
| Asset_threatenedBy_ThreatEvent.......| Exploit_exposed_unauthorized_information |
| Asset_threatenedBy_ThreatEvent.......| Integrity_loss_by_corrupting_critital_data |
<owl:NamedIndividual rdf:about="&securityOntology_ITESM_UC3M;Secret_Data">
<rdf:type rdf:resource="&securityOntology_ITESM_UC3M;Data"/>
<Asset_has_Confidentiality_Importance rdf:datatype="&xsd;string">High</Asset_has_Confidentiality_Importance>
<Asset_has_Availability_Importance rdf:datatype="&xsd;string">Moderate</Asset_has_Availability_Importance>
<Asset_has_Integrity_Importance rdf:datatype="&xsd;string">Moderate</Asset_has_Integrity_Importance>
<Asset_threatenedBy_ThreatEvent rdf:resource="&securityOntology_ITESM_UC3M;Compromise_sensitive_information"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="&securityOntology_ITESM_UC3M;Disclosure_of_sensitive_information"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="&securityOntology_ITESM_UC3M;Exploit_exposed_unauthorized_information"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="&securityOntology_ITESM_UC3M;Integrity_loss_by_corrupting_critital_data"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="&securityOntology_ITESM_UC3M;Obtain_unauthorized_access"/>
</owl:NamedIndividual>
I think the query is something like this, (But the value is not well formatted, and some properties are not importart like "type property"):
PREFIX css:<http://www.semanticweb.org/evalues/ontologies/2014/3/securityOntology_ITESM_UC3M#>
SELECT DISTINCT ?property ?value
WHERE {
css:Secret_Data ?property ?value.
}
Answer to updated question (a query about individuals)
It's much easier to answer question with complete sample data. If we bundle up the data that you've given with appropriate namespace declarations, we end up with something like this:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns="http://stackoverflow.com/q/23223447/1281433/">
<owl:NamedIndividual rdf:about="http://stackoverflow.com/q/23223447/1281433/Secret_Data">
<Asset_has_Availability_Importance rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Moderate</Asset_has_Availability_Importance>
<rdf:type rdf:resource="http://stackoverflow.com/q/23223447/1281433/Data"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="http://stackoverflow.com/q/23223447/1281433/Integrity_loss_by_corrupting_critital_data"/>
<Asset_has_Integrity_Importance rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Moderate</Asset_has_Integrity_Importance>
<Asset_threatenedBy_ThreatEvent rdf:resource="http://stackoverflow.com/q/23223447/1281433/Obtain_unauthorized_access"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="http://stackoverflow.com/q/23223447/1281433/Disclosure_of_sensitive_information"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="http://stackoverflow.com/q/23223447/1281433/Compromise_sensitive_information"/>
<Asset_has_Confidentiality_Importance rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>High</Asset_has_Confidentiality_Importance>
<Asset_threatenedBy_ThreatEvent rdf:resource="http://stackoverflow.com/q/23223447/1281433/Exploit_exposed_unauthorized_information"/>
</owl:NamedIndividual>
</rdf:RDF>
It's often helpful to view this in Turtle serialization, since it will look more like the query. The data is the same though, and the query will run against the data in either serialization, of course.
#prefix : <http://stackoverflow.com/q/23223447/1281433/> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Secret_Data a owl:NamedIndividual , :Data ;
:Asset_has_Availability_Importance
"Moderate"^^<http://www.w3.org/2001/XMLSchema#string> ;
:Asset_has_Confidentiality_Importance
"High"^^<http://www.w3.org/2001/XMLSchema#string> ;
:Asset_has_Integrity_Importance
"Moderate"^^<http://www.w3.org/2001/XMLSchema#string> ;
:Asset_threatenedBy_ThreatEvent
:Integrity_loss_by_corrupting_critital_data , :Obtain_unauthorized_access , :Disclosure_of_sensitive_information , :Compromise_sensitive_information , :Exploit_exposed_unauthorized_information .
You can use a query like the following:
prefix : <http://stackoverflow.com/q/23223447/1281433/>
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#>
select distinct ?property ?value where {
:Secret_Data ?property ?value .
}
---------------------------------------------------------------------------------------
| property | value |
=======================================================================================
| rdf:type | owl:NamedIndividual |
| :Asset_has_Availability_Importance | "Moderate"^^xsd:string |
| rdf:type | :Data |
| :Asset_threatenedBy_ThreatEvent | :Integrity_loss_by_corrupting_critital_data |
| :Asset_has_Integrity_Importance | "Moderate"^^xsd:string |
| :Asset_threatenedBy_ThreatEvent | :Obtain_unauthorized_access |
| :Asset_threatenedBy_ThreatEvent | :Disclosure_of_sensitive_information |
| :Asset_threatenedBy_ThreatEvent | :Compromise_sensitive_information |
| :Asset_has_Confidentiality_Importance | "High"^^xsd:string |
| :Asset_threatenedBy_ThreatEvent | :Exploit_exposed_unauthorized_information |
---------------------------------------------------------------------------------------
If you don't want rdf:type in there, you could use filter ?property != rdf:type, or if there are multiple properties that you want to exclude, filter ( ?property NOT IN ( rdf:type … ) ):
prefix : <http://stackoverflow.com/q/23223447/1281433/>
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#>
select distinct ?property ?value where {
:Secret_Data ?property ?value .
filter ( ?property not in ( rdf:type ) )
}
---------------------------------------------------------------------------------------
| property | value |
=======================================================================================
| :Asset_has_Availability_Importance | "Moderate"^^xsd:string |
| :Asset_threatenedBy_ThreatEvent | :Integrity_loss_by_corrupting_critital_data |
| :Asset_has_Integrity_Importance | "Moderate"^^xsd:string |
| :Asset_threatenedBy_ThreatEvent | :Obtain_unauthorized_access |
| :Asset_threatenedBy_ThreatEvent | :Disclosure_of_sensitive_information |
| :Asset_threatenedBy_ThreatEvent | :Compromise_sensitive_information |
| :Asset_has_Confidentiality_Importance | "High"^^xsd:string |
| :Asset_threatenedBy_ThreatEvent | :Exploit_exposed_unauthorized_information |
---------------------------------------------------------------------------------------
Answer to the original question (a query about classes)
In the original version of the question, you gave this image of your ontology and asked for results that are after it:
| numberChapters | 1 |
| numberPages | 5 |
In the RDF/XML serialization of that ontology (since removed from the question), the description of the Psicology class was as follows:
<owl:Class rdf:about="http://webprotege.stanford.edu/RiMIUJzVuVHCr4Ke4TkFwX">
<rdfs:label>Psicology</rdfs:label>
<rdfs:subClassOf rdf:resource="http://webprotege.stanford.edu/RDHbMG5sh4tyJ6ZoHwxLBHk"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://webprotege.stanford.edu/R9DdxIZDrtXApiHoBJ6NmAy"/>
<owl:hasValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">5</owl:hasValue>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://webprotege.stanford.edu/R8WDOefPWzIoTChbjV31ela"/>
<owl:hasValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:hasValue>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
or in the more human-readable Turtle notation:
<http://webprotege.stanford.edu/RiMIUJzVuVHCr4Ke4TkFwX>
a owl:Class ;
rdfs:label "Psicology" ;
rdfs:subClassOf <http://webprotege.stanford.edu/RDHbMG5sh4tyJ6ZoHwxLBHk> ;
rdfs:subClassOf [ a owl:Restriction ;
owl:hasValue 5 ;
owl:onProperty <http://webprotege.stanford.edu/R9DdxIZDrtXApiHoBJ6NmAy>
] ;
rdfs:subClassOf [ a owl:Restriction ;
owl:hasValue 1 ;
owl:onProperty <http://webprotege.stanford.edu/R8WDOefPWzIoTChbjV31ela>
says that Psicology (which is usually spelled Psychology in English, by the way) is a subclass of the class of things that have the value 5 for the property numPages and the things that have the value 1 for the property numChapters. Psicology is also a subclass of Libray. (Is this supposed to be Library?)
These seem like strange axioms to me, and I wonder if there might be some sort of modeling error going on. I'm not sure what a Psicology is, but you're saying that for any Psicology p, it's the case that numPages(p,5) and numChapters(p,1). Is that really what you want to do?
At any rate, given your data, we can retrieve the results that you want. Looking at the Turtle serialization is useful, because it's very similar to the SPARQL query syntax. The query you want is:
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix : <http://webprotege.stanford.edu/project/Bnag2Z5E4j78tB27NnLq1L#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?property ?value where {
?class rdfs:label "Psicology" ;
rdfs:subClassOf [ owl:hasValue ?value ;
owl:onProperty [ rdfs:label ?property ] ] .
}
-------------------------
| property | value |
=========================
| "numChapters" | 1 |
| "numPages" | 5 |
-------------------------