[Jslib] Re: RDF classes

Martin Kutschker dreckskerl@glump.at
Mon, 11 Feb 2002 20:53:11 +0100


Eric Plaster wrote:

> Thanks martin.  I was begining to wonder if anyone cared ;)
> 
> Anyway, a couple of things up front:
> 
>   1. I didn't have a lot of time to devote to it.


Oh well, that's the same with me ;-)

>   2. I had to think of how I was going to satisfy two camps (i.e. using
>      it as a hiarchical data store, and a graph).
> 
> Because of this, I wanted to just get something out.  I know it's not 
> complete, but that's what open source is all about right?  Through it 
> out there and see if people jump in.


Yes, better to have an incomplete start than nothing at all.

>> The addXXX()-methods use a relative name scheme. You cannot add a 
>> resource with an arbitrary name. Perhaps some addXXXAbsolute().methods 
>> could be used to solve this problem.
> 
> This was a sticky problem that someone with more js experience might 
> help with.  I didn't have a good way to determine if it was an absolute 
> or not (without using a magic path like we did in the past - yuck). 
> Perhaps adding these method are the answer.  In C++ I would do something 
> like this:
> 
>    bool addNode( char *nodename, bool absolute = false );


Well, that is rather easy.

function (aNode, aAbsolute) {
if (aAbsolute) { // will trigger if not null and not eqal 0
   ...
}

>> The RDF class only allows for "root" containers. Why? It is perfectly 
>> ok to have a node as root element. I suggest ading addRootNode(). I'm 
>> not sure if we need a getRootNode.
> 
> Just didn't get around to it.  This one is also a little tricky, because 
> there is no container to attach it to.  I just need to look into it, and 
> I haven't had time.  If anyone has time to do so, that would be great.


I figure just getting the resource and flushing the datasource would all 
be that is needed. But I have not tested it.


>> The container class is missing a getResource method. It would be nice 
>> have access to the underlying XPCOM component. [Note: RDFResource and 
>> RDFContainer might derive from a RDFBaseResource class to add this 
>> functionality.] 
> 
> It does have this.  If you look, RDFContainer is derived from 
> RDFResource.  So the container class has all the members of the resource 
> class.  I did it this way because a container can do everything a 
> resource can, plus some.


Great, I must have missed this.

>> Reference attributes are still missing. I have posted, based on 
>> another post, a method for the old version of the rdf classes.
>>
>> Eg, in chrome.rdf i found something like this:
>>
>> <RDF:Seq about="urn:mozilla:locale:root">
>>     <RDF:li resource="urn:mozilla:locale:en-US"/>
>>     <RDF:li resource="urn:mozilla:locale:US"/>
>> </RDF:Seq>
>>
>> How would I do this with the classes? 
> 
> I have a "getSubject()" member that would return the subject.  For 
> example, for the seq above it would return "urn:mozilla:locale:root". Is 
> this different that what you would like to see?


I meant how do I operate on the Seqs content.

>> I might feel for adding some of these thing, if I create a new version 
>> of mozCalc. 
> 
> It would be great if you could help.

I am about to post some changes. I'm not sure, but I think I used to 
have cvs access. So I could check the changes in, if everyone agrees 
they are fine.

Masi