- From: Jindřich Mynarz <mynarzjindrich@gmail.com>
- Date: Thu, 26 Aug 2021 22:28:30 +0200
- To: Gregg Kellogg <gregg@greggkellogg.net>
- Cc: public-json-ld@w3.org
- Message-ID: <CAE=8Bu8DwOtGLtKtRNBG_g6Lua2iqCJVu=TVto0BiecT8UJ-sA@mail.gmail.com>
Hi Gregg,
thanks for providing the reference to the JSON-LD 1.1 specification to
explain the IRI compaction behaviour!
- Jindrich
On Thu, 26 Aug 2021 at 22:15, Gregg Kellogg <gregg@greggkellogg.net> wrote:
> On Aug 26, 2021, at 7:20 AM, Jindřich Mynarz <mynarzjindrich@gmail.com>
> wrote:
>
> Hi,
>
> I'm wondering about the differences in JSON-LD API's IRI compaction (
> https://www.w3.org/TR/json-ld-api/#iri-compaction) of "@id" and "@type".
> When I compact the following data:
>
> {
> "@type": "http://example.com/A",
> "http://example.com/property": {"@id": "http://example.com/B"}
> }
>
> With the following JSON-LD context:
>
> {
> "@vocab": "http://example.com/",
> "ex": "http://example.com/",
> "AliasedA": "A",
> "AliasedB": "B",
> "property": {"@type": "@id"}
> }
>
> The JSON-LD Playground (https://json-ld.org/playground, running jsonld.js
> compliant with JSON-LD 1.1) returns the following compacted data:
>
> {
> "@context": {
> "@vocab": "http://example.com/",
> "ex": "http://example.com/",
> "AliasedA": "A",
> "AliasedB": "B",
> "property": {
> "@type": "@id"
> }
> },
> "@type": "AliasedA",
> "property": "ex:B"
> }
>
> While the value of "@type" is compacted to its alias term, the value of
> "@id" is only compacted using a prefix definition, not its alias term.
>
>
> The rules for interpreting strings as IRIs are described in 4.2.3 Type
> Coercion [1]. Terms used as properties can be defined using with either
> “@type”: “@id” or “@type”: “@vocab” indicate that they should be
> interpreted as IRI references, and are either relative to the document base
> or vocabulary base. By default, values of “@type” are interpreted as IRI
> references relative to the vocabulary base, and “@id” relative to the
> document base.
>
> It is important to note that terms are only used in expansion for
> vocabulary-relative positions, such as for keys and values of map entries.
> Values of @id are considered to be document-relative, and do not use term
> definitions for expansion.
>
>
> Because @id is document relative, without specifying a document base, it
> can’t be turned into a relative IRI, but it can potentially be turned into
> a compact IRI, given a suitable term definition to use as the prefix. The
> value of @type, and other properties (which use “@type”: “@vocab”) can
> potentially be compacted as IRI references/relative IRIs.
>
> When compacting, the most suitable term definition matching the value of a
> given node key is used for creating the compacted result, through a fairly
> involved process.
>
> Link into JSON-LD Playground: https://tinyurl.com/yfrzckbr
>
> I'm guessing values of "@type" are treated differently by IRI compaction,
> but I cannot find support for that in the JSON-LD API specification. Can
> you help?
>
>
> Gregg Kellogg
> gregg@greggkellogg.net
>
> [1] https://www.w3.org/TR/json-ld11/#type-coercion
>
>
> Best regards,
>
> Jindrich
>
> --
> Jindrich Mynarz
> https://mynarz.net/#jindrich
>
>
>
Received on Thursday, 26 August 2021 20:28:55 UTC