W3C home > Mailing lists > Public > public-csv-wg@w3.org > June 2014

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

From: Tandy, Jeremy <jeremy.tandy@metoffice.gov.uk>
Date: Wed, 11 Jun 2014 10:17:50 +0000
To: "public-csv-wg@w3.org" <public-csv-wg@w3.org>, Andy Seaborne <andy@apache.org>, Gregg Kellogg <gregg@greggkellogg.net>
Message-ID: <2624871D9A05174691BD59F8EFD68AE208846BEB@EXXCMPD1DAG3.cmpd1.metoffice.gov.uk>
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.


[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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:21:40 UTC