Re: Loosing assertions

Neil Stansbury <[email protected]>
Newsgroups gmane.comp.mozilla.devel.rdf
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Hi Axel,

Thanks, I'm being an idiot had had forgotten that it would just assert a 
new arc not replace it.

I have tried change() instead using the code below, but I still do end 
up with two arcs instead of the original one when I iterate through them.


var resource = nsIRDFService.GetResource( resource );
var property = nsIRDFService.GetResource( property );

var oldTarget = ds.GetTarget( resource, property, true );
var newTarget = nsIRDFService.GetLiteral( "NewVal" );

ds.Change( resource, property, oldTarget, newTarget );

var nsEnum = ds.GetTargets( resource, property, true );

// Check
while( nsEnum.hasMoreElements() )	{
   var target = nsEnum.getNext();
   target = target.QueryInterface( Components.interfaces.nsIRDFLiteral );
   alert( "Object: " +target.Value );		// Two assertions
}


Am I missing something again?

Cheers,

N



Axel Hecht wrote:
> 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.