Skip to content

compacting native types with a type specification in context #545

Open
@ethieblin

Description

@ethieblin

This issue comes from digitalbazaar/jsonld.js#466
I have the same issue when trying to round-trip from a framed JSON-LD to RDF and from the produced RDF to a framed JSON-LD.

{
  "@context": {
    "td": "http://example.org/",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "title": {
      "@id": "td:title",
      "@type": "xsd:string"
    },
    "@language": "en"
  },
  "@id": "urn:something",
  "title": "the title"
}

The xsd:string typing in RDF is omitted as it is considered the default type which is fine.

<urn:something> <http://example.org/title> "the title" .

playground toRDF

When transforming the RDF data to JSON-LD again, we get

[
  {
    "@id": "urn:something",
    "http://example.org/title": [
      {
        "@value": "the title"
      }
    ]
  }
]

And when trying to compact or frame back the data with the same context, we get

{
  "@context": {
    "td": "http://example.org/",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "title": {
      "@id": "td:title",
      "@type": "xsd:string"
    },
    "@language": "en"
  },
  "@id": "urn:something",
  "td:title": {
    "@value": "the title"
  }
}

playground framing with original context

It seems that the presence of "@type":"xsd:string" prevents the "title" term to be matched and framed.

The same compaction issues appears with the other native types playground xsd:boolean

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Future Work

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions