[Jslib] Creating a new RDF file with the rdf libraries
Eric Hodel
drbrain@segment7.net
Sun, 07 Apr 2002 02:08:26 +0100
I'm trying to use the following code to create a new RDF file to cache
data for a livejournal client. The Filesystem stuff I stole out of
mozcalc as jslib does not have a getProfileDir() function in DirUtils (I
didn't check the actual code yet).
The only thing I get so far is the file "livelizard.rdf" created in my
profile directory. However, the seq (urn:livelizard:moods) is always
null, so none of the data gets copied. I've looked through the docs,
but can't seem to figure out how to put the pieces together to make it
do what I want.
(Looking through mozcalc wasn't any help either, apparently it suffers
from a similar problem.)
function saveMoods() {
var file = Filesystem.concatPath(Filesystem.getMozUserHomeDir(),
"livelizard.rdf");
var livelizardRDF = new RDFFile(file);
var seq = livelizardRDF.addRootSeq("urn:livelizard:moods");
if (seq != null) {
for (var i = 1; i <= moods.length; i++) {
var mood = moods[i];
var mood_id = mood[MOOD_ID];
var mood_name = mood[MOOD_NAME];
//alert(i + " id: " + mood_id + ", name: " + mood_name);
var node = seq.addNode(mood_id);
seq.setAttribute("urn:livelizard:moods:" + mood_id,
"Name", mood_name);
}
}
livelizardRDF.flush();
}