Re: [viejs] Help needed trying to create a service

22 views
Skip to first unread message

Stéphane Corlosquet

unread,
Aug 13, 2012, 3:54:53 PM8/13/12
to vi...@googlegroups.com
Hi fps,

On Mon, Aug 13, 2012 at 1:51 PM, François-Paul Servant <f...@semanlink.net> wrote:
Hi,

I'm trying to create a VIE service using my own LOD compliant dataset (triple store + sparql endpoint + dereferencable URIs). I started with a copy/paste of DBPediaService.

My URIs and my SPARQL endpoint do not support text application/rdf+json. Does VIE support the parsing of RDF/XML or ttl? If it is the case, is there some sample code of a service using such data? If not, what kind of rdf in json serialization do I have to provide? (if you also have an advice about the tool to produce it in java…)

Have you considered using JSON-LD [1]? Libraries are available in both Javascript and Java [1]. From Java you should be able to transform from RDF to JSON-LD [2].

Steph.

 

TIA

fps


--
--
VIE.js @ Google Groups

web: http://viejs.org
list:   vi...@googlegroups.com

More information can be found at
http://groups.google.com/group/viejs?hl=de?hl=de




François-Paul Servant

unread,
Aug 13, 2012, 3:58:03 PM8/13/12
to vi...@googlegroups.com
Thanks!

fps

François-Paul Servant

unread,
Sep 17, 2012, 7:36:23 PM9/17/12
to vi...@googlegroups.com
Hi,

answering more or less my own question :

VIE.Util.rdf2Entities uses RDFQuery to convert rdf/json data (Talis format, not JSON-LD) into VIE.Entities. It is used by most of the services in the distribution. RDFQuery also contains an RDF-XML parser, so this method can easily be adapted to be used in the creation of VIE services that connect to dataset that return RDF-XML (a format which is more widely used than rdf/json, I think)

Regarding JSON-LD, I read in Entity.js: "VIE internally uses JSON-LD to store entities". So I thought that it should be possible to pass JSON-LD data to the constructor of Entity. But it seems that Entity.js uses @subject instead of @id for the URIs of the resources, cf:
    var Model = Backbone.Model.extend({
        idAttribute: '@subject',

        initialize: function(attributes, options) {
            if (attributes['@subject']) {
                this.id = this['@subject'] = this.toReference(attributes['@subject']);
            
            } else {
                this.id = this['@subject'] = attributes['@subject'] = this.cid.replace('c''_:bnode');
            }
            return this;
        },

I modified these lines to:
    var Model = Backbone.Model.extend({
        idAttribute: '@subject',

        initialize: function(attributes, options) {
            if (attributes['@subject']) {
                this.id = this['@subject'] = this.toReference(attributes['@subject']);
            
            } else if (attributes['@id']) { // fps
                this.id = this['@id'] = this.toReference(attributes['@id']);

            } else {
                this.id = this['@subject'] = attributes['@subject'] = this.cid.replace('c''_:bnode');
            }
            return this;
        },
Not really sure that this makes sense, but it seems that I can now create entities with JSON-LD data.  

Best,

fps

Henri Bergius

unread,
Sep 18, 2012, 4:11:18 AM9/18/12
to vi...@googlegroups.com
Hi,

On Tue, Sep 18, 2012 at 1:36 AM, François-Paul Servant
<f...@semanlink.net> wrote:
> Regarding JSON-LD, I read in Entity.js: "VIE internally uses JSON-LD to
> store entities". So I thought that it should be possible to pass JSON-LD
> data to the constructor of Entity. But it seems that Entity.js uses @subject
> instead of @id for the URIs of the resources

We're using JSON-LD, but a slightly older version of the spec which
used @subject. The relevant issue for this is
https://github.com/bergie/VIE/issues/110

> I modified these lines to:
> } else if (attributes['@id']) { // fps
> this.id = this['@id'] = this.toReference(attributes['@id']);

Pull request appreciated :-)

https://help.github.com/articles/using-pull-requests

> fps

/Henri

--
Henri Bergius
Motorcycle Adventures and Free Software
http://bergie.iki.fi/

Jabber: henri....@gmail.com
Microblogs: @bergie
Reply all
Reply to author
Forward
0 new messages