rdfstore.js

Client-side RDF store


Objects

Properties

Methods

Constants


OAT.RDFStore(callback, options)

Creates the object. Argument callback is executed every time store's contents change. Available options (properties of options object) are:


OAT.RDFStore::data.triples

All loaded data in a big array of triples (array of arrays).

OAT.RDFStore::data.all

All loaded data in a complex JSON object, as shown below.

[
	{
		preds:{
			"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":[
				"http://www.w3.org/2000/10/swap/pim/contact#Male", 
				"http://xmlns.com/foaf/0.1/Person"
			],
			"http://www.w3.org/2000/01/rdf-schema#label":["Tim Berners-Lee"], 
			"http://www.w3.org/2000/10/swap/pim/contact#assistant":[{...}], 
			"http://www.w3.org/2000/10/swap/pim/contact#homePage":["./"], 
			"http://www.w3.org/2000/10/swap/pim/contact#office":[{...}]
		},
		ouri:"samples/tbl.xml",
		type:"http://xmlns.com/foaf/0.1/PersonalProfileDocument",
		uri:"_:832_0", 
		back:[{...}]
	}, 
	...
]

OAT.RDFStore::data.structured

Loaded data after filters have been applied. Same structure as data.all.


OAT.RDFStore::addURL(url, onstart, onend)

Dereferences url and adds its contents to store. Two remaining arguments are used to override global ajaxStart and ajaxEnd parameters.

OAT.RDFStore::addTriples(triplesArray, url)

Adds an array of triples (triplesArray) to storage. The url specifies the address from where these triples originate.

OAT.RDFStore::addXmlDoc(xmlDoc, url)

Adds an XML document (fetched by OAT.AJAX.GET for instance) to storage. The url specifies the address from where this document originates.

OAT.RDFStore::getTitle(itemReference)

Returns a reasonable title (falls back to URI) of an item in storage.

OAT.RDFStore::simplify(string)

Simplifies an URI by removing as much as possible (leaving the part after '#' or '/').

OAT.RDFStore::addFilter(type, value1, [value2])

Applies a pass filter to store contents. Filter type is specified as one of available constants. For FILTER_PROPERTY, both 2nd and 3rd arguments should be used: these specify predicate value and object value (only resources having this P and O will pass).
For FILTER_URI, only 2nd argument should be used: this value specifies an URI to be filtered (only resources having this URI as O or S will pass).

OAT.RDFStore::removeFilter(type, value1, [value2])

Removes a previously set filter; syntax is the same as in addFilter.

OAT.RDFStore::disable(url)

Temporarily disables (removes) all triples originating from url from the store.

OAT.RDFStore::enable(url)

Re-enables previously disabled url, so its contents are loaded in a store.

var callback = function() {
	alert("Store contents have changed, check them out!");
}
var store = new OAT.RDFStore(callback,{});
store.addURL("myRDF.n3");