json-ld/json-ld.org — Issue #57: Specify if context should be minimized when compacting
Author: dlongley
Created: 2012-01-12 17:01:42+00:00
State: open

The API spec currently does not indicate whether or not the context used during compaction should be minimized in the output. "Minimized" refers to removing prefixes or terms from the context that are not used in the data. For example, this context:

```javascript
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"homepage": {
"@id": "http://xmlns.com/foaf/0.1/homepage",
"@type": "@id"
},
"xsd": "http://www.w3.org/2001/XMLSchema#"
}
}
```

When used to compact this data:

```javascript
{
"http://xmlns.com/foaf/0.1/name": "Manu Sporny",
"http://xmlns.com/foaf/0.1/homepage": {
"@id": "http://manu.sporny.org/"
}
}
```

Would yield:

```javascript
{
"@context": {
"homepage": {
"@id": "http://xmlns.com/foaf/0.1/homepage",
"@type": "@id"
},
"name": "http://xmlns.com/foaf/0.1/name"
},
"homepage": "http://manu.sporny.org/",
"name": "Manu Sporny"
}
```

The context has been "minimized" here because any prefixes or terms not used in the data have been removed (here the "xsd" prefix was removed). Alternatively, the output could leave the context exactly the same, regardless of its actual use in the data.

Two advantages to minimizing the context are that: no superfluous information is present in the output, and inline contexts are reduced in size to themselves be "compact" -- showing only what is necessary. Two disadvantages are: a minor increase in implementation complexity, and perhaps having a context in the output that is different from what was used to compact the input may be unexpected.

There is also a related question as to what should be done with inline vs. IRI contexts. When compacting using an IRI, should the output also use the IRI, or should it use an inline context or a minimized inline context, or should this behavior be undefined?