Set up environment for RDF parser
This commit is contained in:
parent
53d336681b
commit
ea767e5647
|
@ -1,6 +1,7 @@
|
|||
// Tweaks to get the Tabulator RDF library to work without Tabulator. All of this happens in the
|
||||
// Zotero.RDF.AJAW namespace.
|
||||
var kb = new RDFIndexedFormula();
|
||||
var tabulator = {log:{debug:function(arg) {
|
||||
Zotero.debug(arg, 4);
|
||||
}}};
|
||||
$rdf.RDFIndexedFormula = $rdf.IndexedFormula;
|
||||
$rdf.RDFSymbol = $rdf.Symbol;
|
||||
$rdf.RDFBlankNode = $rdf.BlankNode;
|
||||
|
||||
Zotero.RDF.AJAW = $rdf;
|
32
chrome/content/zotero/xpcom/rdf/init.js
Normal file
32
chrome/content/zotero/xpcom/rdf/init.js
Normal 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;
|
|
@ -2311,7 +2311,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
* Serializes the current RDF to a string
|
||||
*/
|
||||
"serialize":function(dataMode) {
|
||||
var serializer = Serializer();
|
||||
var serializer = Zotero.RDF.AJAW.Serializer(this._dataStore);
|
||||
|
||||
for(var prefix in this._dataStore.namespaces) {
|
||||
serializer.suggestPrefix(prefix, this._dataStore.namespaces[prefix]);
|
||||
|
|
|
@ -234,6 +234,7 @@ function makeZoteroContext(isConnector) {
|
|||
|
||||
// Load RDF files into Zotero.RDF.AJAW namespace (easier than modifying all of the references)
|
||||
const rdfXpcomFiles = [
|
||||
'rdf/init',
|
||||
'rdf/uri',
|
||||
'rdf/term',
|
||||
'rdf/identity',
|
||||
|
|
Loading…
Reference in New Issue
Block a user