W3C home > Mailing lists > Public > public-lod@w3.org > December 2009

Re: Creating JSON from RDF

From: Frederick Giasson <fred@fgiasson.com>
Date: Thu, 17 Dec 2009 09:29:30 -0500
Message-id: <4B2A404A.1060208@fgiasson.com>
To: Jeni Tennison <jeni@jenitennison.com>
Cc: public-lod@w3.org, John Sheridan <John.Sheridan@nationalarchives.gsi.gov.uk>
Hi Jeni!
> Thanks, that looks interesting, and the idea of supporting similar 
> mappings to XML and to CSV is very attractive.
I also find this attractive :)

> But I couldn't actually work out how I would use it in the kind of 
> situation we find ourselves in. We have, for example, RDF like this:
>
>   http://education.data.gov.uk/doc/school/520965.rdf
>
> which we want to make readily usable by people creating mash-ups. What 
> are the (minimal) definitions that we have to create to use irON to 
> create customised JSON/CSV/XML from this RDF?

Normally, it is the other way around: people do use such notations (irON 
with its different profiles) to "intuitively" (at least, more 
intuitively) create data. So, one of the first goal of irON was to help 
data publishers to publish data without knowing and understanding all 
the specificities of RDF and all its serialization, while keeping it 
quite flexible to be able to describe complex data models. However, one 
of the requirement of irON was to be able to easily map it to RDF (when 
reading the specification, you will notice some similar concepts, which 
is a consequence of this requirement).

But naturally, if you primary source of data is in RDF, and you want to 
describe it in irON (with let sa, the irJSON profile), then can easily 
do the transformations (since RDF is probably the most flexible 
description framework out there, it is not a big deal to transform it in 
any other notation).

To make it complete, what would be required are three things:

(1) the linkage schema which describe the transformation rules
(2) the "schema" itself which describe the usage of the type/attributes 
(this is the ontology)
(3) the record instances file (which is/are the dataset files)

Lets take that RDF from your example above:


==============
  <rdf:Description 
rdf:about="http://education.data.gov.uk/doc/school/520965">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Document"/>
    <rdf:type rdf:resource="http://purl.org/dc/dcmitype/Text"/>
    <foaf:primaryTopic 
rdf:resource="http://education.data.gov.uk/id/school/520965"/>
    <dct:title>Linked Data for Stepping Stones Nursery Group</dct:title>
    <dct:hasFormat 
rdf:resource="http://education.data.gov.uk/doc/school/520965.rdf"/>
    <dct:hasFormat 
rdf:resource="http://education.data.gov.uk/doc/school/520965.html"/>

    <dct:hasFormat 
rdf:resource="http://education.data.gov.uk/doc/school/520965.json"/>
    <dct:hasFormat 
rdf:resource="http://education.data.gov.uk/doc/school/520965.ttl"/>
  </rdf:Description>
==============


Lets start with the linkage schema that would link the irON 
attributes/types to the RDF properties/classes


==============
{
    "linkage": {
        "version": "0.10",
   
        "linkedFormat": "application/rdf+xml",
       
        "prefixList": {
            "dcterms": "http://purl.org/dc/terms/",
            "dctypes": "http://purl.org/dc/dcmitype/",
            "foaf": "http://xmlns.com/foaf/0.1/"
        },
       
        "typeList": {
            "Document": {
                "mapTo": "foaf:Document"
            }
            "Text": {
                "mapTo": "dctypes:Text"
            }
        },
       
        "attributeList": {
            "primaryTopic": {
                "mapTo": "foaf:primaryTopic"
            },
            "title": {
                "mapTo": "dcterms:title"
            },
            "hasFormat": {
                "mapTo": "dcterms:hasFormat"
            }
        }
    }
}
==============

Note 1: you can change the name of the attributes, I used the same as 
the one of the ontology to save some time...
Note 2: I would suggest you to take a look at the Bibliographic Ontology 
for some of the "documents" description in your dataset: 
http://bibliontology.com (check the group and the ontology description).



Then you can describe a "schema" to give more information about the 
usage of these properties to the data consumers

==============
{
    "schema": {
        "version": "0.10",
        "date": "17 December, 2009",



        "attributeList": {
            "title": {
                "prefLabel": "title",
                "description": "Title of a document",
               
                "allowedType": ["Document", "Text"],
                "allowedValue": {"primitive": "String"}
            },
  
            ......

        }
    }
}

==============

*** As I noted in another email I send, the specification section 
related to schemas as been greatly upgraded, but we yet have to update 
the online document.



Then you can describe your record, in a dataset file, like this:


==============
{
    "dataset": {
        "id": "http://education.data.gov.uk/...",
        "prefLabel": "Dataset name",
        "description": "...",
        "source": {
            "name": "UK Government Data Developers",
            "ref": "@abc"
        },
        "creationDate": "02/09/2009",
        "linkage": "linakge_file_above.json",
        "schema": "schema_file_above.json"
    },
    "recordList": [
        {
            "id": "id_1",
            "type": "Document",
            "type": "Text",
            "title": "Linked Data for Stepping Stones Nursery Group",
            "primaryTopic": {
                "ref": "@@http://education.data.gov.uk/id/school/520965"
            }
           
            ....
        }
    ]
}
==============


Note 1: You would describe all the records of your dataset(s) in 
this/these dataset files, in the recordList section.
Note 2: @ => a reference to a local record, @@ => a reference to an 
remote record. Check the record reference section for more information



So, that is it. If you check the specification document, you can easily 
translate this in the irXML and commON profile (I particularly like 
commON to mockup things).

Also, you have access to a irJSON (to be updated, a new version has been 
developed, but not yet made accessible) and a commON PHP parser: 
http://code.google.com/p/iron-notation/downloads/list

But like any such notation, there are many ways to describe the same 
data. So, keep asking questions if you have any other. I will redirect 
you to the proper section in the documentation in the worse case :)


Thanks!


Take care,


Fred
Received on Thursday, 17 December 2009 14:30:00 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 17 December 2009 14:30:01 GMT