Export databanks to RDF

32 views
Skip to first unread message

oanure

unread,
Jun 11, 2009, 6:12:26 AM6/11/09
to rdfQuery
HI Jeni,

I am Oana Ureche, also working on pushback.
I have a question or maybe a suggestion, in case what I want can be
easily implemented and used.

First an example:
For example, I have the HTML paragraph given in your doc:

<p id="info">This paper was written by <span rel="dc:creator"
resource="#me"><span property="foaf:name">Ben Adida</span>.</span></p>

And I am creating a triple store in JavaScript:

var infordf = $('#info').rdf();
var infograph = infordf.databank.dump('application/rdf+xml');

I am not sure if it is necessary to specify 'application/rdf+xml'.

If I do $.toJSON(infograph) I will get the triples in JSON format.
Only I do not want that.
I want to get an RDF graph, something that I can run through the RDF
validator.
It should be possible to write something like $.toRDF(infograph) and
get the following string:

<> dc:creator <#me> .
<#me> foaf:name "Ben Adida" .

Or maybe add the namespaces to the triple store and export everything
in valid RDF?

Any ideas?

Thank you,
Oana.


Jeni Tennison

unread,
Jun 17, 2009, 4:47:38 PM6/17/09
to rdfq...@googlegroups.com, oanure
Hi Oana,

Sorry, I got distracted in the middle of writing this reply!

> And I am creating a triple store in JavaScript:
>
> var infordf = $('#info').rdf();
> var infograph = infordf.databank.dump('application/rdf+xml');
>
> I am not sure if it is necessary to specify 'application/rdf+xml'.
>
> If I do $.toJSON(infograph) I will get the triples in JSON format.
> Only I do not want that.
> I want to get an RDF graph, something that I can run through the RDF
> validator.
> It should be possible to write something like $.toRDF(infograph) and
> get the following string:
>
> <> dc:creator <#me> .
> <#me> foaf:name "Ben Adida" .
>
> Or maybe add the namespaces to the triple store and export everything
> in valid RDF?


I think you're saying that you want the RDF/XML that's generated by
the dump() method to create a string rather than a DOM? I've been lazy
here, because it's easier to generate a DOM than well-formed XML, and
because I figure that serialising a DOM ought to be something that
general purpose Javascript libraries do for you (if, for example,
you're sending an AJAX request).

In the markup demo, I use:

serializer = new XMLSerializer();
answer.text(serializer.serializeToString(xml));

to do the serialisation. This seems to work with Firefox and Safari,
but I haven't tried with IE.

If what you're actually saying is that you want dump() to provide a
serialisation in Turtle syntax, that should be relatively easy to do
and I can add it to the list.

If you're expressing a preference for the $.toRDF() syntax for
creating a representation of the RDF triples, my response would be
that unlike $.toJSON(), $.toRDF() could only work on a particular type
of object (ie a "databank") so it makes sense to use a method rather
than a function to create that representation. I've chosen the name
'dump' but I guess I could change that to toRDF() if there was a good
reason to.

If I haven't interpreted the issue correctly, do let me know.

Cheers,

Jeni
--
Jeni Tennison
http://www.jenitennison.com

melvincarvalho

unread,
Aug 5, 2009, 4:26:36 AM8/5/09
to rdfQuery
I was just wondering if you got something working, in the end? Was it
possible to serialize the DOM into RDF/XML, for example using
XMLSerializer below?

Jeni Tennison

unread,
Aug 5, 2009, 5:19:15 AM8/5/09
to rdfq...@googlegroups.com
Hi,

In the v1.0 release of rdfQuery, the .dump() method's options includes
one for serialising the result of the dump as a string. See the
documentation at:

http://www.jenitennison.com/rdfquery/symbols/jQuery.rdf.html#.dump

So you can do something like:

infordf.databank.dump({
format: 'application/rdf+xml',
serialize: true
});

and you will get a serialised representation of the RDF/XML of the
databank.

Doing the same with the format application/json will give you the
serialised JSON.

Hope that helps,

Melvin Carvalho

unread,
Aug 5, 2009, 7:22:29 AM8/5/09
to rdfq...@googlegroups.com
Really fantastic, many thanks!

oanure

unread,
Aug 18, 2009, 6:47:39 AM8/18/09
to rdfQuery
I'm sorry Melvin,

I just saw now that you were interested in an RDF/XML serialization.
Thanks alot to Jeni for this fantastic feature.

Oana.

On Aug 5, 12:22 pm, Melvin Carvalho <melvincarva...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages