- From: Dietrich Schulten <ds@escalon.de>
- Date: Sun, 07 Sep 2014 13:50:34 +0200
- To: Gregg Kellogg <gregg@greggkellogg.net>
- CC: "public-hydra@w3.org" <public-hydra@w3.org>
Am 06.09.2014 15:21, schrieb Gregg Kellogg:
> On Sep 6, 2014, at 12:04 PM, Dietrich Schulten <ds@escalon.de>
> wrote:
>>
>> Hi,
>>
>> while experimenting with Java annotations for Hydra enabled
>> classes, I ran into the problem of enumerated values: schema.org
>> uses http://schema.org/Enumeration with many subtypes such as
>> http://schema.org/OnSitePickup and it has a general practice to
>> allow enumeration values from other vocabs as attribute values,
>> notably goodrelations, as in the businessFunction attribute
>> below:
>>
>> { "@context": { "@vocab" : "http://schema.org/" }, "@type":
>> "Movie", "name": "Pirates of the Carribean" "offer": {
>> "businessFunction": "http://purl.org/goodrelations/v1#LeaseOut"
>> } }
>>
>> An enumeration value is a URL. In the json-ld spec, it is not
>> mentioned that I can use a term to define the semantics of an
>> attribute *value*.
>>
>> When applying enumeration values to a plain json file, the
>> problem arises that some mapping might be necessary. Assuming
>> this json:
>>
>> { 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.
>
> Gregg
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.
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!
Dietrich
--
Dietrich Schulten
Escalon System-Entwicklung
Bubenhalde 10
74199 Untergruppenbach
+49 172 7369456
Received on Sunday, 7 September 2014 11:51:19 UTC