> Got a quick question ( as I was unable to find it in the doc): how to
> merge two RDF graphs?
I'm trying to figure out what you're aiming to do, because there are a
few different nuances on what 'merge' might mean here.
I think you probably want to union two rdfQuery objects or databanks
together, which you can do by adding them to each other. Perhaps
you're after:
merged = outgraph.add(newgraph);
Note that merged is a separate object from outgraph and newgraph (a
separate databank that is the union of the two other databanks), and
that any further addition to it causes the triples to be added to both
original databanks.
You could also manually iterate over the triples in one of the
databanks and add them to the other, if you wanted, but that would
actually change the original databank (and the results of any queries
on it), obviously.
I haven't yet implemented an 'import' of JSON (or any other format),
but that's something that I do intend to do.
I'm really happy to accept suggestions for ways things could be made
easier or more intuitive, or other developments that would be useful.
And if you want to donate some documentation, that would be great! Let
me know your Google mail address and I can add you as a member of the
project.
Cheers,
Jeni
--
Jeni Tennison
http://www.jenitennison.com
If outgraph is a databank too, then it should work (remember to
capture the result of the .add() method and use that as the merged
result, as it's a new databank rather than an update to the old one).
If outgraph is a rdfQuery object, then you need to do:
merged = outgraph.add($.rdf({databank: tmpgraph }));
to create a new merged rdfQuery object, or:
merged = outgraph.databank.add(tmpgraph);
to create a new merged databank object.
You don't seem to be capturing the result of adding the tmpgraph to
the outgraph. As I said, it's a different object, so if you want to do
something with it, you need to capture it. Perhaps doing something
like the following on line 66:
outgraph = outgraph.add(createDiffFieldGraph(this.field.value,
this.key.value, this.val.value, newval));
or you might want to replace that line with something like:
addFieldGraph(outgraph, this.field.value, this.key.value,
this.val.value, newval);
and then have:
function addFieldGraph(databank, fieldURI, keyURI, valURI, val) {
databank
.add('<' + fieldURI + '> rdf:type pb:UpateableField .')
.add('<' + fieldURI + '> pb:key <' + keyURI + '> .')
.add('<' + fieldURI + '> pb:value <' + valURI + '> .')
.add('<' + valURI + '> rdf:value ' + val + ' .');
return databank;
}
which actually adds the triples to the databank without going to the
trouble of creating a separate databank for them.
A databank is a triplestore. A rdfQuery object is an object that
represents a query over a triplestore.
Hope that helps,
On 4 Mar 2009, at 16:01, mhausenblas wrote:
> That was it. Thank you sooo much!!! Credits will be added, for sure ;)
Glad you got it working!
By the way, if you do want to do diffs, the best I can offer is the
except() method, either on two databanks or two queries. Something like:
added = after.except(before);
removed = before.except(after);
I'm going to be doing a presentation at OXON SWIG next week about
rdfQuery; if you get something visible running, I'd love to demo it if
that would be OK?
Again, thanks a lot for your great first-level support - just as brilliant
as rdfquery itself :)
I've now got a first demo of what we call RDForms (RDFa marked-up + HTML
form) that has rdfquery as it's core [1]. I'm still improving and adding
stuff, but you may wanna have a look at it and demo it, if you think it's
not too premature.
The vision of RDForms/pushback [2] is to turn the read-only Semantic Web/Web
of Data into a read/write one. The starting point is always the 'semantic
space', that is, some RDF graph, such as [3] (RDFised version of the Twitter
statuses of a demo account) . What I did so far is parsing this RDF/XML
(unfortunately this is currently not possible with rdfquery, right?) and, by
using a predefined RDForm, pushing back the changes (add/delete) to a Web
2.0 source (Twitter, in this very first and very simple example).
My Goolge email, btw, is Michael.H...@gmail.com ;)
Cheers,
Michael
[1]
http://esw.w3.org/topic/PushBackDataToLegacySourcesRDForms#RDForms_Examples
[2] http://esw.w3.org/topic/PushBackDataToLegacySources
[3]
http://linkeddata.uriburner.com/about/rdf/http://twitter.com/pushback_demo
--
Dr. Michael Hausenblas
DERI - Digital Enterprise Research Institute
National University of Ireland, Lower Dangan,
Galway, Ireland, Europe
Tel. +353 91 495730
http://sw-app.org/about.html
http://webofdata.wordpress.com/