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
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,