Re: Reference @context via URL with something with type @id

On Mon, Jun 8, 2015 at 7:24 PM, David Janes <davidjanes@davidjanes.com> wrote:
> Ah. I've tried a number of variants with no joy.
>
> I've changed this to Node JS for easier testing. After I add the definitions
> to the @context in "iot.jsonld", the issue seems to be with how @vocab is
> used.
>
> Just to spell it out, the only difference between the two examples is I
> expanded out "model" to "https://iotdb.org/pub/iot#model", which if I
> understand this correctly should be happening because of the @vocab
>
> This does not work
> ...
>   "model":
> "/api/things/urn:iotdb:thing:REST:20b2c3ca712e8b0031debf3453cc75d1:rest-color-light/model"
> ...
>
> This does
> ...
>   "https://iotdb.org/pub/iot#model":
> "/api/things/urn:iotdb:thing:REST:20b2c3ca712e8b0031debf3453cc75d1:rest-color-light/model"
> ...

This managed to confuse me too.  If someone else would like to explain
this with the proper terminology, please do.  I'll give it a try.  The
issue is that during expansion the processor is looks up the original
term in the context, not what the term is expanded into.  The first
one fails since it does not find "model" in the context and defaults
to a string.  However, expansion will use @vocab to expand the term to
the full URL.  It doesn't have a second pass to re-lookup that value.
The second one works since your context has the full URL defined.  The
way you probably want to structure this is that in your context you
will map the short aliases to the full URL and type:

"@context": {
  "model": {
    "@id": "https://iotdb.org/pub/iot#model",
    "@type": "id"
  },
  ... similar for other terms  ...
}

Since you define the "iot" prefix you can shorten that a bit:

"@context": {
  "model": {
    "@id": "iot:model",
    "@type": "id"
  },
  ... similar for other terms  ...
}

If you want to also use "iot:model" or
"https://iotdb.org/pub/iot#model" you will need to duplicate the
definitions in the context for those.  If you do this for all the
terms you use then you can also remove the use of @vocab since it
wouldn't be needed.  I think one reason for this design is so that you
can have different term names that map to the same property URL but
with different types.  Another is simplicity to avoid multiple lookup
passes during expansion.

-dave

Received on Wednesday, 10 June 2015 18:39:06 UTC