Re: Loosing assertions

Axel Hecht <[email protected]>
Newsgroups gmane.comp.mozilla.devel.rdf
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Neil Stansbury wrote:
> Hi all,
> 
> I am loading a number of datasources from both local files and remote 
> URLs into a composite datasource.
> 
> The individual datasources are retrieved via:
> 
> nsIRDFService.GetDataSource( nsIIOService.NewfileUri )
> or
> nsIRDFService.GetDataSource( http URL )
> 
> I am now trying to assert changes manually into the composite ds rather 
> than refreshing the entire remote datasources.
> 
> 
> The odd thing is when I assert() into the composite DS, I know the 
> assertion works initially as I have CSS selectors that change as soon as 
> the assertion completes. But when I check the value immediately after, 
> it is as it was.
> 
> 
> 
> For example:
> 
> var nsIRDFService = 
> Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
> 
> var nsIRDFService =
>   nsIRDFService.QueryInterface(Components.interfaces.nsIRDFService);
> 
> var subject =
>   nsIRDFService.GetResource(subject);
> 
> var predicate =
>   nsIRDFService.GetResource(predicate);
> 
> var object = CompDS.GetTarget(subject, predicate, true);
> 
> var value = object.QueryInterface(Components.interfaces.nsIRDFLiteral);
> 
> alert( value );
> 
> 
> value = "new value"
> 
> var literal = nsIRDFService.GetLiteral(value);
> 
> CompDS.Assert(subject, predicate, literal, true);
> 
> // Check
> object = CompDS.GetTarget(subject, predicate, true);
> value = object.QueryInterface(Components.interfaces.nsIRDFLiteral);
> 
> alert( value );        // Still old value
> 

you end up with

  foo -> bar -> lit1
     |-> bar -> lit2

This does make foo -> bar -> lit2 true, but the first target is still lit1.

Do you want to Change instead of Assert? Or use GetTargets and pick the 
right one.

Axel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.