write (assert) to an rdf file

Fxp <[email protected]> Sun, 10 May 2009 02:50:40 -0700 (PDT)
Newsgroups gmane.comp.mozilla.devel.rdf
Organization http://groups.google.com
Message-ID <[email protected]>
Hi,

I have an rdf file in a folder of my extension.

I want to add a new node, exactly the way it is described in the
tutorial:
https://developer.mozilla.org/en/XUL/Template_Guide/RDF_Modifications
.


The function always says it has no assertion for the asserted
triple...and the source file is never changed!!

Can someone tell me what is missing here for the rdf file to be
modified?

Thank you for your help.

Fran=E7ois



************* The function

function addDesc(){

var RDF =3D
  Components
  .classes["@mozilla.org/rdf/rdf-service;1"]
  .getService(Components.interfaces.nsIRDFService);
	var datasource =3D RDF.GetDataSource("chrome://fxdatatree/content/
template-guide-photos5.rdf");

	var source =3D RDF.GetResource("http://www.xulplanet.com/ndeakin/images/
t/obelisk.jpg");
	var predicate =3D RDF.GetResource("http://purl.org/dc/elements/1.1/
description");
	var target =3D RDF.GetLiteral("One of the thirty or so Egyptian
obelisks");

	datasource.Assert(source, predicate, target, true);
	alert(datasource.HasAssertion(source, predicate, target, true));
}


**************** the rdf file

<?xml version=3D"1.0"?>
<rdf:RDF xmlns:rdf=3D"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:dc=3D"http://purl.org/dc/elements/1.1/"
         xmlns:r=3D"http://www.xulplanet.com/rdf/"
         xmlns:nso=3D"http://www.daml.org/2001/09/countries/country-
ont#">

  <rdf:Seq rdf:about=3D"http://www.xulplanet.com/rdf/myphotos">
    <rdf:li rdf:resource=3D"http://www.xulplanet.com/ndeakin/images/t/
palace.jpg"/>
    <rdf:li rdf:resource=3D"http://www.xulplanet.com/ndeakin/images/t/
canal.jpg"/>
    <rdf:li rdf:resource=3D"http://www.xulplanet.com/ndeakin/images/t/
obelisk.jpg"/>
  </rdf:Seq>

  <rdf:Description rdf:about=3D"http://www.xulplanet.com/ndeakin/images/
t/palace.jpg"
                   dc:title=3D"Palace from Above"
                   dc:date=3D"2005-04-30T14:55:00+01.00"
                   dc:description=3D"View from the top of the tower
looking east of the Doges Palace">
    <r:country resource=3D"http://www.daml.org/2001/09/countries/iso#IT"/
>
  </rdf:Description>
  <rdf:Description rdf:about=3D"http://www.xulplanet.com/ndeakin/images/
t/canal.jpg"
                   dc:title=3D"Canal"
                   dc:date=3D"2005-05-06T10:15:00+01.00">
    <r:country resource=3D"http://www.daml.org/2001/09/countries/iso#NL"/
>
  </rdf:Description>
  <rdf:Description rdf:about=3D"http://www.xulplanet.com/ndeakin/images/
t/obelisk.jpg"
                   dc:title=3D"Obelisk">
    <r:country resource=3D"http://www.daml.org/2001/09/countries/iso#IT"/
>
  </rdf:Description>

  <nso:Country about=3D"http://www.daml.org/2001/09/countries/iso#IT"
               dc:title=3D"Italy"/>

  <nso:Country about=3D"http://www.daml.org/2001/09/countries/iso#NL"
               dc:title=3D"Netherlands"/>
</rdf:RDF>