mozdev.org

JSLib
Page Updated: April 07, 2002
Latest Version: 0.1.375
Debug | Install | File I/O | RDF | Network | Sound | Utils | XUL | Zip
Home | Mailing List | Install | Source Code | Downloads | Bugs | docs | clients

RDF

Preamble

RDF in mozilla goes a long way in making a complex graph based information storage facility useable.  This module of jslib is designed to make it even easier.

No longer is expertise in C or C++ required, nor does one need to bother with the details of implementing the XPConnect wrapper to access local file handling routines.

Files can be viewed online here .

Full source code is available under the MPL license.

Contents

How to use these classes

First off, I'd like to say that this is not a comprehensive set of classes for rdf manipulation.  I wrote these classes (with help from Pete Collins, and Martin Kutschker and the rest of the gang at jslib) as a way to easily manipulate rdf files for use in my own creations.  Once I saw that it was something that other people might be interested in, I brought it to jslib.  If there is a feature that you think is missing, or want to change something, by all means join the discussion at public.mozdev.jslib on news.mozdev.org.

Now that that is said, we can get into useage.  At the bottom of this page is a list of the different classes, and a link to there api.  If you're thinking of jumping ahead, remember that RDFBase is just a base class and does nother of real value by it's self.  RDFContainer, and RDFResource are beget by calling functions out of RDF and RDFFile.

RDF

This is the main class.  This is where every thing starts.  To use the various RDF classes, you must first have an RDF class.

EXAMPLE

var rdf = new RDF("http://www.somesite.com/some.rdf");

RDFFile

This is a derived class of RDF.  This object can be used to open or create an rdf file.

EXAMPLE

var rdf = new RDFFile("/tmp/bob.rdf");
OR
var rdf = new RDFFile("file:///tmp/bob.rdf");

Resources

In the rdf world everything is a resource; however, for lack of a better word for it, this class is considered a node or element within the graph.  For example, if you had a container with a list of web site addresses, each of those addresses would be resources.

EXAMPLE

var node = rdf.getNode("some:resource:path");
node.setAttribute("name", "value");
rdf.flush();

Containers

Containers are just special resources.  These resources can hold other resources.

EXAMPLE
var seq = rdf.getRootSeq("some:resource:path");
seq.setAttribute("name", "value");
var list = seq.getSubNodes();
for(var i=0; i<list.length; i++) {
    dump("node: "+list[i].getSubject+"\n");
}

Walking an unknown rdf graph

In the test directory is a file called test.js .  This has some simple code to dump out the contents of an rdf file.

RDF Classes Available
rdf.js RDF manipulation
rdfFile.js RDF manipulation of a file
rdfContainer.js RDF container class
rdfResource.js RDF resource class
rdfBase.js RDF Base class (should only be used by the above classes)

The jslib project can be contacted through the mailing list or the member list.
Copyright © 2000-2014. All rights reserved. Terms of Use & Privacy Policy.