jsonld.js icon indicating copy to clipboard operation
jsonld.js copied to clipboard

defining a prop as `xsd:boolean` loses its prefixed URL

Open VladimirAlexiev opened this issue 1 year ago • 3 comments

Given this context

{"@context":
 {"owl": "http://www.w3.org/2002/07/owl#",
  "xsd": "http://www.w3.org/2001/XMLSchema#",
  "owl:deprecated": {"@type": "xsd:boolean"}
 }
}

This instance data

{
  "@id": "ex:Ontology",
  "http://www.w3.org/2002/07/owl#deprecated": true
}

is compacted to

{
  "@context": {
    "owl": "http://www.w3.org/2002/07/owl#",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "owl:deprecated": {
      "@type": "xsd:boolean"
    }
  },
  "@id": "ex:Ontology",
  "http://www.w3.org/2002/07/owl#deprecated": true
}

As you see, the prefix owl: is not used for the property. If I remove the prop type from the context

  "owl:deprecated": {"@type": "xsd:boolean"}

Then the prop is shortened.

Same happens in playground and https://github.com/digitalbazaar/jsonld-cli/releases/tag/v2.0.0

@msporny @gkellogg is this expected?

VladimirAlexiev avatar Oct 12 '24 13:10 VladimirAlexiev

Yes, it is operating as designed. Term selection looks for exact patterns, and would have used owl:deprecated if it were "true"^^xsd:boolean, but it needs to match that value pattern, and not a native value. JSON-LD only takes native types into consideration for from and to RDF transformation.

gkellogg avatar Oct 12 '24 19:10 gkellogg

which means that ALL json native values are useless or harmful, and only strings should be used . Right?

VladimirAlexiev avatar Oct 15 '24 02:10 VladimirAlexiev

which means that ALL json native values are useless or harmful, and only strings should be used . Right?

Pretty much :) native values generally loose fidelity, and the algorithms intentionally ignore them. JSON-LD is really about interpreting string values.

gkellogg avatar Oct 15 '24 03:10 gkellogg