This object represents an RDF datasource. It will load data from an RDF file or URL as needed. To instantiate it, use one of the following forms:

var dsource=new RDFDataSource ( uri );
var dsource=new RDFDataSource ( uri , callbackFn );

This will create a new datasource for the given URI. The URI may be an internal RDF datasource, (such as rdf:bookmarks) or a pointer to an RDF file or URL. If the URI is null, an empty in-memory datasource will be created. If the second argument is null, the datasource is loaded synchronously. If a callback function is supplied as the second argument, the datasource is loaded asynchronously and the function is called when the datasource has finished loading. Note that not all datasources may be loaded synchronously. The callback function is passed the datasource as its first argument.

Properties and Methods:

copyAllToDataSource ( dsource2 )

Copies all of the resources from the datasource and adds them into another. The argument should be the RDFDataSource to copy the resources to.

deleteRecursive ( node )

Deletes a node from the datasource and all resources descending from it in the tree. This only works for datasources that don't have circular references. The node argument may be an RDFNode or a URI.

getAllResources ( )

Returns an RDFEnumerator of all the resources in the datasource.

getAnonymousNode ( )

Returns an RDFNode with a randomly generated URI.

getLiteral ( uri )

Gets an RDFLiteral of the datasource, identified by URI. It doesn't necessarily have to exist in the datasource.

getNode ( uri )

Gets an RDFNode of the datasource, identified by URI. It doesn't necessarily have to exist in the datasource.

getRawDataSource ( )

Returns the nsIRDFDataSource object for the datasource.

parseFromString ( string , baseURI )

Takes a string of RDF, parses it, and appends the nodes into the datasource. You must also specify the base URI for the datasource.

refresh (sync)

Reloads the contents of the datasource from its original RDF file. If sync is set to true, the function does not return until it has completed.


Writes any changes made to the datasource back to its RDF file. This only works for writeable datasources.

serializeToStream ( outputStream )

Saves a serialized version of the datasource to an nsIOutputStream.

serializeToString ( )

Returns the contents of the datasource, serialized as a string.

Copyright (C) 1999 - 2003 XulPlanet.com