Set up environment for RDF parser

This commit is contained in:
aurimasv 2012-04-26 17:36:17 -05:00
parent 53d336681b
commit ea767e5647
4 changed files with 39 additions and 5 deletions

View file

@ -1,6 +1,7 @@
// Tweaks to get the Tabulator RDF library to work without Tabulator. All of this happens in the // Tweaks to get the Tabulator RDF library to work without Tabulator. All of this happens in the
// Zotero.RDF.AJAW namespace. // Zotero.RDF.AJAW namespace.
var kb = new RDFIndexedFormula(); $rdf.RDFIndexedFormula = $rdf.IndexedFormula;
var tabulator = {log:{debug:function(arg) { $rdf.RDFSymbol = $rdf.Symbol;
Zotero.debug(arg, 4); $rdf.RDFBlankNode = $rdf.BlankNode;
}}};
Zotero.RDF.AJAW = $rdf;

View file

@ -0,0 +1,32 @@
/* Set up the environment before loading the rest of the files into Zotero */
var $rdf = {
Util: {
ArrayIndexOf: function (arr, item, i) {
//supported in all browsers except IE<9
return arr.indexOf(item, i);
},
RDFArrayRemove: function(a, x) { //removes all statements equal to x from a
for(var i=0; i<a.length; i++) {
//TODO: This used to be the following, which didnt always work..why
//if(a[i] == x)
if (a[i].subject.sameTerm( x.subject ) &&
a[i].predicate.sameTerm( x.predicate ) &&
a[i].object.sameTerm( x.object ) &&
a[i].why.sameTerm( x.why )) {
a.splice(i,1);
return;
}
}
throw "RDFArrayRemove: Array did not contain " + x;
},
},
};
var tabulator = {
log: {
debug: Zotero.debug,
warn: Zotero.debug
}
};
var alert = tabulator.log.warn;

View file

@ -2311,7 +2311,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
* Serializes the current RDF to a string * Serializes the current RDF to a string
*/ */
"serialize":function(dataMode) { "serialize":function(dataMode) {
var serializer = Serializer(); var serializer = Zotero.RDF.AJAW.Serializer(this._dataStore);
for(var prefix in this._dataStore.namespaces) { for(var prefix in this._dataStore.namespaces) {
serializer.suggestPrefix(prefix, this._dataStore.namespaces[prefix]); serializer.suggestPrefix(prefix, this._dataStore.namespaces[prefix]);

View file

@ -234,6 +234,7 @@ function makeZoteroContext(isConnector) {
// Load RDF files into Zotero.RDF.AJAW namespace (easier than modifying all of the references) // Load RDF files into Zotero.RDF.AJAW namespace (easier than modifying all of the references)
const rdfXpcomFiles = [ const rdfXpcomFiles = [
'rdf/init',
'rdf/uri', 'rdf/uri',
'rdf/term', 'rdf/term',
'rdf/identity', 'rdf/identity',