Skip to content

RDF Deserialization and @index #65

Closed
@vcharpenay

Description

@vcharpenay

The use case I am going to present comes from the Web of Things W3C WG. Its main deliverable is the Thing Description model, for which we would like to define a JSON-LD serialization.

Currently, we have a pre-processing algorithm that adds @id, @type and @context keys to model elements. The model includes a number of indexed definitions, for which @index works just fine. However, it happens that @index keys are also used as identifiers for the definition they map to and we would like to be able to query them among a collection of TD documents stored in an RDF store. For instance, assuming the following TD document:

{
  "@context": "http://www.w3.org/ns/td",
  "@type": "Thing",
  "properties": {
    "temperature": { "type": "number" },
    "onOff": { "type": "boolean" }
  }
}

we'd like the following query to return something like "temperature" instead of a blank node:

select ?index where {
  ?thing a td:Thing ;
      td:properties ?index .
  ?index a jsonschema:NumberDataSchema .
}

In other words, we'd like to have a way to keep @index keys in the RDF graph after JSON-LD deserialization. As far as I know, it is currently not possible. We thought of two possible approaches: ID indexing or extended RDF deserialization.

ID indexing

Properties in the example above could be indexed by @id and not by @index. However, this solution comes with 2 issues: first, we would need to define a @base for these identifiers (ideally the root node's @id0 and, second, we have stumbled many times upon the problem that identifiers collide because the same index key is used several times in the same TD document. Our current solution is to assign a unique JSON pointer to all indexed definitions. Can this approach be standardized?

Extended RDF deserialization

Index values could be included in the RDF graph, using some RDF term defined under the jsonld namespace. Something like:

_:thing a td:Thing ;
    td:properties _:p1, _:p2 .
_:p1 a jsonschema:NumberDataSchema ;
    jsonld:indexKey "temperature"^^xsd:string .
_:p2 a jsonschema:BooleanDataSchema ;
    jsonld:indexKey "onOff"^^xsd:string .

Is that something that is within the scope of JSON-LD 1.1? It would make the full transformation to RDF fully bidirectional, as far as the TD model is concerned.

(See also the related issue w3c/wot-thing-description#444.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions