rdf4j icon indicating copy to clipboard operation
rdf4j copied to clipboard

JSON-LD Writer writes types with expanded rdf:type IRI

Open daltontc opened this issue 2 years ago • 0 comments

Current Behavior

Statements with type declarations are being written out with the expanded rdf:type IRI rather than the @type shorthand when using the JSONLD Writer. Changing the JSONLDSettings. USE_RDF_TYPE property appears to have no effect on the out.

When writing out a model that has an individual with types other than owl:NamedIndividual, the JSONLD Writer prints out the full IRI for rdf:type for the non owl:NamedIndividual types but will correctly write out the @type for owl:NamedIndividual.

For example,

@prefix : <http://test.com/ontology> .

:Class1 rdf:type owl:Class .

:Individual1 rdf:type owl:NamedIndividual ,
                       :Class1 .

:Class2 a owl:Class .

:Individual2 a :Class1 .

Becomes:

[ {
  "@id" : "http://test.com/ontologyClass1",
  "@type" : [ "http://www.w3.org/2002/07/owl#Class" ]
}, {
  "@id" : "http://test.com/ontologyClass2",
  "@type" : [ "http://www.w3.org/2002/07/owl#Class" ]
}, {
  "@id" : "http://test.com/ontologyIndividual1",
  "@type" : [ "http://www.w3.org/2002/07/owl#NamedIndividual" ],
  "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" : [ {
    "@id" : "http://test.com/ontologyClass1"
  } ]
}, {
  "@id" : "http://test.com/ontologyIndividual2",
  "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" : [ {
    "@id" : "http://test.com/ontologyClass1"
  } ]
} ]

Expected Behavior

All types for a given subject should be written out with the @type annotation.

The above example should become:

[ {
  "@id" : "http://test.com/ontologyClass1",
  "@type" : [ "http://www.w3.org/2002/07/owl#Class" ]
}, {
  "@id" : "http://test.com/ontologyClass2",
  "@type" : [ "http://www.w3.org/2002/07/owl#Class" ]
}, {
  "@id" : "http://test.com/ontologyIndividual1",
  "@type" : [ "http://www.w3.org/2002/07/owl#NamedIndividual", "http://test.com/ontologyClass1" ]
}, {
  "@id" : "http://test.com/ontologyIndividual2",
  "@type" : [ "http://test.com/ontologyClass1" ]
} ]

Steps To Reproduce

https://github.com/daltontc/rdf4jTest/tree/bug/multiple_types

Version

3.7.4

Are you interested in contributing a solution yourself?

No response

Anything else?

No response

daltontc avatar Jan 25 '22 20:01 daltontc