Skip to content

Commit

Permalink
Disallow subclasses of core:UcoObject and co:Collection in UCO reposi…
Browse files Browse the repository at this point in the history
…tory

A follow-on patch will regenerate Make-managed files.

References:
* #509

Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
  • Loading branch information
ajnelson-nist committed Jan 18, 2023
1 parent 72427e2 commit cc1ec31
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@prefix co: <http://purl.org/co/> .
@prefix core: <https://ontology.unifiedcyberontology.org/uco/core/> .
@prefix ex: <http://example.org/ontology/> .
@prefix observable: <https://ontology.unifiedcyberontology.org/uco/obserable/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:IPAddressRoute
a owl:Class ;
rdfs:comment "This is expected to trigger a disjointed-classes violation, once subclass expansion occurs. This example copies subclass axioms from co:, core:, and observable:."@en ;
rdfs:subClassOf
co:List ,
observable:ObservableObject
;
.

co:Bag
a owl:Class ;
rdfs:subClassOf co:Collection ;
.

co:List
a owl:Class ;
rdfs:comment "This definition is excerpted from co:."@en ;
rdfs:subClassOf [
a owl:Class ;
owl:intersectionOf (
co:Bag
[
a owl:Restriction ;
owl:onProperty co:item ;
owl:allValuesFrom co:ListItem ;
]
) ;
] ;
.

core:Item
a owl:Class ;
rdfs:subClassOf core:UcoObject ;
.

observable:ObservableObject
a owl:Class ;
rdfs:subClassOf
core:Item ,
observable:Observable
;
.

observable:Observable
a owl:Class ;
rdfs:subClassOf core:UcoObject ;
.

10 changes: 10 additions & 0 deletions tests/shapes/test_qc_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
@pytest.mark.parametrize(
["filename", "expected_validation_result", "expected_focus_values"],
[
(
"examples_uco_qc/co_Collection_core_UcoObject_XFAIL_validation.ttl",
False,
{
(
URIRef("http://example.org/ontology/IPAddressRoute"),
URIRef("http://example.org/ontology/IPAddressRoute"),
)
}
),
(
"examples_uco_owl/owl_incompatibleWith_shape_PASS_validation.ttl",
True,
Expand Down
22 changes: 22 additions & 0 deletions tests/shapes/uco-qc.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@
rdfs:comment "This ontology contains shapes meant to be used against the transitive closure of UCO, excluding imported, externally-developed ontologies."@en ;
.

uco-qc:disjointedness-co-collection-core-uco-object
a sh:NodeShape ;
sh:sparql [
a sh:SPARQLConstraint ;
rdfs:seeAlso <https://github.com/ucoProject/UCO/issues/509> ;
sh:message "The focus node is defined as a subclass of two classes intended to be disjoint, co:Collection and core:UcoObject. See Issue 509 for suggested implementation alterations."@en ;
sh:select """
PREFIX co: <http://purl.org/co/>
PREFIX core: <https://ontology.unifiedcyberontology.org/uco/core/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT $this
WHERE {
$this
rdfs:subClassOf*/(owl:intersectionOf/rdf:rest*/rdf:first)?/rdfs:subClassOf* co:Collection ;
rdfs:subClassOf* core:UcoObject ;
.
}
""" ;
] ;
sh:targetClass owl:Class ;
.

uco-qc:owl-Ontology-shape
a sh:NodeShape ;
sh:property [
Expand Down

0 comments on commit cc1ec31

Please sign in to comment.