RE: Enumeration values

On 7 Sep 2014 at 13:50, Dietrich Schulten wrote:
> Am 06.09.2014 15:21, schrieb Gregg Kellogg:
>> On Sep 6, 2014, at 12:04 PM, Dietrich Schulten wrote:
>>> { name: "Pirates of the Caribbean", acquire: "RENT", delivery:
>>> "IN_SHOP" }
>>> 
>>> Can I write a context which says that "RENT" means
>>> http://purl.org/goodrelations/v1#LeaseOut and "IN_SHOP" means
>>> "http://schema.org/OnSitePickup"? The json-ld spec seems not to
>>> mention such a usage.
>>> 
>>> It seems that terms cannot appear as attribute values unless the
>>> attribute is @type. Also, jsonld-java doesn't understand what I
>>> might mean by:
>> 
>> Actually, you want @type: @vocab, which will allow term values
>> without needing a compact URI form.
> 
> After some discussion with Gregg who pointed me to
> http://www.w3.org/TR/json-ld-api/#value-expansion, this is the outcome.
> 
> The @vocab keyword has a second meaning which is not mentioned in the
> json-ld spec, only in the api. If used as a value of @type in the
> context, it says that the corresponding attribute value must be
> expanded to an IRI.

Actually, it's also described in the syntax spec (but there's no example):

    http://www.w3.org/TR/json-ld/#type-coercion



> Example:
> Define @vocab to be schema.org, let "gr" be goodrelations, let
> "delivery" be @type:@vocab, then the value of the "delivery" attribute
> in the JSON will be expanded as an IRI.
> 
> The effect on the value of "delivery" is this: - A compact IRI
> gr:LeaseOut expands to http://purl.org/goodrelations/v1#LeaseOut. -
> Without gr: the @vocab value of schema.org is prepended. Useful if the
> enumerated value is in schema.org - And now the surprise: If I
> additionally define RENT to be gr:LeaseOut, that will be resolved, too:
> 
> {
>  "@context": {
>    "@vocab" : "http://schema.org/",
>    "gr": "http://purl.org/goodrelations/v1#",
>    "delivery" : {
>      "@id" : "availableDeliveryMethod",
>      "@type" : "@vocab"
>    },
>    "RENT": "gr:LeaseOut"
>   },
>   "@type": "Movie",
>   "name": "Pirates of the Carribean",
>   "offer": {
>     "delivery": "RENT"
>    }
> }
> 
> expands to the following in the http://json-ld.org/playground/
> 
> {
>   "@type": "http://schema.org/Movie",
>   "http://schema.org/name": "Pirates of the Carribean",
>   "http://schema.org/offer": {
>     "http://schema.org/availableDeliveryMethod": {
>       "@id": "http://purl.org/goodrelations/v1#LeaseOut"
>     }
>   }
> }
> 
> Thanks a lot!

Yep, this is a very powerful feature.


--
Markus Lanthaler
@markuslanthaler

Received on Sunday, 7 September 2014 21:25:45 UTC