Skip to content

Commit

Permalink
Merge pull request #637 from EBISPOT/nesting-issue
Browse files Browse the repository at this point in the history
Nesting issue
  • Loading branch information
henrietteharmse authored Apr 3, 2024
2 parents 5cff727 + 2561298 commit fa543bf
Show file tree
Hide file tree
Showing 16 changed files with 116,689 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,31 @@ public void writePropertyValue(JsonWriter writer, PropertyValue value, Set<Strin

}

private final static Set<String> XMLPrimitiveDataTypes = new HashSet<>(Arrays.asList(
"http://www.w3.org/2001/XMLSchema#string",
"http://www.w3.org/2001/XMLSchema#boolean",
"http://www.w3.org/2001/XMLSchema#decimal",
"http://www.w3.org/2001/XMLSchema#float",
"http://www.w3.org/2001/XMLSchema#double",
"http://www.w3.org/2001/XMLSchema#duration",
"http://www.w3.org/2001/XMLSchema#dateTime",
"http://www.w3.org/2001/XMLSchema#time",
"http://www.w3.org/2001/XMLSchema#date",
"http://www.w3.org/2001/XMLSchema#gYearMonth",
"http://www.w3.org/2001/XMLSchema#gYear",
"http://www.w3.org/2001/XMLSchema#gMonthDay",
"http://www.w3.org/2001/XMLSchema#gDay",
"http://www.w3.org/2001/XMLSchema#gMonth",
"http://www.w3.org/2001/XMLSchema#hexBinary",
"http://www.w3.org/2001/XMLSchema#base64Binary",
"http://www.w3.org/2001/XMLSchema#anyURI",
"http://www.w3.org/2001/XMLSchema#QName",
"http://www.w3.org/2001/XMLSchema#NOTATION"
));

private boolean isXMLPrimitiveDatatype(String uri) {
return XMLPrimitiveDataTypes.contains(uri);
}
public void writeValue(JsonWriter writer, PropertyValue value) throws IOException {
assert (value.axioms == null);

Expand Down Expand Up @@ -513,7 +538,7 @@ public void writeValue(JsonWriter writer, PropertyValue value) throws IOExceptio
case URI:
String uri = ((PropertyValueURI) value).getUri();
OntologyNode uriNode = nodes.get(uri);
if(uriNode != null && uriNode.types.contains(OntologyNode.NodeType.DATATYPE)) {
if(uriNode != null && !isXMLPrimitiveDatatype(uri) && uriNode.types.contains(OntologyNode.NodeType.DATATYPE)) {
// special case for rdfs:Datatype; nest it as with a bnode instead of referencing
writeNode(writer, uriNode, Set.of("datatype"));
} else {
Expand Down
9 changes: 9 additions & 0 deletions testcases/datatypes/nesting-issue/datatype-enumeration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ontologies": [
{
"id": "owl2primer-datatype-enumeration",
"preferredPrefix": "owl2primer-datatype-enumeration",
"ontology_purl": "./testcases/owl2-primer/datatype-enumeration.owl"
}
]
}
101 changes: 101 additions & 0 deletions testcases/datatypes/nesting-issue/datatype-enumeration.owl
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration.owl#"
xml:base="http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration.owl"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
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#"
xmlns:datatype-enumeration="http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration#">
<owl:Ontology rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration.owl">
<owl:versionIRI rdf:resource="http://www.ebi.ac.uk/testcases/owl2primer/v.0.0.1/datatype-enumeration.owl"/>
</owl:Ontology>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Datatypes
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration.owl#toddlerAge -->

<rdfs:Datatype rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration.owl#toddlerAge">
<owl:equivalentClass>
<rdfs:Datatype>
<owl:oneOf>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">2</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">3</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">4</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</owl:oneOf>
</rdfs:Datatype>
</owl:equivalentClass>
</rdfs:Datatype>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration.owl#ageOfToddler -->

<owl:DatatypeProperty rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration.owl#ageOfToddler">
<rdfs:range rdf:resource="http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration.owl#toddlerAge"/>
</owl:DatatypeProperty>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration.owl#Dummy -->

<owl:Class rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-enumeration.owl#Dummy"/>
</rdf:RDF>



<!-- Generated by the OWL API (version 4.5.24.2023-01-14T21:28:32Z) https://github.com/owlcs/owlapi -->

9 changes: 9 additions & 0 deletions testcases/datatypes/nesting-issue/datatype-exclusion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ontologies": [
{
"id": "owl2primer-datatype-exclusion",
"preferredPrefix": "owl2primer-datatype-exclusion",
"ontology_purl": "./testcases/datatypes/nesting-issue/datatype-exclusion.owl"
}
]
}
142 changes: 142 additions & 0 deletions testcases/datatypes/nesting-issue/datatype-exclusion.owl
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#"
xml:base="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
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#"
xmlns:datatype-exclusion="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion#">
<owl:Ontology rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl">
<owl:versionIRI rdf:resource="http://www.ebi.ac.uk/testcases/owl2primer/v.0.0.1/datatype-exclusion.owl"/>
</owl:Ontology>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Datatypes
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#majorAge -->

