How to distinguish field (cell) references in JSON, and other questions about templates

Hi - having read through the [Generating RDF from Tabular Data on the Web][1] doc, I wonder how the [field references][2] work in a JSON template ...

(aside: should "field references" now be "cell references" given last week's agreement on terminology?)

The field reference is a column (short) name enclosed in braces; but JSON also makes extensive use of braces. How would an application reading a JSON template distinguish a field reference from normal JSON?

Perhaps a the "template" definition in the CSV metadata should specify the character used to enclose field references?

Assuming the JSON syntax from the [Metadata Vocabulary][3] doc e.g. 

...
  "template ": {
    "name": "My JSON transformation template",
    "source": "my-json-template.json",
    "hasFormat": "application/json",
    "description": "blah blah blah",
    "type": "template",
    "cell-ref-enclosure": ["%%","%%"]
  }
...

The keys are taken from the list in the Metadata Vocabulary (these are from Dublin Core Terms), with the exception of "cell-ref-enclosure" which I've used to specify the "cell reference escape character sequence"; I think there must be a better name! 

The value must be an array of length 2; the start and finish character might not be the same: e.g. the default brace enclosure would be:
...
    "cell-ref-enclosure": ["{","}"]
...

Given the escape sequence "%%" & "%%"; the JSON template might then include statements like:

...
  "result": {
      "def-op:airTemperature_C": { "value": "%%air-temp%%" },
      "def-op:dewPointTemperature_C": { "value": "%%dew-point%%" }
  }
...

You'll also notice that I've assumed that the template is not _inlined_ in the CSV metadata document; I've used (perhaps incorrectly) "source" to refer to the target. 

It also occurs to me that the template definition in the CSV metadata should specify the Content-Type created by a target transformation - a given CSV metadata doc might include references to multiple transformation templates; and users should be able to ask for _one_ of those by name. I've used "hasFormat" to specify this.

Jeremy

[1]: http://w3c.github.io/csvw/csv2rdf/ 
[2]: http://w3c.github.io/csvw/csv2rdf/#dfn-field-reference
[3]: http://w3c.github.io/csvw/metadata/index.html 

Received on Wednesday, 11 June 2014 10:18:20 UTC