w3c / json-ld-syntax

JSON-LD 1.1 Specification
https://w3c.github.io/json-ld-syntax/
Other
112 stars 22 forks source link

Flattening doc with node references instead of node object? #277

Closed zaliqarosli closed 4 years ago

zaliqarosli commented 4 years ago

To be able to externally reference nodes in an RDF graph, it is important that nodes have an identifier. IRIs are a fundamental concept of Linked Data, for nodes to be truly linked, dereferencing the identifier should result in a representation of that node. This may allow an application to retrieve further information about a node.

Hi, I have a node object with a property whose value is a list of node identifiers. Similarly to how contexts can be referenced using a URL, these children nodes are referenced from the main node object by its identifier, and are not connected by the child node object itself. I have not been able to find an example of this. Is this at all possible?

Example:

{
    "@context": [ "https://raw.githubusercontent.com/ReproNim/schema-standardization/master/contexts/generic",
        "https://raw.githubusercontent.com/ReproNim/schema-standardization/master/activities/MedicalHistory-LORIS/medicalhistory_context"
    ],
    "@type": "https://raw.githubusercontent.com/ReproNim/schema-standardization/master/schemas/Activity",
    "@id": "medicalhistory_sectionA",
    "prefLabel": "Section A of Medical History Instrument",
    "altLabel": "medicalhistory_sectionA",
    "description": "Section A of Medical History Instrument",
    "schemaVersion": "0.0.1",
    "version": "0.0.1",
    "preamble": "A. Arthritis",
    "ui": {
        "inputType": "section",
        "order": [
            "https://raw.githubusercontent.com/ReproNim/schema-standardization/master/activities/MedicalHistory-LORIS/items/medicalhistory_1",
            "https://raw.githubusercontent.com/ReproNim/schema-standardization/master/items/age_text"
        ],
        "shuffle": false
    }
}

where this doc would flatten out to include, in the resulting graph, the node object defined in https://raw.githubusercontent.com/ReproNim/schema-standardization/master/activities/MedicalHistory-LORIS/items/medicalhistory_1.

In other words, how would I dereference a node's identifier without directly adding its object into the main jsonld doc?

pchampin commented 4 years ago

Short answer is no, JSON-LD algorithm will not dereference these IRI.

It is important to understand that the URL (or list of URLs) given to @context plays a very different role from the IRIs used in most other places in JSON-LD (including the values of your order property):

zaliqarosli commented 4 years ago

@pchampin thank you for your quick response. just to clarify, is it okay practice to opt for referencing nodes by their identifier rather than including the node objects themselves?

pchampin commented 4 years ago

is it okay practice to opt for referencing nodes by their identifier rather than including the node objects themselves?

It's more than okay. It is the core principle of linked data :-)