<rdfs:Datatype rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#majorAge">
<owl:equivalentClass>
<rdfs:Datatype>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#personAge"/>
<rdfs:Datatype>
<owl:datatypeComplementOf rdf:resource="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#minorAge"/>
</rdfs:Datatype>
</owl:intersectionOf>
</rdfs:Datatype>
</owl:equivalentClass>
</rdfs:Datatype>



<!-- http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#minorAge -->

<rdfs:Datatype rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#minorAge">
<owl:equivalentClass>
<rdfs:Datatype>
<owl:onDatatype rdf:resource="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#personAge"/>
<owl:withRestrictions rdf:parseType="Collection">
<rdf:Description>
<xsd:minInclusive rdf:datatype="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#personAge">0</xsd:minInclusive>
</rdf:Description>
<rdf:Description>
<xsd:maxInclusive rdf:datatype="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#personAge">18</xsd:maxInclusive>
</rdf:Description>
</owl:withRestrictions>
</rdfs:Datatype>
</owl:equivalentClass>
</rdfs:Datatype>



<!-- http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#personAge -->

<rdfs:Datatype rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#personAge">
<owl:equivalentClass>
<rdfs:Datatype>
<owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
<owl:withRestrictions rdf:parseType="Collection">
<rdf:Description>
<xsd:minInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">150</xsd:minInclusive>
</rdf:Description>
<rdf:Description>
<xsd:maxInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</xsd:maxInclusive>
</rdf:Description>
</owl:withRestrictions>
</rdfs:Datatype>
</owl:equivalentClass>
</rdfs:Datatype>



<!-- http://www.w3.org/2001/XMLSchema#integer -->

<rdf:Description rdf:about="http://www.w3.org/2001/XMLSchema#integer">
<owl:equivalentClass>
<rdfs:Datatype>
<owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
<owl:withRestrictions rdf:parseType="Collection">
<rdf:Description>
<xsd:minInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</xsd:minInclusive>
</rdf:Description>
<rdf:Description>
<xsd:maxInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">150</xsd:maxInclusive>
</rdf:Description>
</owl:withRestrictions>
</rdfs:Datatype>
</owl:equivalentClass>
</rdf:Description>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#ageOfAdult -->

<owl:DatatypeProperty rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#ageOfAdult">
<rdfs:range rdf:resource="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#majorAge"/>
</owl:DatatypeProperty>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#Dummy -->

<owl:Class rdf:about="http://www.ebi.ac.uk/testcases/owl2primer/datatype-exclusion.owl#Dummy"/>
</rdf:RDF>



<!-- Generated by the OWL API (version 4.5.24.2023-01-14T21:28:32Z) https://github.com/owlcs/owlapi -->

9 changes: 9 additions & 0 deletions testcases/datatypes/nesting-issue/datatype-minmax.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ontologies": [
{
"id": "owl2primer-datatype-minmax",
"preferredPrefix": "owl2primer-datatype-minmax",
"ontology_purl": "./testcases/datatypes/nesting-issue/datatype-minmax.owl"
}
]
}
Loading

0 comments on commit fa543bf

Please sign in to comment.