Providing the @type in the @context for a value

Hello,

Either this is not possible or I am missing something obvious. I am not
sure which.

I have the following json-ld document:

    {
        "@id": "ex:Bobe",
        "@type": "ex:MyType",
        "@context": {
            "ex": "http://example.com/",
            "yyyy": "ex:yyyy",
            "name": "ex:name",
            "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
            "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
            "sch": "http://schema.org/",
            "xml": "http://www.w3.org/XML/1998/namespace",
            "xsd": "http://www.w3.org/2001/XMLSchema#"
        },
        "yyyy": {
            "@type": "ex:XXXX",
            "name": "my name"
        }
    }

which has the following RDF representation:
( using https://github.com/RDFLib/rdflib )

    @prefix ex: <http://example.com/> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix sch: <http://schema.org/> .
    @prefix xml: <http://www.w3.org/XML/1998/namespace> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

    ex:Bobe a ex:MyType ;
        ex:yyyy [ a ex:XXXX ;
                ex:name "my name" ] .

What I would like to be able to do is write "yyyy": { ... } as

    "yyyy": {
        "name": "my name"
    }

and have "@type": "ex:XXXX" specified in the "@context".

Is this possible?

What I have tried:

    {
        "@id": "ex:Bobe",
        "@type": "ex:MyType",
        "@context": {
            "ex": "http://example.com/",
            "yyyy": {
                "@id": "ex:yyyy",
                "@type": "ex:XXXX"
            },
            "name": "ex:name",
            "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
            "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
            "sch": "http://schema.org/",
            "xml": "http://www.w3.org/XML/1998/namespace",
            "xsd": "http://www.w3.org/2001/XMLSchema#"
        },
        "yyyy": {
            "name": "my name"
        }
    }

which has the following RDF representation:
( using https://github.com/RDFLib/rdflib )

    @prefix ex: <http://example.com/> . a
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix sch: <http://schema.org/> .
    @prefix xml: <http://www.w3.org/XML/1998/namespace> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

    ex:Bobe a ex:MyType ;
        ex:yyyy [ ex:name "my name" ] .

The N-Quad representation on the JSON-LD Playground is:

    <http://example.com/Bobe> <http://example.com/yyyy> _:b0 .
    <http://example.com/Bobe> <
http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/MyType>
.
    _:b0 <http://example.com/name> "my name" .


The "@type" information is lost.

Regards,
James

Received on Friday, 1 May 2020 13:57:28 UTC