Jeremy Gillick wrote:

I've found a solution, but I hope there's an easier way. I have to manually
Unassert each property; appended code below:



Maybe n.p.m.rdf is the better venue?


/be

...
//Name
oProp =
oRdf.GetResource("http://mozilla.org/package/jgillick/switchproxy/rdf#name";)
;
oDs.Unassert(oProxy, oProp, oDs.GetTarget(oProxy, oProp, true));

//Id
oProp =
oRdf.GetResource("http://mozilla.org/package/jgillick/switchproxy/rdf#id";);
oDs.Unassert(oProxy, oProp, oDs.GetTarget(oProxy, oProp, true));

//Proxy Url
oProp =
oRdf.GetResource("http://mozilla.org/package/jgillick/switchproxy/rdf#proxy";
);
oDs.Unassert(oProxy, oProp, oDs.GetTarget(oProxy, oProp, true));
...

Is there an easier way to do all of this?

Thanks,
Jeremy

"Jeremy Gillick" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]


I have an application that adds data to the 'rdf:localstore'. When I add


an


entry it looks something like this:

<RDF:Seq about="http://mozilla.org/package/jgillick/switchproxy/rdf/all";>
   <RDF:li
resource="http://mozilla.org/package/jgillick/switchproxy/rdf/all/test"/>
</RDF:Seq>
<RDF:Description
about="http://mozilla.org/package/jgillick/switchproxy/rdf/all/test";
                  NS4:name="test"

NS4:id="http://mozilla.org/package/jgillick/switchproxy/rdf/all/test";
                  NS4:proxy="test" />

When I try to remove
http://mozilla.org/package/jgillick/switchproxy/rdf/all/test, it only


remove


the <RDF:LI> tag in the Seq block, but leaves the <RDF:Description> tag.
This causes problems when somebody tries to add an item later with the


same


name, which coorisponds to the about attribute. I need to be able to


remove


the LI reference and the actual data.

The code I'm currently using to remove the item is below:

-----------------------------------------
const gRdfDataSouce = "rdf:localstore";
const gRdfRoot =


"http://mozilla.org/package/jgillick/switchproxy/rdf/all";;


var oItem = document.getElementById('proxy-list').selectedItem;
var oRdf =



Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.i


nterfaces.nsIRDFService);
var oRdfC =



Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components


.interfaces.nsIRDFContainer);
var oDs = oRdf.GetDataSource(gRdfDataSouce);
var oRoot = oRdf.GetResource(gRdfRoot);
var oProxy = oRdf.GetResource(oItem.id);

oRdfC.Init(oDs, oRoot);

//Remove
oRdfC.RemoveElement(oProxy, true);
-----------------------------------------

In this example, oItem.id equals
"http://mozilla.org/package/jgillick/switchproxy/rdf/all/test";

Thanks,
Jeremy








n
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to