[Jslib] Re: RDF redesign
Eric Plaster
plaster@visi.com
Wed, 07 Nov 2001 12:05:49 -0600
--------------080805040400040308000105
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Well, maybe this is a good time to give a status report on what I have
done so far. Working on a chart of functionallity, I took an OOD point
of view and broke out what was common and what was (as I preceived it)
to be unique to a class. So if you look in the jslib/libraries/rdf
directory there should be the following files/classes:
* RDFBase
* This holds common data members and functions that are common
to all the classes bellow (i.e. this.dsource, this.flush())
* RDFResource
* This is basicly the node. You can set/get/find attributes.
* RDFContainer
* This has all the members of RDFResource plus members to
getSubNodes, getSubSeq, etc...
* RDF
* This DOES NOT derive from RDFResource or RDFContainer, but
it creates these objects and returns them. It has member
like getRootSeq("urn:blah:...") and getAllSeqs()
* RDFFile
* This just does your normal create-if-not-there thing and is
derived from RDF
Now, you can look at my project (rpgtools) to see how I've been using it
in my project (or rather testing it with my project :) Anyway, here is
how it would look with the new rdf classes:
var path = "/tmp/foo.rdf";
var rdf = new RDF(path);
var seq = rdf.getSeq("urn:test:data");
var list = seq.getSubNodes();
for(var i=0; i<list.length;i++) {
var name = list[i].getAttribute("name");
dump("name: "+name+"\n");
}
... or ...
var node = seq.getNode("bob");
As you can see, I've eliminated the need for NC, or a root node. The
new classes works more on the graph idea. You ask the RDF class for a
seq, and it either returns a RDFContainer of type "seq" or it returns
null. You can then manipulate that seq by using setAttribute,
getSubNodes, addNode, etc...
So...
Now that that is all said and done. I'm thinking about rearranging it
again. I have to do some more thinking about it, but here is what I was
kind of thinking:
You have a "rdf" class. For this class you can query resources
(RDFResource), with this resource, you can set subject, predicate, or
object. Then you can also add any sub resources if you want (remember
you can make any li into a seq with one call, and without looseing any
arcs). Thus any RDFResource can be changed into a RDFContainer...
Let me know what you guys think...
-eric
Martin T. Kutschker wrote:
> Eric Plaster <plaster@urbanrage.com <mailto:plaster@urbanrage.com>
> > schrieb in im Newsbeitrag:
> public.mozdev.jslib/3BD88800.3090502@urbanrage.com
> <mailto:public.mozdev.jslib/3BD88800.3090502@urbanrage.com>...
>
>
> Ok, I said that I was going to work on this back in Aug, but got
> distracted by a lay off. So I'm going to start work on it again
> (see my posting here on 8/8). I'll be checking in stuff into
> libraries/rdf (which currently doesn't exist) so I shouldn't be
> getting in anyones way.
>
> If anyone has any suggestions, shoot them my way. My goals:
>
> * Full compatability with all rdfs (no magic)
>
> Magic is a tricky thing :-) Though I think it could still come in
> handy. Perhaps we could use special classes with magic or magic modes.
> Anyway, I had an idea for magic:
>
>
>
> RDF(...., "urn:base", "marker")
>
>
>
> Marker is eg "data" or "root, but may be empty. Magic only comes into
> effect if a node starts with a colon:
>
>
>
> "urn:base:somechild" -> "urn:base:somechild"
>
> ":somechilde" -> "urn:base:somechild"
>
> "urn:otherbase" -> "urn:otherbase"
>
>
>
> I know we have seen now, that we don't have to have a single "root "
> for a given datasource but working from a root within the graph (using
> "magic") might still come in handy. Perhaps the "root magic"
> should move away from the constructor to somewhere else (to some
> analogy of container utils?),
>
>
>
> Masi
>
--
Eric Plaster
Urban Rage Software <http://www.urbanrage.com>
Senior Software Engineer
RPG tools project
rpgtools@urbanrage.com
http://rpgtools.mozdev.org
*/ AD&D tools for the player and the DM/*
--------------080805040400040308000105
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<br>
Well, maybe this is a good time to give a status report on what I have done
so far. Working on a chart of functionallity, I took an OOD point of view
and broke out what was common and what was (as I preceived it) to be unique
to a class. So if you look in the jslib/libraries/rdf directory there should
be the following files/classes:<br>
<ul>
<li>RDFBase</li>
<ul>
<li>This holds common data members and functions that are common to all
the classes bellow (i.e. this.dsource, this.flush())<br>
</li>
</ul>
<li>RDFResource</li>
<ul>
<li>This is basicly the node. You can set/get/find attributes.<br>
</li>
</ul>
<li>RDFContainer</li>
<ul>
<li>This has all the members of RDFResource plus members to getSubNodes,
getSubSeq, etc...<br>
</li>
</ul>
<li>RDF</li>
<ul>
<li>This DOES NOT derive from RDFResource or RDFContainer, but it creates
these objects and returns them. It has member like getRootSeq("urn:blah:...")
and getAllSeqs()<br>
</li>
</ul>
<li>RDFFile</li>
<ul>
<li>This just does your normal create-if-not-there thing and is derived
from RDF</li>
</ul>
</ul>
Now, you can look at my project (rpgtools) to see how I've been using it
in my project (or rather testing it with my project :) Anyway, here is how
it would look with the new rdf classes:<br>
<br>
var path = "/tmp/foo.rdf";<br>
var rdf = new RDF(path);<br>
var seq = rdf.getSeq("urn:test:data");<br>
var list = seq.getSubNodes();<br>
for(var i=0; i<list.length;i++) {<br>
var name = list[i].getAttribute("name");<br>
dump("name: "+name+"\n");<br>
}<br>
<br>
... or ...<br>
var node = seq.getNode("bob");<br>
<br>
As you can see, I've eliminated the need for NC, or a root node. The new
classes works more on the graph idea. You ask the RDF class for a seq, and
it either returns a RDFContainer of type "seq" or it returns null. You can
then manipulate that seq by using setAttribute, getSubNodes, addNode, etc...<br>
<br>
So...<br>
Now that that is all said and done. I'm thinking about rearranging it again.
I have to do some more thinking about it, but here is what I was kind of
thinking:<br>
<br>
You have a "rdf" class. For this class you can query resources (RDFResource),
with this resource, you can set subject, predicate, or object. Then you
can also add any sub resources if you want (remember you can make any li
into a seq with one call, and without looseing any arcs). Thus any RDFResource
can be changed into a RDFContainer...<br>
<br>
Let me know what you guys think...<br>
-eric<br>
<br>
Martin T. Kutschker wrote:<br>
<blockquote type="cite" cite="mid:public.mozdev.jslib%2F9sb1fr$gvu$1@tigris.mozdev.org">
<title></title>
<meta content="MSHTML 5.50.4616.200" name="GENERATOR">
<style></style>
<blockquote dir="Ltr" style="padding-right: 0px; padding-left: 5px; margin-left: 5px; border-left-width: 2px; border-left-style: solid; border-left-color: rgb(0,0,0); margin-right: 0px; ">
<div>Eric Plaster <<a href="mailto:plaster@urbanrage.com">plaster@urbanrage.com</a>
> schrieb in im Newsbeitrag: <a href="mailto:public.mozdev.jslib/3BD88800.3090502@urbanrage.com">
public.mozdev.jslib/3BD88800.3090502@urbanrage.com</a>...</div>
<br>
Ok, I said that I was going to work on this back in Aug, but got distracted
by a lay off. So I'm going to start work on it again (see my posting
here on 8/8). I'll be checking in stuff into libraries/rdf (which currently
doesn't exist) so I shouldn't be getting in anyones way.<br>
<br>
If anyone has any suggestions, shoot them my way. My goals:<br>
<ul>
<li>Full compatability with all rdfs (no magic) </li>
</ul>
</blockquote>
<div dir="Ltr">Magic is a tricky thing :-) Though I think it could still
come in handy. Perhaps we could use special classes with magic or magic
modes. Anyway, I had an idea for magic:</div>
<div dir="Ltr"> </div>
<div dir="Ltr">RDF(...., "urn:base", "marker")</div>
<div dir="Ltr"> </div>
<div dir="Ltr">Marker is eg "data" or "root, but may be empty. Magic
only comes into effect if a node starts with a colon:</div>
<div dir="Ltr"> </div>
<div dir="Ltr">"urn:base:somechild" -> "urn:base:somechild" </div>
<div dir="Ltr">":somechilde" -> "urn:base:somechild"</div>
<div dir="Ltr">"urn:otherbase" -> "urn:otherbase"</div>
<div dir="Ltr"> </div>
<div dir="Ltr">I know we have seen now, that we don't have to have a
single "root " for a given datasource but working from a root within the
graph (using "magic") might still come in handy. Perhaps the "root magic"
should move away from the constructor to somewhere else (to some analogy
of container utils?),</div>
<div dir="Ltr"> </div>
<div dir="Ltr">Masi</div>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td valign="Top">Eric Plaster<br>
</td>
<td valign="Top" align="Right"><a href="http://www.urbanrage.com" style="color: maroon; text-decoration: none; ">
Urban Rage Software</a><br>
</td>
</tr>
<tr>
<td valign="Top"> Senior Software Engineer<br>
</td>
<td valign="Top" align="Right"> RPG tools project<br>
</td>
</tr>
<tr>
<td valign="Top"> <a class="moz-txt-link-abbreviated" href="mailto:rpgtools@urbanrage.com">rpgtools@urbanrage.com</a><br>
</td>
<td valign="Top" align="Right"><a href="http://rpgtools.mozdev.org" style="color: maroon; text-decoration: none; ">
http://rpgtools.mozdev.org<br>
</a></td>
</tr>
</tbody>
</table>
<div align="Center"><font color="#999999"><b><i><font color="#666666"><small>
AD&D tools for the player and the DM</small></font></i></b></font></div>
</div>
<br>
</body>
</html>
--------------080805040400040308000105--