Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON-LD serialization of rightOperand values #279

Closed
simonstey opened this issue Oct 13, 2017 · 6 comments
Closed

JSON-LD serialization of rightOperand values #279

simonstey opened this issue Oct 13, 2017 · 6 comments

Comments

@simonstey
Copy link
Contributor

Preliminaries:
Values of property odrl:rightOperand can be literals or IRIs:

one rightOperand property value of type:

  • literal, or IRI [rfc3987], or RightOperand; or
  • for set-based operators; list of literals, or list of IRIs [rfc3987], or list of RightOperands;

http://www.w3.org/ns/odrl.jsonld :

"rightOperand": "odrl:rightOperand",


Problem:
By default, all JSON-LD values are interpreted as strings (cf. schemaorg/schemaorg#51) ->

{
    "@context": "http://www.w3.org/ns/odrl.jsonld",
    "@type": "Offer",
    "uid": "http://example.com/policy:88",
    "profile": "http://example.com/odrl:profile:09",
    "permission": [{
        "assigner": "http://example.com/assigner:sony",
        "target": "http://example.com/music/1999.mp3",
        "action": "play",
        "duty": [{
           "action": [{
              "rdf:value": { "@id": "odrl:compensate" },
              "refinement": [{
                 "leftOperand": "payAmount",
                 "operator": "eq",
                 "rightOperand": "5.00",
                 "unit": "http://dbpedia.org/resource/Euro"
              }]
            }],
            "constraint": [{
                "leftOperand": "event",
                "operator": "lt",
                "rightOperand": "policyUsage"
            }]
        }]
    }]
}  

-->

<http://example.com/policy:88> a odrl:Offer ;
    odrl:permission [ odrl:action odrl:play ;
            odrl:assigner <http://example.com/assigner:sony> ;
            odrl:duty [ odrl:action [ rdf:value odrl:compensate ;
                            odrl:refinement [ odrl:leftOperand odrl:payAmount ;
                                    odrl:operator odrl:eq ;
                                    odrl:rightOperand "5.00" ;
                                    odrl:unit "http://dbpedia.org/resource/Euro" ] ] ;
                    odrl:constraint [ odrl:leftOperand odrl:event ;
                            odrl:operator odrl:lt ;
                            odrl:rightOperand "policyUsage" ] ] ;
            odrl:target <http://example.com/music/1999.mp3> ] ;
    odrl:profile <http://example.com/odrl:profile:09> .

Solution:

From schemaorg/schemaorg#51 (comment):

I think in this situation, it seems safest to always stay explicit and always use

  • { "@id": "https://foo.example/" }
  • { "@value": "bar" }

and don't rely on schema.org JSON-LD context having or not having "@type": "@id"

{
	"@context": "http://www.w3.org/ns/odrl.jsonld",
	"@type": "Offer",
	"uid": "http://example.com/policy:88",
	"profile": "http://example.com/odrl:profile:09",
	"permission": [{
		"assigner": "http://example.com/assigner:sony",
		"target": "http://example.com/music/1999.mp3",
		"action": "play",
		"duty": [{
			"action": [{
				"rdf:value": {
					"@id": "odrl:compensate"
				},
				"refinement": [{
					"leftOperand": "payAmount",
					"operator": "eq",
					"rightOperand": {
						"@value": "5.00",
						"@type": "xsd:decimal"
					},
					"unit": "http://dbpedia.org/resource/Euro"
				}]
			}],
			"constraint": [{
				"leftOperand": "event",
				"operator": "lt",
				"rightOperand": {
					"@id": "odrl:policyUsage"
				}
			}]
		}]
	}]
}

-->

<http://example.com/policy:88> a odrl:Offer ;
    odrl:permission [ odrl:action odrl:play ;
            odrl:assigner <http://example.com/assigner:sony> ;
            odrl:duty [ odrl:action [ rdf:value odrl:compensate ;
                            odrl:refinement [ odrl:leftOperand odrl:payAmount ;
                                    odrl:operator odrl:eq ;
                                    odrl:rightOperand 5.00 ;
                                    odrl:unit "http://dbpedia.org/resource/Euro" ] ] ;
                    odrl:constraint [ odrl:leftOperand odrl:event ;
                            odrl:operator odrl:lt ;
                            odrl:rightOperand odrl:policyUsage ] ] ;
            odrl:target <http://example.com/music/1999.mp3> ] ;
    odrl:profile <http://example.com/odrl:profile:09> .
@vroddon
Copy link
Contributor

vroddon commented Oct 13, 2017

Which specific change has to be done where?

@simonstey
Copy link
Contributor Author

instead of writing :

  • (IRIs): "rightOperand": "policyUsage" -> "rightOperand": { "@id": "odrl:policyUsage" }
  • (Literals): "rightOperand": "5.00" -> "rightOperand": { "@value": "5.00", "@type": "xsd:decimal" }

@iherman
Copy link
Member

iherman commented Oct 13, 2017

@simonstey, can you please prepare a Pull Request with the proposed changes in vocab/ODRL22.jsonld ? The version on the W3C space is merely a copy of the file in the repo, and I am uneasy "just" changing it directly.

@simonstey
Copy link
Contributor Author

we wouldn't change anything in the context file, but would fix the examples of the IM

@iherman iherman removed their assignment Oct 13, 2017
@iherman
Copy link
Member

iherman commented Oct 13, 2017

Oh, I am sorry, I misunderstood.

@riannella riannella moved this from Backlog to Under Discussion in ODRL CR Review Oct 25, 2017
riannella added a commit that referenced this issue Oct 27, 2017
@riannella
Copy link
Contributor

Fixed

@riannella riannella moved this from Under Discussion to Completed in ODRL CR Review Oct 27, 2017
@riannella riannella removed this from Completed in ODRL CR Review Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants