- From: Gregg Kellogg via GitHub <sysbot+gh@w3.org>
- Date: Wed, 26 Apr 2017 16:30:36 +0000
- To: public-poe-archives@w3.org
Yes, there are a couple of ways to go when you have more than one node object at the top-level: 1) Wrap them in an array `[{"@context": .., ...}, {"@context": .., ..}` 2) Wrap them all in `@graph` with a shared context `{"@context": ..., "@graph": []}`. 3) Find a common object property and use a reverse relationship. For example, in an RDFS document, this might be `rdfs:isDefinedBy`, in which case you can do something like we do for [CSVW](https://github.com/w3c/csvw/blob/gh-pages/ns/csvw.jsonld): ```json { "@context": { "rdfs": "http://www.w3.org/2000/01/rdf-schema#", "rdfs_classes": { "@reverse": "rdfs:isDefinedBy", "@type": "@id" }, ... }, ..., "rdfs:classes": [ { "@id": "csvw:Cell", "@type": "rdfs:Class", "rdfs:label": { "en": "Cell" }, "rdfs:comment": { "en": "A Cell represents a cell at the intersection of a Row and a Column within a Table." } }, { "@id": "csvw:Column", "@type": "rdfs:Class", "rdfs:label": { "en": "Column Description" }, "rdfs:comment": { "en": "A Column represents a vertical arrangement of Cells within a Table." } }, ... ] } ``` You can, of course, make it multiple JSON-LD documents, and use the graph merge, but adding `[]` around them solves this problem at the expense of repeating `@context`. JSON-LD _is_ JSON, so we need to play be the rules. That said, we are in the process of doing a community update for [JSON-LD 1.1](http://json-ld.org/spec/latest/json-ld/) and reasonable ideas are being entertained, when they are not too disruptive. One feature we're adding is [ID Maps](http://json-ld.org/spec/latest/json-ld/#node-identifier-indexing), which uses the `@container` property of a term definition to allow for indexing values. We could add `"@container": "@id"` as a top-level context element to set the default container value, in which case a top-level object might contain both an `@context` and identifiers to index node definitions. This would substantially change the way that JSON-LD looks, so I'm sure it would be controversial, but would be a fairly simple change to the algorithms. Hypothetically, your example might look like the following: ```json { "@context": ["http://www.w3.org/ns/odrl.jsonld", {"@container": "@id"} ], "http://example.com/policy:6161": { "type": "Offer", "permission": [{ "target": "http://example.com/wallpaper:1234", "assigner": "http://example.com/myPix:6161", "action": "distribute", "constraint": [{ "leftOperand": "spatial", "operator": "eq", "rightOperand": "https://www.iso.org/obp/ui/#iso:code:3166:IT" }], "duty": [ { "action": "compensate", "constraint": [{ "leftOperand": "payAmount", "operator": "eq", "rightOperand": "100.00", "dataType": "http://www.w3.org/2001/XMLSchema#decimal", "unit": "https://www.currency-iso.org/dam/downloads/lists/list_one.xml#EUR" }] }, { "action": "nextPolicy", "target": "http://example.com/policy:7171" } ] }] }, "http://example.com/policy:7171": { "@context": "http://www.w3.org/ns/odrl.jsonld", "type": "Set", "permission": [{ "target": "http://example.com/wallpaper:1234", "action": "display" }] } } ``` -- GitHub Notification of comment by gkellogg Please view or discuss this issue at https://github.com/w3c/poe/issues/46#issuecomment-297467445 using your GitHub account
Received on Wednesday, 26 April 2017 16:30:43 UTC