- From: Dietrich Schulten <ds@escalon.de>
- Date: Sun, 22 Feb 2015 09:41:01 +0100
- To: public-hydra@w3.org
Hi,
An update to the problem that schema.org has no http://schema.org/order
property. Yesterday evening it dawned on me that this is not entirely
true, see below.
Am 21.02.2015 um 16:18 schrieb Dietrich Schulten:
>
> {
> "@context": {
> "@vocab": "http://schema.org",
> "hydra": "http://www.w3.org/ns/hydra/core#",
> "hydra:property": { "@type": "@vocab"}
> }
> "@type": "CafeOrCoffeeShop",
> "@id": "http://example.com/store",
> "name": "Kaffeehaus Hagen",
> "makesOffer": [
> {
> "@type": "Offer",
> "@id": "http://example.com/offers/1234",
> "itemOffered":
> {
> "@type": "Product",
> "@id": "http://example.com/products/latte",
> "name": "Latte Macchiato",
> "hydra:collection": {
> "@id": "http://example.com/orders"
> "hydra:operation" : {
> "hydra:method": "POST",
> "@type": "OrderAction",
> "hydra:expects":
> {
> "@type": "Product",
> "hydra:supportedProperty": [
> {
> "hydra:property": "name",
> "hydra:required": true,
> "defaultValue": "Latte Macchiato",
> "readOnlyValue": true
> }
> ]
> },
> "hydra:returns": "Order"
> }
> }
> },
> "price": 2.8,
> "priceCurrency": "EUR",
> }]
> }
>
What we need is a relationship between the product and orders where the
product may occur. Such a relationship exists
http://schema.org/orderedItem.
This property loosely states that it might occur on
http://schema.org/Order (domainIncludes) and that its values might be of
type http://schema.org/Product (rangeIncludes).
The only issue is that the domain is wrong, i.e. :orderedItem is
supposed to appear as a property of an :Order, however, we need it on a
:Product. But that is not a problem at all, we can simply reverse domain
and range with json-ld, as shown in the @context of the updated version
of the coffeeshop below. No need to apply hydra:collection, we can just
invent a term "orders" and say that it is the reverse of :orderedItem.
One caveat: the property :orderedItem loosely relates a :Product to an
:Order. With schema.org that is not a strict relation, so one could in
fact use our "orders" term on a customer without entailing that the
customer is also a product. But if a property is defined with rdfs:range
and rdfs:domain you need to be careful where you use it, be it reverted
or not.
{
"@context": {
"@vocab": "http://schema.org/",
"hydra": "http://www.w3.org/ns/hydra/core#",
"hydra:property": { "@type": "@vocab"},
"orders": {"@reverse": "orderedItem"}
},
"@type": "CafeOrCoffeeShop",
"@id": "http://example.com/store",
"name": "Kaffeehaus Hagen",
"makesOffer": [
{
"@type": "Offer",
"@id": "http://example.com/offers/1234",
"itemOffered":
{
"@type": "Product",
"@id": "http://example.com/products/latte",
"name": "Latte Macchiato",
"orders": {
"@id": "http://example.com/orders",
"hydra:operation" : {
"hydra:method": "POST",
"@type": "OrderAction",
"hydra:expects":
{
"@type": "Product",
"hydra:supportedProperty": [
{
"hydra:property": "name",
"hydra:required": true,
"defaultValue": "Latte Macchiato",
"readOnlyValue": true
}
]
},
"hydra:returns": "Order"
}
}
},
"price": 2.8,
"priceCurrency": "EUR",
"addOn": [
{
"@type": "Offer",
"itemOffered":
{
"@type": "Product",
"name": "shot"
},
"price": 0.2,
"priceCurrency": "EUR"
}
]
}]
}
Best regards,
Dietrich
Received on Sunday, 22 February 2015 08:41:43 UTC