From 53d336681bf498700b69babaefc218a490e440c0 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Wed, 25 Apr 2012 20:14:58 -0500 Subject: [PATCH 01/38] Tabulator v0.8 RDF parser initial commit --- chrome/content/zotero/xpcom/rdf/identity.js | 333 ++++++---------- chrome/content/zotero/xpcom/rdf/match.js | 107 ++--- chrome/content/zotero/xpcom/rdf/n3parser.js | 244 ++++++++---- chrome/content/zotero/xpcom/rdf/rdfparser.js | 73 +++- chrome/content/zotero/xpcom/rdf/serialize.js | 399 +++++++++++-------- chrome/content/zotero/xpcom/rdf/term.js | 374 +++++++++-------- chrome/content/zotero/xpcom/rdf/uri.js | 46 ++- 7 files changed, 839 insertions(+), 737 deletions(-) diff --git a/chrome/content/zotero/xpcom/rdf/identity.js b/chrome/content/zotero/xpcom/rdf/identity.js index d53b1bcc7c..da3b3ead21 100644 --- a/chrome/content/zotero/xpcom/rdf/identity.js +++ b/chrome/content/zotero/xpcom/rdf/identity.js @@ -1,6 +1,6 @@ // Identity management and indexing for RDF // -// This file provides RDFIndexedFormula a formula (set of triples) which +// This file provides IndexedFormula a formula (set of triples) which // indexed by predicate, subject and object. // // It "smushes" (merges into a single node) things which are identical @@ -15,38 +15,24 @@ /*jsl:option explicit*/ // Turn on JavaScriptLint variable declaration checking -owl_ns = "http://www.w3.org/2002/07/owl#"; -link_ns = "http://www.w3.org/2006/link#"; +$rdf.IndexedFormula = function() { + +var owl_ns = "http://www.w3.org/2002/07/owl#"; +// var link_ns = "http://www.w3.org/2007/ont/link#"; /* hashString functions are used as array indeces. This is done to avoid ** conflict with existing properties of arrays such as length and map. ** See issue 139. */ -RDFLiteral.prototype.hashString = RDFLiteral.prototype.toNT; -RDFSymbol.prototype.hashString = RDFSymbol.prototype.toNT; -RDFBlankNode.prototype.hashString = RDFBlankNode.prototype.toNT; -RDFCollection.prototype.hashString = RDFCollection.prototype.toNT; - -RDFIndexedFormula.prototype = new RDFFormula(); -RDFIndexedFormula.prototype.constructor = RDFIndexedFormula; -// RDFIndexedFormula.superclass = RDFFormula.prototype; -RDFIndexedFormula.SuperClass = RDFFormula; - -RDFArrayRemove = function(a, x) { //removes all elements equal to x from a - for(var i=0; i to [f(F,s,p,o),...] @@ -60,12 +46,10 @@ function RDFIndexedFormula(features) { this.whyIndex = []; // Array of statements with X as provenance this.index = [ this.subjectIndex, this.predicateIndex, this.objectIndex, this.whyIndex ]; this.namespaces = {} // Dictionary of namespace prefixes - if (features == undefined) features = ["sameAs", + if (features === undefined) features = ["sameAs", "InverseFunctionalProperty", "FunctionalProperty"]; // this.features = features - // Callbackify? - function handleRDFType(formula, subj, pred, obj, why) { if (formula.typeCallback != undefined) formula.typeCallback(formula, obj, why); @@ -85,36 +69,21 @@ function RDFIndexedFormula(features) { ''] = [ handleRDFType ]; // Assumption: these terms are not redirected @@fixme - if (features.indexOf("sameAs") >=0) + if ($rdf.Util.ArrayIndexOf(features,"sameAs") >= 0) this.propertyActions[''] = [ function(formula, subj, pred, obj, why) { + // tabulator.log.warn("Equating "+subj.uri+" sameAs "+obj.uri); //@@ formula.equate(subj,obj); return true; // true if statement given is NOT needed in the store }]; //sameAs -> equate & don't add to index -/* - function newPropertyAction(formula, pred, action) { - tabulator.log.debug("newPropertyAction: "+pred); - if (formula.propertyActions[pred] == undefined) - formula.propertyActions[pred] = []; - formula.propertyActions[pred].push(action); - // Now apply the function to to statements already in the store - var toBeFixed = formula.statementsMatching(undefined, pred, undefined); - var i; - for (i=0; i= 0) + + if ($rdf.Util.ArrayIndexOf(features,"InverseFunctionalProperty") >= 0) this.classActions["<"+owl_ns+"InverseFunctionalProperty>"] = [ function(formula, subj, pred, obj, addFn) { return formula.newPropertyAction(subj, handle_IFP); // yes subj not pred! }]; //IFP -> handle_IFP, do add to index - if (features.indexOf("FunctionalProperty") >= 0) + if ($rdf.Util.ArrayIndexOf(features,"FunctionalProperty") >= 0) this.classActions["<"+owl_ns+"FunctionalProperty>"] = [ function(formula, subj, proj, obj, addFn) { return formula.newPropertyAction(subj, handle_FP); @@ -123,6 +92,7 @@ function RDFIndexedFormula(features) { function handle_IFP(formula, subj, pred, obj) { var s1 = formula.any(undefined, pred, obj); if (s1 == undefined) return false; // First time with this value + // tabulator.log.warn("Equating "+s1.uri+" and "+subj.uri + " because IFP "+pred.uri); //@@ formula.equate(s1, subj); return true; } //handle_IFP @@ -130,17 +100,19 @@ function RDFIndexedFormula(features) { function handle_FP(formula, subj, pred, obj) { var o1 = formula.any(subj, pred, undefined); if (o1 == undefined) return false; // First time with this value + // tabulator.log.warn("Equating "+o1.uri+" and "+obj.uri + " because FP "+pred.uri); //@@ formula.equate(o1, obj); return true ; } //handle_FP - -} /* end RDFIndexedFormula */ +} /* end IndexedFormula */ +$rdf.IndexedFormula.prototype = new $rdf.Formula(); +$rdf.IndexedFormula.prototype.constructor = $rdf.IndexedFormula; +$rdf.IndexedFormula.SuperClass = $rdf.Formula; - -RDFIndexedFormula.prototype.newPropertyAction = function newPropertyAction(pred, action) { - tabulator.log.debug("newPropertyAction: "+pred); +$rdf.IndexedFormula.prototype.newPropertyAction = function newPropertyAction(pred, action) { + //$rdf.log.debug("newPropertyAction: "+pred); var hash = pred.hashString(); if (this.propertyActions[hash] == undefined) this.propertyActions[hash] = []; @@ -154,15 +126,9 @@ RDFIndexedFormula.prototype.newPropertyAction = function newPropertyAction(pred, return done; } - - - -RDFPlainFormula = function() { return RDFIndexedFormula([]); } // No features - - -RDFIndexedFormula.prototype.setPrefixForURI = function(prefix, nsuri) { +$rdf.IndexedFormula.prototype.setPrefixForURI = function(prefix, nsuri) { //TODO:This is a hack for our own issues, which ought to be fixed post-release - //See http://dig.csail.mit.edu/cgi-bin/roundup.cgi/tabulator/issue227 + //See http://dig.csail.mit.edu/cgi-bin/roundup.cgi/$rdf/issue227 if(prefix=="tab" && this.namespaces["tab"]) { return; } @@ -170,33 +136,36 @@ RDFIndexedFormula.prototype.setPrefixForURI = function(prefix, nsuri) { } // Deprocated ... name too generic -RDFIndexedFormula.prototype.register = function(prefix, nsuri) { +$rdf.IndexedFormula.prototype.register = function(prefix, nsuri) { this.namespaces[prefix] = nsuri } -/** simplify graph in store when we realize two identifiers are equal +/** simplify graph in store when we realize two identifiers are equivalent We replace the bigger with the smaller. */ -RDFIndexedFormula.prototype.equate = function(u1, u2) { - tabulator.log.debug("Equating "+u1+" and "+u2) - +$rdf.IndexedFormula.prototype.equate = function(u1, u2) { + // tabulator.log.warn("Equating "+u1+" and "+u2); // @@ + //@@JAMBO Must canonicalize the uris to prevent errors from a=b=c + //03-21-2010 + u1 = this.canon( u1 ); + u2 = this.canon( u2 ); var d = u1.compareTerm(u2); if (!d) return true; // No information in {a = a} var big, small; if (d < 0) { // u1 less than u2 - return this.replaceWith(u2, u1); + return this.replaceWith(u2, u1); } else { - return this.replaceWith(u1, u2); + return this.replaceWith(u1, u2); } } // Replace big with small, obsoleted with obsoleting. // -RDFIndexedFormula.prototype.replaceWith = function(big, small) { - tabulator.log.debug("Replacing "+big+" with "+small) // @@ +$rdf.IndexedFormula.prototype.replaceWith = function(big, small) { + //$rdf.log.debug("Replacing "+big+" with "+small) // @@ var oldhash = big.hashString(); var newhash = small.hashString(); @@ -205,7 +174,7 @@ RDFIndexedFormula.prototype.replaceWith = function(big, small) { if (oldlist == undefined) return; // none to move var newlist = ix[newhash]; if (newlist == undefined) { - ix[newhash] = newlist; + ix[newhash] = oldlist; } else { ix[newhash] = oldlist.concat(newlist); } @@ -219,28 +188,35 @@ RDFIndexedFormula.prototype.replaceWith = function(big, small) { this.redirections[oldhash] = small; if (big.uri) { - if (this.aliases[newhash] == undefined) - this.aliases[newhash] = []; - this.aliases[newhash].push(big); // Back link - - this.add(small, this.sym('http://www.w3.org/2006/link#uri'), big.uri) - - // If two things are equal, and one is requested, we should request the other. - if (this.sf) { - this.sf.nowKnownAs(big, small) - } - + //@@JAMBO: must update redirections,aliases from sub-items, too. + if (this.aliases[newhash] == undefined) + this.aliases[newhash] = []; + this.aliases[newhash].push(big); // Back link + + if( this.aliases[oldhash] ) { + for( var i = 0; i < this.aliases[oldhash].length; i++ ) { + this.redirections[this.aliases[oldhash][i].hashString()] = small; + this.aliases[newhash].push(this.aliases[oldhash][i]); + } + } + + this.add(small, this.sym('http://www.w3.org/2007/ont/link#uri'), big.uri) + + // If two things are equal, and one is requested, we should request the other. + if (this.sf) { + this.sf.nowKnownAs(big, small) + } } moveIndex(this.classActions); moveIndex(this.propertyActions); - tabulator.log.debug("Equate done. "+big+" to be known as "+small) + //$rdf.log.debug("Equate done. "+big+" to be known as "+small) return true; // true means the statement does not need to be put in }; // Return the symbol with canonical URI as smushed -RDFIndexedFormula.prototype.canon = function(term) { +$rdf.IndexedFormula.prototype.canon = function(term) { if (term == undefined) return term; var y = this.redirections[term.hashString()]; if (y == undefined) return term; @@ -248,7 +224,7 @@ RDFIndexedFormula.prototype.canon = function(term) { } // Compare by canonical URI as smushed -RDFIndexedFormula.prototype.sameThings = function(x, y) { +$rdf.IndexedFormula.prototype.sameThings = function(x, y) { if (x.sameTerm(y)) return true; var x1 = this.canon(x); // alert('x1='+x1); @@ -260,7 +236,7 @@ RDFIndexedFormula.prototype.sameThings = function(x, y) { } // A list of all the URIs by which this thing is known -RDFIndexedFormula.prototype.uris = function(term) { +$rdf.IndexedFormula.prototype.uris = function(term) { var cterm = this.canon(term) var terms = this.aliases[cterm.hashString()]; if (!cterm.uri) return [] @@ -277,27 +253,31 @@ RDFIndexedFormula.prototype.uris = function(term) { // function RDFMakeTerm(formula,val, canonicalize) { if (typeof val != 'object') { - if (typeof val == 'string') - return new RDFLiteral(val); + if (typeof val == 'string') + return new $rdf.Literal(val); if (typeof val == 'number') - return new RDFLiteral(val); // @@ differet types + return new $rdf.Literal(val); // @@ differet types if (typeof val == 'boolean') - return new RDFLiteral(val?"1":"0", undefined, - RDFSymbol.prototype.XSDboolean); - else if (typeof val == 'number') - return new RDFLiteral(''+val); // @@ datatypes - else if (typeof val == 'undefined') - return undefined; - else // @@ add converting of dates and numbers - throw "Can't make Term from " + val + " of type " + typeof val; + return new $rdf.Literal(val?"1":"0", undefined, + $rdf.Symbol.prototype.XSDboolean); + else if (typeof val == 'number') + return new $rdf.Literal(''+val); // @@ datatypes + else if (typeof val == 'undefined') + return undefined; + else // @@ add converting of dates and numbers + throw "Can't make Term from " + val + " of type " + typeof val; } return val; } -// add a triple to the store -RDFIndexedFormula.prototype.add = function(subj, pred, obj, why) { +// Add a triple to the store +// +// Returns the statement added +// (would it be better to return the original formula for chaining?) +// +$rdf.IndexedFormula.prototype.add = function(subj, pred, obj, why) { var actions, st; - if (why == undefined) why = this.fetcher ? this.fetcher.appNode: kb.sym("chrome:theSession"); //system generated + if (why == undefined) why = this.fetcher ? this.fetcher.appNode: this.sym("chrome:theSession"); //system generated //defined in source.js, is this OK with identity.js only user? subj = RDFMakeTerm(this, subj); pred = RDFMakeTerm(this, pred); @@ -307,23 +287,7 @@ RDFIndexedFormula.prototype.add = function(subj, pred, obj, why) { var hash = [ this.canon(subj).hashString(), this.canon(pred).hashString(), this.canon(obj).hashString(), this.canon(why).hashString()]; -/* // Removed TimBL 2007-01-06 - // Check we don't already know it -- esp when working with dbview - // db view has many documents with the same triple - a waste. - // but is we want to be able to edit documents, we must maintain the original - // triples from each one. We might occasionally want to mutiple provences too - // for a full Truth Management System. Maybe this should be run-time option. - st = this.anyStatementMatching(subj,pred,obj) // @@@@@@@ temp fix <====WATCH OUT! - It is general necessary to know when data has come from >1 place. - Maybe this should be a mode? -*/ - // This is wasting time and shouldn't happen at all - //st = this.anyStatementMatching(subj,pred,obj,why) // Avoid duplicates - //if (st != undefined) return; // already in store - - - - // tabulator.log.debug("\nActions for "+s+" "+p+" "+o+". size="+this.statements.length) + if (this.predicateCallback != undefined) this.predicateCallback(this, pred, why); @@ -338,24 +302,24 @@ RDFIndexedFormula.prototype.add = function(subj, pred, obj, why) { } //If we are tracking provenanance, every thing should be loaded into the store - //if (done) return new RDFStatement(subj, pred, obj, why); // Don't put it in the store + //if (done) return new Statement(subj, pred, obj, why); // Don't put it in the store // still return this statement for owl:sameAs input - var st = new RDFStatement(subj, pred, obj, why); + var st = new $rdf.Statement(subj, pred, obj, why); for (var i=0; i<4; i++) { var ix = this.index[i]; var h = hash[i]; if (ix[h] == undefined) ix[h] = []; - ix[h].push(st); // Set of things with this as subject + ix[h].push(st); // Set of things with this as subject, etc } - tabulator.log.debug("ADDING {"+subj+" "+pred+" "+obj+"} "+why); + //$rdf.log.debug("ADDING {"+subj+" "+pred+" "+obj+"} "+why); this.statements.push(st); return st; }; //add // Find out whether a given URI is used as symbol in the formula -RDFIndexedFormula.prototype.mentionsURI = function(uri) { +$rdf.IndexedFormula.prototype.mentionsURI = function(uri) { var hash = '<' + uri + '>'; return (!!this.subjectIndex[hash] || !!this.objectIndex[hash] || !!this.predicateIndex[hash]); @@ -363,15 +327,15 @@ RDFIndexedFormula.prototype.mentionsURI = function(uri) { // Find an unused id for a file being edited: return a symbol // (Note: Slow iff a lot of them -- could be O(log(k)) ) -RDFIndexedFormula.prototype.nextSymbol = function(doc) { +$rdf.IndexedFormula.prototype.nextSymbol = function(doc) { for(var i=0;;i++) { var uri = doc.uri + '#n' + i; - if (!this.mentionsURI(uri)) return kb.sym(uri); + if (!this.mentionsURI(uri)) return this.sym(uri); } } -RDFIndexedFormula.prototype.anyStatementMatching = function(subj,pred,obj,why) { +$rdf.IndexedFormula.prototype.anyStatementMatching = function(subj,pred,obj,why) { var x = this.statementsMatching(subj,pred,obj,why,true); if (!x || x == []) return undefined; return x[0]; @@ -380,8 +344,8 @@ RDFIndexedFormula.prototype.anyStatementMatching = function(subj,pred,obj,why) { // Return statements matching a pattern // ALL CONVENIENCE LOOKUP FUNCTIONS RELY ON THIS! -RDFIndexedFormula.prototype.statementsMatching = function(subj,pred,obj,why,justOne) { - tabulator.log.debug("Matching {"+subj+" "+pred+" "+obj+"}"); +$rdf.IndexedFormula.prototype.statementsMatching = function(subj,pred,obj,why,justOne) { + //$rdf.log.debug("Matching {"+subj+" "+pred+" "+obj+"}"); var pat = [ subj, pred, obj, why ]; var pattern = []; @@ -397,10 +361,16 @@ RDFIndexedFormula.prototype.statementsMatching = function(subj,pred,obj,why,just hash[p] = pattern[p].hashString(); } } - if (given.length == 0) return this.statements; // Easy + if (given.length == 0) { + return this.statements; + } if (given.length == 1) { // Easy too, we have an index for that var p = given[0]; var list = this.index[p][hash[p]]; + if(list && justOne) { + if(list.length>1) + list = list.slice(0,1); + } return list == undefined ? [] : list; } @@ -437,29 +407,33 @@ RDFIndexedFormula.prototype.statementsMatching = function(subj,pred,obj,why,just } if (st != null) results.push(st); } + + if(justOne) { + if(results.length>1) + results = results.slice(0,1); + } return results; }; // statementsMatching - /** remove a particular statement from the bank **/ -RDFIndexedFormula.prototype.remove = function (st) { - tabulator.log.debug("entering remove w/ st=" + st); +$rdf.IndexedFormula.prototype.remove = function (st) { + //$rdf.log.debug("entering remove w/ st=" + st); var term = [ st.subject, st.predicate, st.object, st.why]; for (var p=0; p<4; p++) { var c = this.canon(term[p]); var h = c.hashString(); if (this.index[p][h] == undefined) { - tabulator.log.warn ("Statement removal: no index '+p+': "+st); + //$rdf.log.warn ("Statement removal: no index '+p+': "+st); } else { - RDFArrayRemove(this.index[p][h], st); + $rdf.Util.RDFArrayRemove(this.index[p][h], st); } } - RDFArrayRemove(this.statements, st); + $rdf.Util.RDFArrayRemove(this.statements, st); }; //remove /** remove all statements matching args (within limit) **/ -RDFIndexedFormula.prototype.removeMany = function (subj, pred, obj, why, limit) { - tabulator.log.debug("entering removeMany w/ subj,pred,obj,why,limit = " + subj +", "+ pred+", " + obj+", " + why+", " + limit); +$rdf.IndexedFormula.prototype.removeMany = function (subj, pred, obj, why, limit) { + //$rdf.log.debug("entering removeMany w/ subj,pred,obj,why,limit = " + subj +", "+ pred+", " + obj+", " + why+", " + limit); var sts = this.statementsMatching (subj, pred, obj, why, false); //This is a subtle bug that occcured in updateCenter.js too. //The fact is, this.statementsMatching returns this.whyIndex instead of a copy of it @@ -468,56 +442,19 @@ RDFIndexedFormula.prototype.removeMany = function (subj, pred, obj, why, limit) var statements = []; for (var i=0;i other.classOrder) return +1 if (this.value < other.value) return -1 @@ -104,7 +62,7 @@ RDFLiteral.prototype.compareTerm = function(other) { return 0 } -RDFSymbol.prototype.compareTerm = function(other) { +$rdf.Symbol.prototype.compareTerm = function(other) { if (this.classOrder < other.classOrder) return -1 if (this.classOrder > other.classOrder) return +1 if (this.uri < other.uri) return -1 @@ -112,7 +70,7 @@ RDFSymbol.prototype.compareTerm = function(other) { return 0 } -RDFBlankNode.prototype.compareTerm = function(other) { +$rdf.BlankNode.prototype.compareTerm = function(other) { if (this.classOrder < other.classOrder) return -1 if (this.classOrder > other.classOrder) return +1 if (this.id < other.id) return -1 @@ -120,14 +78,14 @@ RDFBlankNode.prototype.compareTerm = function(other) { return 0 } -RDFCollection.prototype.compareTerm = RDFBlankNode.prototype.compareTerm +$rdf.Collection.prototype.compareTerm = $rdf.BlankNode.prototype.compareTerm // Convenience routines // Only one of s p o can be undefined, and w is optional. -RDFFormula.prototype.each = function(s,p,o,w) { +$rdf.Formula.prototype.each = function(s,p,o,w) { var results = [] - var st, sts = this.statementsMatching(s,p,o,w) + var st, sts = this.statementsMatching(s,p,o,w,false) var i, n=sts.length if (typeof s == 'undefined') { for (i=0; i 127) && (c < 2048)) { + utftext += String.fromCharCode((c >> 6) | 192); + utftext += String.fromCharCode((c & 63) | 128); + } + else { + utftext += String.fromCharCode((c >> 12) | 224); + utftext += String.fromCharCode(((c >> 6) & 63) | 128); + utftext += String.fromCharCode((c & 63) | 128); + } + + } + + return utftext; + }, + + // public method for url decoding + decode : function (utftext) { + var string = ""; + var i = 0; + + while ( i < utftext.length ) { + + var c = utftext.charCodeAt(i); + if (c < 128) { + string += String.fromCharCode(c); + i++; + } + else if((c > 191) && (c < 224)) { + string += String.fromCharCode(((c & 31) << 6) + | (utftext.charCodeAt(i+1) & 63)); + i += 2; + } + else { + string += String.fromCharCode(((c & 15) << 12) + | ((utftext.charCodeAt(i+1) & 63) << 6) + | (utftext.charCodeAt(i+2) & 63)); + i += 3; + } + } + return string; + } + +}// Things we need to define to make converted pythn code work in js +// environment of $rdf var RDFSink_forSomeSym = "http://www.w3.org/2000/10/swap/log#forSome"; var RDFSink_forAllSym = "http://www.w3.org/2000/10/swap/log#forAll"; @@ -7,27 +76,27 @@ var Logic_NS = "http://www.w3.org/2000/10/swap/log#"; // pyjs seems to reference runtime library which I didn't find -pyjslib_Tuple = function(theList) { return theList }; +var pyjslib_Tuple = function(theList) { return theList }; -pyjslib_List = function(theList) { return theList }; +var pyjslib_List = function(theList) { return theList }; -pyjslib_Dict = function(listOfPairs) { +var pyjslib_Dict = function(listOfPairs) { if (listOfPairs.length > 0) throw "missing.js: oops nnonempty dict not imp"; return []; } -pyjslib_len = function(s) { return s.length } +var pyjslib_len = function(s) { return s.length } -pyjslib_slice = function(str, i, j) { +var pyjslib_slice = function(str, i, j) { if (typeof str.slice == 'undefined') throw '@@ mising.js: No .slice function for '+str+' of type '+(typeof str) if ((typeof j == 'undefined') || (j ==null)) return str.slice(i); return str.slice(i, j) // @ exactly the same spec? } -StopIteration = Error('dummy error stop iteration') +var StopIteration = Error('dummy error stop iteration'); -pyjslib_Iterator = function(theList) { +var pyjslib_Iterator = function(theList) { this.last = 0; this.li = theList; this.next = function() { @@ -35,43 +104,54 @@ pyjslib_Iterator = function(theList) { return this.li[this.last++]; } return this; -} +}; -ord = function(str) { +var ord = function(str) { return str.charCodeAt(0) } -string_find = function(str, s) { +var string_find = function(str, s) { return str.indexOf(s) } -assertFudge = function(condition, desc) { +var assertFudge = function(condition, desc) { if (condition) return; if (desc) throw "python Assertion failed: "+desc; throw "(python) Assertion failed."; } -stringFromCharCode = function(uesc) { +var stringFromCharCode = function(uesc) { return String.fromCharCode(uesc); } +String.prototype.encode = function(encoding) { + if (encoding != 'utf-8') throw "UTF8_converter: can only do utf-8" + return Utf8.encode(this); +} +String.prototype.decode = function(encoding) { + if (encoding != 'utf-8') throw "UTF8_converter: can only do utf-8" + //return Utf8.decode(this); + return this; +} -uripath_join = function(base, given) { - return Util.uri.join(given, base) // sad but true + + +var uripath_join = function(base, given) { + return $rdf.Util.uri.join(given, base) // sad but true } var becauseSubexpression = null; // No reason needed var diag_tracking = 0; var diag_chatty_flag = 0; -diag_progress = function(str) { tabulator.log.debug(str); } +var diag_progress = function(str) { /*$rdf.log.debug(str);*/ } // why_BecauseOfData = function(doc, reason) { return doc }; -RDF_type_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; -DAML_sameAs_URI = "http://www.w3.org/2002/07/owl#sameAs"; +var RDF_type_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; +var DAML_sameAs_URI = "http://www.w3.org/2002/07/owl#sameAs"; /* function SyntaxError(details) { @@ -235,7 +315,7 @@ __SinkParser.prototype.feed = function(octets) { So if there is more data to feed to the parser, it should be straightforward to recover.*/ - var str = octets; + var str = octets.decode("utf-8"); var i = 0; while ((i >= 0)) { var j = this.skipSpace(str, i); @@ -267,18 +347,17 @@ __SinkParser.prototype.tok = function(tok, str, i) { /* Check for keyword. Space must have been stripped on entry and we must not be at end of file.*/ - var whitespace = "\t\n\v\f\r "; if ((pyjslib_slice(str, i, ( i + 1 ) ) == "@")) { var i = ( i + 1 ) ; } else { - if ((this.keywords.indexOf(tok) < 0)) { + if (($rdf.Util.ArrayIndexOf(this.keywords,tok) < 0)) { return -1; } } var k = ( i + pyjslib_len(tok) ) ; - if ((pyjslib_slice(str, i, k) == tok) && (_notQNameChars.indexOf(str[k]) >= 0)) { + if ((pyjslib_slice(str, i, k) == tok) && (_notQNameChars.indexOf(str.charAt(k)) >= 0)) { return k; } else { @@ -320,7 +399,7 @@ __SinkParser.prototype.directive = function(str, i) { var x = __x.next(); - if ((this._variables.indexOf(x) < 0) || (this._parentVariables.indexOf(x) >= 0)) { + if ($rdf.Util.ArrayIndexOf(this._variables,x) < 0 || ($rdf.Util.ArrayIndexOf(this._parentVariables,x) >= 0)) { this._variables[x] = ( this._context.newUniversal(x)); } @@ -862,7 +941,7 @@ __SinkParser.prototype.commaSeparatedList = function(str, j, res, ofUris) { throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found expecting comma sep list"); return i; } - if ((str[i] == ".")) { + if ((str.charAt(i) == ".")) { return j; } if (ofUris) { @@ -965,7 +1044,7 @@ __SinkParser.prototype.uri_ref2 = function(str, i, res) { } } var symb = this._store.sym( ( ns + ln ) ); - if ((this._variables.indexOf(symb) >= 0)) { + if (($rdf.Util.ArrayIndexOf(this._variables, symb) >= 0)) { res.push(this._variables[symb]); } else { @@ -977,7 +1056,7 @@ __SinkParser.prototype.uri_ref2 = function(str, i, res) { if ((i < 0)) { return -1; } - if ((str[i] == "?")) { + if ((str.charAt(i) == "?")) { var v = new pyjslib_List([]); var j = this.variable(str, i, v); if ((j > 0)) { @@ -986,11 +1065,11 @@ __SinkParser.prototype.uri_ref2 = function(str, i, res) { } return -1; } - else if ((str[i] == "<")) { + else if ((str.charAt(i) == "<")) { var i = ( i + 1 ) ; var st = i; while ((i < pyjslib_len(str))) { - if ((str[i] == ">")) { + if ((str.charAt(i) == ">")) { var uref = pyjslib_slice(str, st, i); if (this._baseURI) { var uref = uripath_join(this._baseURI, uref); @@ -1002,7 +1081,7 @@ __SinkParser.prototype.uri_ref2 = function(str, i, res) { var uref = ( uref + "#" ) ; } var symb = this._store.sym(uref); - if ((this._variables.indexOf(symb) >= 0)) { + if (($rdf.Util.ArrayIndexOf(this._variables,symb) >= 0)) { res.push(this._variables[symb]); } else { @@ -1020,7 +1099,7 @@ __SinkParser.prototype.uri_ref2 = function(str, i, res) { if ((j < 0)) { return -1; } - if ((this.keywords.indexOf(v[0]) >= 0)) { + if (($rdf.Util.ArrayIndexOf(this.keywords, v[0]) >= 0)) { throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Keyword \"" + v[0] ) + "\" not allowed here." ) ); } res.push(this._store.sym( ( this._bindings[""] + v[0] ) )); @@ -1034,28 +1113,24 @@ __SinkParser.prototype.skipSpace = function(str, i) { /* Skip white space, newlines and comments. return -1 if EOF, else position of first non-ws character*/ - - while (1) { - eol.lastIndex = 0; - var m = eol.exec(str.slice(i)); - if ((m == null)) { - break; + var tmp = str; + var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000'; + for (var j = (i ? i : 0); j < str.length; j++) { + if (whitespace.indexOf(str.charAt(j)) === -1) { + if( str.charAt(j)==='#' ) { + str = str.slice(i).replace(/^[^\n]*\n/,""); + i=0; + j=-1; + } else { + break; + } } - this.lines = ( this.lines + 1 ) ; - i += eol.lastIndex; - this.previousLine = this.startOfLine; - this.startOfLine = i; - tabulator.log.debug( ( ( ( "N3 line " + this.lines ) + " " ) + str.slice(this.previousLine, this.startOfLine) ) ); } - ws.lastIndex = 0; - var m = ws.exec(str.slice(i)); - if ((m != null) && (m[0] != "")) { - i += ws.lastIndex; - } - if ((i == pyjslib_len(str))) { + val = (tmp.length - str.length) + j; + if( val === tmp.length ) { return -1; } - return i; + return val; }; __SinkParser.prototype.variable = function(str, i, res) { /* @@ -1071,11 +1146,11 @@ __SinkParser.prototype.variable = function(str, i, res) { } var j = ( j + 1 ) ; var i = j; - if (("0123456789-".indexOf(str[j]) >= 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, ( ( "Varible name can't start with '" + str[j] ) + "s'" ) ); + if (("0123456789-".indexOf(str.charAt(j)) >= 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, ( ( "Varible name can't start with '" + str.charAt(j) ) + "s'" ) ); return -1; } - while ((i < pyjslib_len(str)) && (_notNameChars.indexOf(str[i]) < 0)) { + while ((i < pyjslib_len(str)) && (_notNameChars.indexOf(str.charAt(i)) < 0)) { var i = ( i + 1 ) ; } if ((this._parentContext == null)) { @@ -1093,7 +1168,7 @@ __SinkParser.prototype.bareWord = function(str, i, res) { if ((j < 0)) { return -1; } - var ch = str[j]; + var ch = str.charAt(j); if (("0123456789-".indexOf(ch) >= 0)) { return -1; } @@ -1101,7 +1176,7 @@ __SinkParser.prototype.bareWord = function(str, i, res) { return -1; } var i = j; - while ((i < pyjslib_len(str)) && (_notNameChars.indexOf(str[i]) < 0)) { + while ((i < pyjslib_len(str)) && (_notNameChars.indexOf(str.charAt(i)) < 0)) { var i = ( i + 1 ) ; } res.push(pyjslib_slice(str, j, i)); @@ -1119,7 +1194,7 @@ __SinkParser.prototype.qname = function(str, i, res) { if ((i < 0)) { return -1; } - var c = str[i]; + var c = str.charAt(i); if (("0123456789-+".indexOf(c) >= 0)) { return -1; } @@ -1127,7 +1202,7 @@ __SinkParser.prototype.qname = function(str, i, res) { var ln = c; var i = ( i + 1 ) ; while ((i < pyjslib_len(str))) { - var c = str[i]; + var c = str.charAt(i); if ((_notNameChars.indexOf(c) < 0)) { var ln = ( ln + c ) ; var i = ( i + 1 ) ; @@ -1140,12 +1215,12 @@ __SinkParser.prototype.qname = function(str, i, res) { else { var ln = ""; } - if ((i < pyjslib_len(str)) && (str[i] == ":")) { + if ((i < pyjslib_len(str)) && (str.charAt(i) == ":")) { var pfx = ln; var i = ( i + 1 ) ; var ln = ""; while ((i < pyjslib_len(str))) { - var c = str[i]; + var c = str.charAt(i); if ((_notNameChars.indexOf(c) < 0)) { var ln = ( ln + c ) ; var i = ( i + 1 ) ; @@ -1158,7 +1233,7 @@ __SinkParser.prototype.qname = function(str, i, res) { return i; } else { - if (ln && this.keywordsSet && (this.keywords.indexOf(ln) < 0)) { + if (ln && this.keywordsSet && ($rdf.Util.ArrayIndexOf(this.keywords, ln) < 0)) { res.push(new pyjslib_Tuple(["", ln])); return i; } @@ -1178,7 +1253,7 @@ __SinkParser.prototype.object = function(str, i, res) { else { var i = j; } - if ((str[i] == "\"")) { + if ((str.charAt(i) == "\"")) { if ((pyjslib_slice(str, i, ( i + 3 ) ) == "\"\"\"")) { var delim = "\"\"\""; } @@ -1211,7 +1286,7 @@ __SinkParser.prototype.nodeOrLiteral = function(str, i, res) { else { var i = j; } - var ch = str[i]; + var ch = str.charAt(i); if (("-+0987654321".indexOf(ch) >= 0)) { number_syntax.lastIndex = 0; var m = number_syntax.exec(str.slice(i)); @@ -1221,17 +1296,17 @@ __SinkParser.prototype.nodeOrLiteral = function(str, i, res) { var j = ( i + number_syntax.lastIndex ) ; var val = pyjslib_slice(str, i, j); if ((val.indexOf("e") >= 0)) { - res.push(this._store.literal(parseFloat(val), undefined, kb.sym(FLOAT_DATATYPE))); + res.push(this._store.literal(parseFloat(val), undefined, this._store.sym(FLOAT_DATATYPE))); } else if ((pyjslib_slice(str, i, j).indexOf(".") >= 0)) { - res.push(this._store.literal(parseFloat(val), undefined, kb.sym(DECIMAL_DATATYPE))); + res.push(this._store.literal(parseFloat(val), undefined, this._store.sym(DECIMAL_DATATYPE))); } else { - res.push(this._store.literal(parseInt(val), undefined, kb.sym(INTEGER_DATATYPE))); + res.push(this._store.literal(parseInt(val), undefined, this._store.sym(INTEGER_DATATYPE))); } return j; } - if ((str[i] == "\"")) { + if ((str.charAt(i) == "\"")) { if ((pyjslib_slice(str, i, ( i + 3 ) ) == "\"\"\"")) { var delim = "\"\"\""; } @@ -1283,7 +1358,7 @@ __SinkParser.prototype.strconst = function(str, i, delim) { if ((pyjslib_slice(str, j, i) == delim)) { return new pyjslib_Tuple([i, ustr]); } - if ((str[j] == "\"")) { + if ((str.charAt(j) == "\"")) { var ustr = ( ustr + "\"" ) ; var j = ( j + 1 ) ; continue; @@ -1295,7 +1370,7 @@ __SinkParser.prototype.strconst = function(str, i, delim) { } var i = ( ( j + interesting.lastIndex ) - 1 ) ; var ustr = ( ustr + pyjslib_slice(str, j, i) ) ; - var ch = str[i]; + var ch = str.charAt(i); if ((ch == "\"")) { var j = i; continue; @@ -1322,7 +1397,7 @@ __SinkParser.prototype.strconst = function(str, i, delim) { } var k = string_find("abfrtvn\\\"", ch); if ((k >= 0)) { - var uch = "\a\b\f\r\t\v\n\\\""[k]; + var uch = "\a\b\f\r\t\v\n\\\"".charAt(k); var ustr = ( ustr + uch ) ; var j = ( j + 1 ) ; } @@ -1387,7 +1462,36 @@ __SinkParser.prototype.UEscape = function(str, i, startline) { var uch = stringFromCharCode( ( ( "0x" + pyjslib_slice(value, 2, 10) ) - 0 ) ); return new pyjslib_Tuple([j, uch]); }; - +function OLD_BadSyntax(uri, lines, str, i, why) { + return new __OLD_BadSyntax(uri, lines, str, i, why); +} +function __OLD_BadSyntax(uri, lines, str, i, why) { + this._str = str.encode("utf-8"); + this._str = str; + this._i = i; + this._why = why; + this.lines = lines; + this._uri = uri; +} +__OLD_BadSyntax.prototype.toString = function() { + var str = this._str; + var i = this._i; + var st = 0; + if ((i > 60)) { + var pre = "..."; + var st = ( i - 60 ) ; + } + else { + var pre = ""; + } + if (( ( pyjslib_len(str) - i ) > 60)) { + var post = "..."; + } + else { + var post = ""; + } + return "Line %i of <%s>: Bad syntax (%s) at ^ in:\n\"%s%s^%s%s\"" % new pyjslib_Tuple([ ( this.lines + 1 ) , this._uri, this._why, pre, pyjslib_slice(str, st, i), pyjslib_slice(str, i, ( i + 60 ) ), post]); +}; function BadSyntax(uri, lines, str, i, why) { return ( ( ( ( ( ( ( ( "Line " + ( lines + 1 ) ) + " of <" ) + uri ) + ">: Bad syntax: " ) + why ) + "\nat: \"" ) + pyjslib_slice(str, i, ( i + 30 ) ) ) + "\"" ) ; } @@ -1420,4 +1524,6 @@ function stripCR(str) { function dummyWrite(x) { } +return SinkParser; +}(); diff --git a/chrome/content/zotero/xpcom/rdf/rdfparser.js b/chrome/content/zotero/xpcom/rdf/rdfparser.js index 7a28e7f32e..8ab32a545e 100644 --- a/chrome/content/zotero/xpcom/rdf/rdfparser.js +++ b/chrome/content/zotero/xpcom/rdf/rdfparser.js @@ -61,7 +61,9 @@ * @constructor * @param {RDFStore} store An RDFStore object */ -function RDFParser(store) { +$rdf.RDFParser = function (store) { + var RDFParser = {}; + /** Standard namespaces that we know how to handle @final * @member RDFParser */ @@ -111,7 +113,7 @@ function RDFParser(store) { /** Add a symbol of a certain type to the this frame */ 'addSymbol': function (type, uri) { - uri = Util.uri.join(uri, this['base']) + uri = $rdf.Util.uri.join(uri, this['base']) this['node'] = this['store']['sym'](uri) this['nodeType'] = type }, @@ -129,7 +131,7 @@ function RDFParser(store) { } if (this['parent']['rdfid'] != null) { // reify var triple = this['store']['sym']( - Util.uri.join("#"+this['parent']['rdfid'], + $rdf.Util.uri.join("#"+this['parent']['rdfid'], this['base'])) this['store']['add'](triple, this['store']['sym']( @@ -236,6 +238,29 @@ function RDFParser(store) { } } + //from the OpenLayers source .. needed to get around IE problems. + this['getAttributeNodeNS'] = function(node, uri, name) { + var attributeNode = null; + if(node.getAttributeNodeNS) { + attributeNode = node.getAttributeNodeNS(uri, name); + } else { + var attributes = node.attributes; + var potentialNode, fullName; + for(var i=0; i=0) + result = result + el['nodeName'].split(":")[1]; + else + result = result + el['nodeName']; + } + return result; } var dig = true // if we'll dig down in the tree on the next iter @@ -325,9 +360,9 @@ function RDFParser(store) { if (!frame['parent'] || !frame['parent']['nodeType'] || frame['parent']['nodeType'] == frame['ARC']) { // we need a node - var about =dom['getAttributeNodeNS']( + var about =this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'],"about") - var rdfid =dom['getAttributeNodeNS']( + var rdfid =this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'],"ID") if (about && rdfid) { throw new Error("RDFParser: " + dom['nodeName'] @@ -341,7 +376,7 @@ function RDFParser(store) { dom['removeAttributeNode'](rdfid) } else if (about == null && rdfid == null) { - var bnid = dom['getAttributeNodeNS']( + var bnid = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'],"nodeID") if (bnid) { frame['addBNode'](bnid['nodeValue']) @@ -354,7 +389,7 @@ function RDFParser(store) { } // Typed nodes - var rdftype = dom['getAttributeNodeNS']( + var rdftype = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'],"type") if (RDFParser['ns']['RDF']+"Description" != elementURI(dom)) { @@ -365,7 +400,7 @@ function RDFParser(store) { this['store']['sym']( RDFParser['ns']['RDF']+"type"), this['store']['sym']( - Util.uri.join( + $rdf.Util.uri.join( rdftype['nodeValue'], frame['base'])), this['why']) @@ -390,7 +425,7 @@ function RDFParser(store) { // save the arc's rdf:ID if it has one if (this['reify']) { - var rdfid = dom['getAttributeNodeNS']( + var rdfid = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'],"ID") if (rdfid) { frame['rdfid'] = rdfid['nodeValue'] @@ -398,9 +433,9 @@ function RDFParser(store) { } } - var parsetype = dom['getAttributeNodeNS']( + var parsetype = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'],"parseType") - var datatype = dom['getAttributeNodeNS']( + var datatype = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'],"datatype") if (datatype) { frame['datatype'] = datatype['nodeValue'] @@ -432,9 +467,9 @@ function RDFParser(store) { } if (attrs['length'] != 0) { - var resource = dom['getAttributeNodeNS']( + var resource = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'],"resource") - var bnid = dom['getAttributeNodeNS']( + var bnid = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'],"nodeID") frame = this['buildFrame'](frame) @@ -549,7 +584,7 @@ function RDFParser(store) { if (attrs[x].name.slice(0,6)=='xmlns:') { var uri = attrs[x].nodeValue; // alert('base for namespac attr:'+this.base); - if (this.base) uri = Util.uri.join(uri, this.base); + if (this.base) uri = $rdf.Util.uri.join(uri, this.base); this.store.setPrefixForURI(attrs[x].name.slice(6), uri); } @@ -559,4 +594,4 @@ function RDFParser(store) { } return frame } -} \ No newline at end of file +} diff --git a/chrome/content/zotero/xpcom/rdf/serialize.js b/chrome/content/zotero/xpcom/rdf/serialize.js index ab0b4648dc..3e724a981d 100644 --- a/chrome/content/zotero/xpcom/rdf/serialize.js +++ b/chrome/content/zotero/xpcom/rdf/serialize.js @@ -7,7 +7,11 @@ ** in XML (from mhausenblas) */ -__Serializer = function(){ +// @@@ Check the whole toStr thing tosee whetehr it still makes sense -- tbl +// +$rdf.Serializer = function() { + +var __Serializer = function( store ){ this.flags = ""; this.base = null; this.prefixes = []; @@ -15,11 +19,12 @@ __Serializer = function(){ this.prefixchars = "abcdefghijklmnopqustuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; this.incoming = null; // Array not calculated yet this.formulas = []; // remebering original formulae from hashes + this.store = store; /* pass */ } -Serializer = function() {return new __Serializer()}; +var Serializer = function( store ) {return new __Serializer( store )}; __Serializer.prototype.setBase = function(base) { this.base = base }; @@ -42,7 +47,7 @@ __Serializer.prototype.fromStr = function(s) { if (!x) alert('No formula object for '+s) return x; } - return kb.fromNT(s); + return this.store.fromNT(s); }; @@ -75,11 +80,14 @@ __Serializer.prototype.makeUpPrefix = function(uri) { function canUse(pp) { if (namespaces[pp]) return false; // already used + sz.prefixes[uri] = pp; pok = pp; return true } - for (var ns in sz.prefixes) namespaces[sz.prefixes[ns]] = ns; // reverse index + for (var ns in sz.prefixes) { + namespaces[sz.prefixes[ns]] = ns; // reverse index + } if ('#/'.indexOf(p[p.length-1]) >= 0) p = p.slice(0, -1); var slash = p.lastIndexOf('/'); if (slash >= 0) p = p.slice(slash+1); @@ -97,62 +105,152 @@ __Serializer.prototype.makeUpPrefix = function(uri) { } -/* The scan is to find out which nodes will have to be the roots of trees -** in the serialized form. This will be any symbols, and any bnodes -** which hve more or less than one incoming arc, and any bnodes which have -** one incoming arc but it is an uninterrupted loop of such nodes back to itself. -** This should be kept linear time with repect to the number of statements. -** Note it does not use any indexing. -*/ - // Todo: // - Sort the statements by subject, pred, object // - do stuff about the docu first and then (or first) about its primary topic. __Serializer.prototype.rootSubjects = function(sts) { - var incoming = {}; - var subjects = {}; + var incoming = []; + var subjects = []; var sz = this; + var allBnodes = {}; +/* This scan is to find out which nodes will have to be the roots of trees +** in the serialized form. This will be any symbols, and any bnodes +** which hve more or less than one incoming arc, and any bnodes which have +** one incoming arc but it is an uninterrupted loop of such nodes back to itself. +** This should be kept linear time with repect to the number of statements. +** Note it does not use any indexing of the store. +*/ + + + tabulator.log.debug('serialize.js Find bnodes with only one incoming arc\n') for (var i = 0; i= 0) uri = backslashUify(uri); else uri = hexify(uri); @@ -489,7 +586,6 @@ function backslashUify(str) { __Serializer.prototype.statementsToXML = function(sts) { var indent = 4; var width = 80; - // var subjects = null; // set later var sz = this; var namespaceCounts = []; // which have been used @@ -552,137 +648,90 @@ __Serializer.prototype.statementsToXML = function(sts) { function statementListToXMLTree(statements) { sz.suggestPrefix('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); - var res = []; - var pair = sz.rootSubjects(statements); - var roots = pair[0]; - var subjects = pair[1]; + var stats = sz.rootSubjects(statements); + var roots = stats.roots; results = [] for (var i=0; i bb[0]) { - return 1; - } else if (aa[0] < bb[0]) { - return -1; - } else { - if ("undefined" !== typeof aa[1] && "undefined" !== typeof bb[1]) { - if (parseInt(aa[1], 10) > parseInt(bb[1], 10)) { - return 1; - } else if (parseInt(aa[1], 10) < parseInt(bb[1], 10)) { - return -1; - } - } - } - return 0; - }); - for (var i=0; i', - subjectXMLTree(st.object, subjects, true), - '']); - } else { - results = results.concat(['<'+qname(st.predicate)+' rdf:nodeID="' - +st.object.toNT().slice(2)+'"/>']); - } - break; - case 'symbol': - results = results.concat(['<'+qname(st.predicate)+' rdf:resource="' - + relURI(st.object)+'"/>']); - break; - case 'literal': - results = results.concat(['<'+qname(st.predicate) - + (st.object.dt ? ' rdf:datatype="'+escapeForXML(st.object.dt.uri)+'"' : '') - + (st.object.lang ? ' xml:lang="'+st.object.lang+'"' : '') - + '>' + escapeForXML(st.object.value) - + '']); - break; - case 'collection': - results = results.concat(['<'+qname(st.predicate)+' rdf:parseType="Collection">', - collectionXMLTree(st.object, subjects), - '']); - break; - default: - throw "Can't serialize object of type "+st.object.termType +" into XML"; - - } // switch - } - } - - var tag = type ? qname(type) : 'rdf:Description'; - - attrs = ''; + function subjectXMLTree(subject, stats) { + var start if (subject.termType == 'bnode') { - if(!referenced || sz.incoming[subject].length != 1) { // not an anonymous bnode - attrs = ' rdf:nodeID="'+subject.toNT().slice(2)+'"'; + if (!stats.incoming[subject]) { // anonymous bnode + var start = ''; + } else { + var start = ''; } } else { - attrs = ' rdf:about="'+ relURI(subject)+'"'; + var start = ''; } - return [ '<' + tag + attrs + '>' ].concat([results]).concat([""]); + return [ start ].concat( + [propertyXMLTree(subject, stats)]).concat([""]); } - - function collectionXMLTree(subject, subjects) { + function collectionXMLTree(subject, stats) { res = [] for (var i=0; i< subject.elements.length; i++) { - res.push(subjectXMLTree(subject.elements[i], subjects)); + res.push(subjectXMLTree(subject.elements[i], stats)); } return res; + } + + // The property tree for a single subject or anonymos node + function propertyXMLTree(subject, stats) { + var results = [] + var sts = stats.subjects[sz.toStr(subject)]; // relevant statements + if (sts == undefined) return results; // No relevant statements + sts.sort(); + for (var i=0; i', + '']); + } else { + results = results.concat(['<'+qname(st.predicate)+' rdf:parseType="Resource">', + propertyXMLTree(st.object, stats), + '']); + } + break; + case 'symbol': + results = results.concat(['<'+qname(st.predicate)+' rdf:resource="' + + relURI(st.object)+'"/>']); + break; + case 'literal': + results = results.concat(['<'+qname(st.predicate) + + (st.object.datatype ? ' rdf:datatype="'+escapeForXML(st.object.datatype.uri)+'"' : '') + + (st.object.lang ? ' xml:lang="'+st.object.lang+'"' : '') + + '>' + escapeForXML(st.object.value) + + '']); + break; + case 'collection': + results = results.concat(['<'+qname(st.predicate)+' rdf:parseType="Collection">', + collectionXMLTree(st.object, stats), + '']); + break; + default: + throw "Can't serialize object of type "+st.object.termType +" into XML"; + + } // switch + } + return results; } function qname(term) { @@ -730,3 +779,7 @@ __Serializer.prototype.statementsToXML = function(sts) { } // End @@ body +return Serializer; + +}(); + diff --git a/chrome/content/zotero/xpcom/rdf/term.js b/chrome/content/zotero/xpcom/rdf/term.js index 0764833daa..cced406dda 100644 --- a/chrome/content/zotero/xpcom/rdf/term.js +++ b/chrome/content/zotero/xpcom/rdf/term.js @@ -8,224 +8,245 @@ // W3C open source licence 2005. // -RDFTracking = 0 // Are we requiring reasons for statements? - -//takes in an object and makes it an object if it's a literal -function makeTerm(val) { - // tabulator.log.debug("Making term from " + val) - if (typeof val == 'object') return val; - if (typeof val == 'string') return new RDFLiteral(val); - if (typeof val == 'number') return new RDFLiteral(val); // @@ differet types - if (typeof val == 'boolean') return new RDFLiteral(val?"1":"0", undefined, - RDFSymbol.prototype.XSDboolean); - if (typeof val == 'undefined') return undefined; - alert("Can't make term from " + val + " of type " + typeof val); -} - - // Symbol -function RDFEmpty() { +$rdf.Empty = function() { return this; -} -RDFEmpty.prototype.termType = 'empty' -RDFEmpty.prototype.toString = function () { return "()" } -RDFEmpty.prototype.toNT = function () { return "@@" } +}; -function RDFSymbol_toNT(x) { - return ("<" + x.uri + ">") +$rdf.Empty.prototype.termType = 'empty'; +$rdf.Empty.prototype.toString = function () { return "()" }; +$rdf.Empty.prototype.toNT = $rdf.Empty.prototype.toString; + +$rdf.Symbol = function( uri ) { + this.uri = uri; + this.value = uri; // -- why? -tim + return this; } -function toNT() { - return RDFSymbol_toNT(this) -} - -function RDFSymbol(uri) { - this.uri = uri - return this -} - -RDFSymbol.prototype.termType = 'symbol' -RDFSymbol.prototype.toString = toNT -RDFSymbol.prototype.toNT = toNT - -// Some precalculaued symbols - -RDFSymbol.prototype.XSDboolean = new RDFSymbol('http://www.w3.org/2001/XMLSchema#boolean'); -RDFSymbol.prototype.integer = new RDFSymbol('http://www.w3.org/2001/XMLSchema#integer'); +$rdf.Symbol.prototype.termType = 'symbol'; +$rdf.Symbol.prototype.toString = function () { return ("<" + this.uri + ">"); }; +$rdf.Symbol.prototype.toNT = $rdf.Symbol.prototype.toString; +// Some precalculated symbols +$rdf.Symbol.prototype.XSDboolean = new $rdf.Symbol('http://www.w3.org/2001/XMLSchema#boolean'); +$rdf.Symbol.prototype.XSDdecimal = new $rdf.Symbol('http://www.w3.org/2001/XMLSchema#decimal'); +$rdf.Symbol.prototype.XSDfloat = new $rdf.Symbol('http://www.w3.org/2001/XMLSchema#float'); +$rdf.Symbol.prototype.XSDinteger = new $rdf.Symbol('http://www.w3.org/2001/XMLSchema#integer'); +$rdf.Symbol.prototype.XSDdateTime = new $rdf.Symbol('http://www.w3.org/2001/XMLSchema#dateTime'); +$rdf.Symbol.prototype.integer = new $rdf.Symbol('http://www.w3.org/2001/XMLSchema#integer'); // Used? // Blank Node -var RDFNextId = 0; // Gobal genid -RDFGenidPrefix = "genid:" -NTAnonymousNodePrefix = "_:n" +if (typeof $rdf.NextId != 'undefined') { + $rdf.log.error('Attempt to re-zero existing blank node id counter at '+$rdf.NextId); +} else { + $rdf.NextId = 0; // Global genid +} +$rdf.NTAnonymousNodePrefix = "_:n"; -function RDFBlankNode(id) { +$rdf.BlankNode = function ( id ) { /*if (id) this.id = id; else*/ - this.id = RDFNextId++ + this.id = $rdf.NextId++ + this.value = id ? id : this.id.toString(); return this -} +}; -RDFBlankNode.prototype.termType = 'bnode' - -RDFBlankNode.prototype.toNT = function() { - return NTAnonymousNodePrefix + this.id -} -RDFBlankNode.prototype.toString = RDFBlankNode.prototype.toNT +$rdf.BlankNode.prototype.termType = 'bnode'; +$rdf.BlankNode.prototype.toNT = function() { + return $rdf.NTAnonymousNodePrefix + this.id +}; +$rdf.BlankNode.prototype.toString = $rdf.BlankNode.prototype.toNT; // Literal -function RDFLiteral(value, lang, datatype) { +$rdf.Literal = function (value, lang, datatype) { this.value = value - this.lang=lang; // string - this.datatype=datatype; // term - this.toString = RDFLiteralToString - this.toNT = RDFLiteral_toNT - return this + if (lang == "" || lang == null) this.lang = undefined; + else this.lang = lang; // string + if (datatype == null) this.datatype = undefined; + else this.datatype = datatype; // term + return this; } -RDFLiteral.prototype.termType = 'literal' - -function RDFLiteral_toNT() { +$rdf.Literal.prototype.termType = 'literal' +$rdf.Literal.prototype.toString = function() { + return ''+this.value; +}; +$rdf.Literal.prototype.toNT = function() { var str = this.value if (typeof str != 'string') { if (typeof str == 'number') return ''+str; throw Error("Value of RDF literal is not string: "+str) } - str = str.replace(/\\/g, '\\\\'); // escape - str = str.replace(/\"/g, '\\"'); - str = '"' + str + '"' //' + str = str.replace(/\\/g, '\\\\'); // escape backslashes + str = str.replace(/\"/g, '\\"'); // escape quotes + str = str.replace(/\n/g, '\\n'); // escape newlines + str = '"' + str + '"' //'; if (this.datatype){ - str = str + '^^' + this.datatype//.toNT() + str = str + '^^' + this.datatype.toNT() } if (this.lang) { - str = str + "@" + this.lang + str = str + "@" + this.lang; } - return str -} + return str; +}; -function RDFLiteralToString() { - return ''+this.value -} - -RDFLiteral.prototype.toString = RDFLiteralToString -RDFLiteral.prototype.toNT = RDFLiteral_toNT +$rdf.Collection = function() { + this.id = $rdf.NextId++; // Why need an id? For hashstring. + this.elements = []; + this.closed = false; +}; -function RDFCollection() { - this.id = RDFNextId++ - this.elements = [] - this.closed = false -} +$rdf.Collection.prototype.termType = 'collection'; -RDFCollection.prototype.termType = 'collection' +$rdf.Collection.prototype.toNT = function() { + return $rdf.NTAnonymousNodePrefix + this.id +}; -RDFCollection.prototype.toNT = function() { - return NTAnonymousNodePrefix + this.id -} -RDFCollection.prototype.toString = RDFCollection.prototype.toNT +$rdf.Collection.prototype.toString = function() { + var str='('; + for (var i=0; i=0) dt = $rdf.Symbol.prototype.XSDfloat; + else if ((''+val).indexOf('.')>=0) dt = $rdf.Symbol.prototype.XSDdecimal; + else dt = $rdf.Symbol.prototype.XSDinteger; + return new $rdf.Literal(val, undefined, dt); + } + if (typeof val == 'boolean') return new $rdf.Literal(val?"1":"0", undefined, + $rdf.Symbol.prototype.XSDboolean); + if (typeof val == 'undefined') return undefined; + throw ("Can't make term from " + val + " of type " + typeof val); +} + // Statement // // This is a triple with an optional reason. // // The reason can point to provenece or inference // -function RDFStatement_toNT() { - return (this.subject.toNT() + " " - + this.predicate.toNT() + " " - + this.object.toNT() +" .") -} -function RDFStatement(subject, predicate, object, why) { - this.subject = makeTerm(subject) - this.predicate = makeTerm(predicate) - this.object = makeTerm(object) +$rdf.Statement = function(subject, predicate, object, why) { + this.subject = $rdf.term(subject) + this.predicate = $rdf.term(predicate) + this.object = $rdf.term(object) if (typeof why !='undefined') { - this.why = why - } else if (RDFTracking) { - tabulator.log.debug("WARNING: No reason on "+subject+" "+predicate+" "+object) + this.why = why; } - return this + return this; } -RDFStatement.prototype.toNT = RDFStatement_toNT -RDFStatement.prototype.toString = RDFStatement_toNT - +$rdf.st= function(subject, predicate, object, why) { + return new $rdf.Statement(subject, predicate, object, why); +}; + +$rdf.Statement.prototype.toNT = function() { + return (this.subject.toNT() + " " + + this.predicate.toNT() + " " + + this.object.toNT() +" ."); +}; + +$rdf.Statement.prototype.toString = $rdf.Statement.prototype.toNT; // Formula // // Set of statements. -function RDFFormula() { +$rdf.Formula = function() { this.statements = [] this.constraints = [] this.initBindings = [] this.optional = [] - this.superFormula = null; - return this -} + return this; +}; -function RDFFormula_toNT() { - // throw 'Who called me?'; + +$rdf.Formula.prototype.termType = 'formula'; +$rdf.Formula.prototype.toNT = function() { return "{" + this.statements.join('\n') + "}" -} +}; +$rdf.Formula.prototype.toString = $rdf.Formula.prototype.toNT; -//RDFQueryFormula.prototype = new RDFFormula() -//RDFQueryFormula.termType = 'queryFormula' -RDFFormula.prototype.termType = 'formula' -RDFFormula.prototype.toNT = RDFFormula_toNT -RDFFormula.prototype.toString = RDFFormula_toNT - -RDFFormula.prototype.add = function(subj, pred, obj, why) { - this.statements.push(new RDFStatement(subj, pred, obj, why)) +$rdf.Formula.prototype.add = function(subj, pred, obj, why) { + this.statements.push(new $rdf.Statement(subj, pred, obj, why)) } // Convenience methods on a formula allow the creation of new RDF terms: -RDFFormula.prototype.sym = function(uri,name) { +$rdf.Formula.prototype.sym = function(uri,name) { if (name != null) { - if (!tabulator.ns[uri]) throw 'The prefix "'+uri+'" is not set in the API'; - uri = tabulator.ns[uri] + name + throw "This feature (kb.sym with 2 args) is removed. Do not assume prefix mappings." + if (!$rdf.ns[uri]) throw 'The prefix "'+uri+'" is not set in the API'; + uri = $rdf.ns[uri] + name } - return new RDFSymbol(uri) + return new $rdf.Symbol(uri) } -RDFFormula.prototype.literal = function(val, lang, dt) { - return new RDFLiteral(val.toString(), lang, dt) +$rdf.sym = function(uri) { return new $rdf.Symbol(uri); }; + +$rdf.Formula.prototype.literal = function(val, lang, dt) { + return new $rdf.Literal(val.toString(), lang, dt) +} +$rdf.lit = $rdf.Formula.prototype.literal; + +$rdf.Formula.prototype.bnode = function(id) { + return new $rdf.BlankNode(id) } -RDFFormula.prototype.bnode = function(id) { - return new RDFBlankNode(id) +$rdf.Formula.prototype.formula = function() { + return new $rdf.Formula() } -RDFFormula.prototype.formula = function() { - return new RDFFormula() +$rdf.Formula.prototype.collection = function () { // obsolete + return new $rdf.Collection() } -RDFFormula.prototype.collection = function () { // obsolete - return new RDFCollection() -} - -RDFFormula.prototype.list = function (values) { - li = new RDFCollection(); +$rdf.Formula.prototype.list = function (values) { + li = new $rdf.Collection(); if (values) { for(var i = 0; i= 0) return uri.slice(0, index); @@ -135,9 +142,4 @@ Util.uri.protocol = function (uri) { return null; } //protocol -URIjoin = Util.uri.join -uri_docpart = Util.uri.docpart -uri_protocol = Util.uri.protocol - - //ends From ea767e5647cc6859b3238fbd7240a62f939893ad Mon Sep 17 00:00:00 2001 From: aurimasv Date: Thu, 26 Apr 2012 17:36:17 -0500 Subject: [PATCH 02/38] Set up environment for RDF parser --- chrome/content/zotero/xpcom/rdf.js | 9 +++--- chrome/content/zotero/xpcom/rdf/init.js | 32 +++++++++++++++++++ .../zotero/xpcom/translation/translate.js | 2 +- components/zotero-service.js | 1 + 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 chrome/content/zotero/xpcom/rdf/init.js diff --git a/chrome/content/zotero/xpcom/rdf.js b/chrome/content/zotero/xpcom/rdf.js index dceef34ffd..e68120ce57 100644 --- a/chrome/content/zotero/xpcom/rdf.js +++ b/chrome/content/zotero/xpcom/rdf.js @@ -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; \ No newline at end of file diff --git a/chrome/content/zotero/xpcom/rdf/init.js b/chrome/content/zotero/xpcom/rdf/init.js new file mode 100644 index 0000000000..81941997b6 --- /dev/null +++ b/chrome/content/zotero/xpcom/rdf/init.js @@ -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 Date: Thu, 26 Apr 2012 20:55:14 -0500 Subject: [PATCH 03/38] Eliminate unintentional globals --- chrome/content/zotero/xpcom/rdf/identity.js | 2 +- chrome/content/zotero/xpcom/rdf/n3parser.js | 2 +- chrome/content/zotero/xpcom/rdf/serialize.js | 18 +++++++++--------- chrome/content/zotero/xpcom/rdf/term.js | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/chrome/content/zotero/xpcom/rdf/identity.js b/chrome/content/zotero/xpcom/rdf/identity.js index da3b3ead21..f2c803200f 100644 --- a/chrome/content/zotero/xpcom/rdf/identity.js +++ b/chrome/content/zotero/xpcom/rdf/identity.js @@ -119,7 +119,7 @@ $rdf.IndexedFormula.prototype.newPropertyAction = function newPropertyAction(pre this.propertyActions[hash].push(action); // Now apply the function to to statements already in the store var toBeFixed = this.statementsMatching(undefined, pred, undefined); - done = false; + var done = false; for (var i=0; i', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type': 'a' @@ -288,7 +288,7 @@ __Serializer.prototype.statementsToN3 = function(sts) { return s } - treeToLine = function(tree) { + var treeToLine = function(tree) { var str = ''; for (var i=0; i.\n'; for (var ns in namespaceCounts) { @@ -563,7 +563,7 @@ function hexify(str) { // also used in parser function backslashUify(str) { - var res = ''; + var res = '', k; for (var i=0; i65535) @@ -599,7 +599,7 @@ __Serializer.prototype.statementsToXML = function(sts) { return s } - XMLtreeToLine = function(tree) { + var XMLtreeToLine = function(tree) { var str = ''; for (var i=0; i"]); } function collectionXMLTree(subject, stats) { - res = [] + var res = [] for (var i=0; i< subject.elements.length; i++) { res.push(subjectXMLTree(subject.elements[i], stats)); } diff --git a/chrome/content/zotero/xpcom/rdf/term.js b/chrome/content/zotero/xpcom/rdf/term.js index cced406dda..4f7d1b2ae8 100644 --- a/chrome/content/zotero/xpcom/rdf/term.js +++ b/chrome/content/zotero/xpcom/rdf/term.js @@ -246,7 +246,7 @@ $rdf.Formula.prototype.collection = function () { // obsolete } $rdf.Formula.prototype.list = function (values) { - li = new $rdf.Collection(); + var li = new $rdf.Collection(); if (values) { for(var i = 0; i Date: Thu, 26 Apr 2012 23:56:08 -0500 Subject: [PATCH 04/38] Use shorthand notation for rdf:type and some other constructs. --- chrome/content/zotero/xpcom/rdf/serialize.js | 69 +++++++++++++++++--- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/xpcom/rdf/serialize.js b/chrome/content/zotero/xpcom/rdf/serialize.js index 5baf34b2aa..bc506c6887 100644 --- a/chrome/content/zotero/xpcom/rdf/serialize.js +++ b/chrome/content/zotero/xpcom/rdf/serialize.js @@ -669,19 +669,72 @@ __Serializer.prototype.statementsToXML = function(sts) { // The tree for a subject function subjectXMLTree(subject, stats) { - var start + const liPrefix = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#_'; + var results = []; + var type = null, t, st; + var sts = stats.subjects[sz.toStr(subject)]; // relevant statements + sts.sort(); + for (var i=0; i', + subjectXMLTree(st.object, stats), + '']); + break; + case 'symbol': + results = results.concat(['<'+ t +' rdf:resource="' + + relURI(st.object)+'"/>']); + break; + case 'literal': + results = results.concat(['<'+ t + + (st.object.dt ? ' rdf:datatype="'+escapeForXML(st.object.dt.uri)+'"' : '') + + (st.object.lang ? ' xml:lang="'+st.object.lang+'"' : '') + + '>' + escapeForXML(st.object.value) + + '']); + break; + case 'collection': + results = results.concat(['<'+ t +' rdf:parseType="Collection">', + collectionXMLTree(st.object, stats), + '']); + break; + default: + throw "Can't serialize object of type "+st.object.termType +" into XML"; + } // switch + } + } + + var tag = type ? qname(type) : 'rdf:Description'; + + var attrs = ''; if (subject.termType == 'bnode') { - if (!stats.incoming[subject]) { // anonymous bnode - var start = ''; - } else { - var start = ''; + if(sz.incoming[subject].length != 1) { // not an anonymous bnode + attrs = ' rdf:ID="'+subject.toNT().slice(2)+'"'; } } else { - var start = ''; + attrs = ' rdf:about="'+ relURI(subject)+'"'; } - return [ start ].concat( - [propertyXMLTree(subject, stats)]).concat([""]); + return [ '<' + tag + attrs + '>' ].concat([results]).concat([""]); } function collectionXMLTree(subject, stats) { var res = [] From b0923f64a34b94275d2291c6266ca8af882b7cae Mon Sep 17 00:00:00 2001 From: aurimasv Date: Fri, 27 Apr 2012 00:15:57 -0500 Subject: [PATCH 05/38] Simon: use objects instead of arrays in serialize.js --- chrome/content/zotero/xpcom/rdf/serialize.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/rdf/serialize.js b/chrome/content/zotero/xpcom/rdf/serialize.js index bc506c6887..c8953b943d 100644 --- a/chrome/content/zotero/xpcom/rdf/serialize.js +++ b/chrome/content/zotero/xpcom/rdf/serialize.js @@ -111,8 +111,8 @@ __Serializer.prototype.makeUpPrefix = function(uri) { // - do stuff about the docu first and then (or first) about its primary topic. __Serializer.prototype.rootSubjects = function(sts) { - var incoming = []; - var subjects = []; + var incoming = {}; + var subjects = {}; var sz = this; var allBnodes = {}; From eaa50ca9fc49883cd3bf9f3942f78a36714efe2e Mon Sep 17 00:00:00 2001 From: aurimasv Date: Fri, 27 Apr 2012 00:23:29 -0500 Subject: [PATCH 06/38] Simon: patches to RDF support --- chrome/content/zotero/xpcom/rdf/serialize.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/rdf/serialize.js b/chrome/content/zotero/xpcom/rdf/serialize.js index c8953b943d..c9fb3b6864 100644 --- a/chrome/content/zotero/xpcom/rdf/serialize.js +++ b/chrome/content/zotero/xpcom/rdf/serialize.js @@ -697,9 +697,14 @@ __Serializer.prototype.statementsToXML = function(sts) { t = qname(st.predicate); switch (st.object.termType) { case 'bnode': - results = results.concat(['<'+ t +'>', - subjectXMLTree(st.object, stats), - '']); + if(sz.incoming[st.object].length == 1) { + results = results.concat(['<'+ t +'>', + subjectXMLTree(st.object, stats), + '']); + } else { + results = results.concat(['<'+ t +' rdf:nodeID="' + +st.object.toNT().slice(2)+'"/>']); + } break; case 'symbol': results = results.concat(['<'+ t +' rdf:resource="' @@ -728,7 +733,7 @@ __Serializer.prototype.statementsToXML = function(sts) { var attrs = ''; if (subject.termType == 'bnode') { if(sz.incoming[subject].length != 1) { // not an anonymous bnode - attrs = ' rdf:ID="'+subject.toNT().slice(2)+'"'; + attrs = ' rdf:nodeID="'+subject.toNT().slice(2)+'"'; } } else { attrs = ' rdf:about="'+ relURI(subject)+'"'; From a3810626213aab3d3df8ecfc0e8df4e3c10cef6c Mon Sep 17 00:00:00 2001 From: aurimasv Date: Fri, 27 Apr 2012 00:27:44 -0500 Subject: [PATCH 07/38] Simon: closes #1732, Creator sequence breaks in RDF export with > 10 creators (thanks Frank) --- chrome/content/zotero/xpcom/rdf/serialize.js | 29 +++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/rdf/serialize.js b/chrome/content/zotero/xpcom/rdf/serialize.js index c9fb3b6864..ae5db64f8d 100644 --- a/chrome/content/zotero/xpcom/rdf/serialize.js +++ b/chrome/content/zotero/xpcom/rdf/serialize.js @@ -673,7 +673,34 @@ __Serializer.prototype.statementsToXML = function(sts) { var results = []; var type = null, t, st; var sts = stats.subjects[sz.toStr(subject)]; // relevant statements - sts.sort(); + + // Sort only on the predicate, leave the order at object + // level undisturbed. This leaves multilingual content in + // the order of entry (for partner literals), which helps + // readability. + // + // For the predicate sort, we attempt to split the uri + // as a hint to the sequence, as sequenced items seems + // to be of the form http://example.com#_1, http://example.com#_2, + // et cetera. Probably not the most optimal of fixes, but + // it does work. + sts.sort(function(a,b) { + var aa = a.predicate.uri.split('#_'); + var bb = a.predicate.uri.split('#_'); + if (aa[0] > bb[0]) { + return 1; + } else if (aa[0] < bb[0]) { + return -1; + } else if ("undefined" !== typeof aa[1] && "undefined" !== typeof bb[1]) { + if (parseInt(aa[1], 10) > parseInt(bb[1], 10)) { + return 1; + } else if (parseInt(aa[1], 10) < parseInt(bb[1], 10)) { + return -1; + } + } + return 0; + }); + for (var i=0; i Date: Fri, 27 Apr 2012 00:29:02 -0500 Subject: [PATCH 08/38] Simon: fix invalid XML on export due to quotation marks in URI --- chrome/content/zotero/xpcom/rdf/serialize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/rdf/serialize.js b/chrome/content/zotero/xpcom/rdf/serialize.js index ae5db64f8d..725ecdc647 100644 --- a/chrome/content/zotero/xpcom/rdf/serialize.js +++ b/chrome/content/zotero/xpcom/rdf/serialize.js @@ -660,7 +660,7 @@ __Serializer.prototype.statementsToXML = function(sts) { function escapeForXML(str) { if (typeof str == 'undefined') return '@@@undefined@@@@'; - return str.replace(/&/g, '&').replace(/ Date: Fri, 27 Apr 2012 00:34:53 -0500 Subject: [PATCH 09/38] Remove unused code from the unused n3 parser --- chrome/content/zotero/xpcom/rdf/n3parser.js | 111 +------------------- 1 file changed, 3 insertions(+), 108 deletions(-) diff --git a/chrome/content/zotero/xpcom/rdf/n3parser.js b/chrome/content/zotero/xpcom/rdf/n3parser.js index 1260be2d03..42ac568db0 100644 --- a/chrome/content/zotero/xpcom/rdf/n3parser.js +++ b/chrome/content/zotero/xpcom/rdf/n3parser.js @@ -1,73 +1,10 @@ -/** -* -* UTF-8 data encode / decode -* http://www.webtoolkit.info/ -* -**/ - $rdf.N3Parser = function () { function hexify(str) { // also used in parser return encodeURI(str); } -var Utf8 = { - - // public method for url encoding - encode : function (string) { - string = string.replace(/\r\n/g,"\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - - var c = string.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - - } - - return utftext; - }, - - // public method for url decoding - decode : function (utftext) { - var string = ""; - var i = 0; - - while ( i < utftext.length ) { - - var c = utftext.charCodeAt(i); - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - string += String.fromCharCode(((c & 31) << 6) - | (utftext.charCodeAt(i+1) & 63)); - i += 2; - } - else { - string += String.fromCharCode(((c & 15) << 12) - | ((utftext.charCodeAt(i+1) & 63) << 6) - | (utftext.charCodeAt(i+2) & 63)); - i += 3; - } - } - return string; - } - -}// Things we need to define to make converted pythn code work in js +// Things we need to define to make converted pythn code work in js // environment of $rdf var RDFSink_forSomeSym = "http://www.w3.org/2000/10/swap/log#forSome"; @@ -125,19 +62,6 @@ var stringFromCharCode = function(uesc) { return String.fromCharCode(uesc); } - -String.prototype.encode = function(encoding) { - if (encoding != 'utf-8') throw "UTF8_converter: can only do utf-8" - return Utf8.encode(this); -} -String.prototype.decode = function(encoding) { - if (encoding != 'utf-8') throw "UTF8_converter: can only do utf-8" - //return Utf8.decode(this); - return this; -} - - - var uripath_join = function(base, given) { return $rdf.Util.uri.join(given, base) // sad but true } @@ -315,7 +239,7 @@ __SinkParser.prototype.feed = function(octets) { So if there is more data to feed to the parser, it should be straightforward to recover.*/ - var str = octets.decode("utf-8"); + var str = octets; var i = 0; while ((i >= 0)) { var j = this.skipSpace(str, i); @@ -1462,36 +1386,7 @@ __SinkParser.prototype.UEscape = function(str, i, startline) { var uch = stringFromCharCode( ( ( "0x" + pyjslib_slice(value, 2, 10) ) - 0 ) ); return new pyjslib_Tuple([j, uch]); }; -function OLD_BadSyntax(uri, lines, str, i, why) { - return new __OLD_BadSyntax(uri, lines, str, i, why); -} -function __OLD_BadSyntax(uri, lines, str, i, why) { - this._str = str.encode("utf-8"); - this._str = str; - this._i = i; - this._why = why; - this.lines = lines; - this._uri = uri; -} -__OLD_BadSyntax.prototype.toString = function() { - var str = this._str; - var i = this._i; - var st = 0; - if ((i > 60)) { - var pre = "..."; - var st = ( i - 60 ) ; - } - else { - var pre = ""; - } - if (( ( pyjslib_len(str) - i ) > 60)) { - var post = "..."; - } - else { - var post = ""; - } - return "Line %i of <%s>: Bad syntax (%s) at ^ in:\n\"%s%s^%s%s\"" % new pyjslib_Tuple([ ( this.lines + 1 ) , this._uri, this._why, pre, pyjslib_slice(str, st, i), pyjslib_slice(str, i, ( i + 60 ) ), post]); -}; + function BadSyntax(uri, lines, str, i, why) { return ( ( ( ( ( ( ( ( "Line " + ( lines + 1 ) ) + " of <" ) + uri ) + ">: Bad syntax: " ) + why ) + "\nat: \"" ) + pyjslib_slice(str, i, ( i + 30 ) ) ) + "\"" ) ; } From 87e77593c389f2930cbfbd115f4ab2813adf6e66 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Fri, 27 Apr 2012 00:55:00 -0500 Subject: [PATCH 10/38] Remove some left-over unnecessary code from previous commits --- chrome/content/zotero/xpcom/rdf/serialize.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/rdf/serialize.js b/chrome/content/zotero/xpcom/rdf/serialize.js index 725ecdc647..9181293ef2 100644 --- a/chrome/content/zotero/xpcom/rdf/serialize.js +++ b/chrome/content/zotero/xpcom/rdf/serialize.js @@ -706,9 +706,6 @@ __Serializer.prototype.statementsToXML = function(sts) { if(st.predicate.uri == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' && !type && st.object.termType == "symbol") { // look for a type type = st.object; - sts.splice(i,1); - i--; - continue; } else { // see whether predicate can be replaced with "li" if(st.predicate.uri.substr(0, liPrefix.length) == liPrefix) { From 805d3ed6a67add126eff97579200458b52bf5ac5 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Fri, 27 Apr 2012 01:53:00 -0500 Subject: [PATCH 11/38] Passed through jsbeutifier --- chrome/content/zotero/xpcom/rdf/identity.js | 662 +++--- chrome/content/zotero/xpcom/rdf/init.js | 48 +- chrome/content/zotero/xpcom/rdf/match.js | 167 +- chrome/content/zotero/xpcom/rdf/n3parser.js | 2100 +++++++++--------- chrome/content/zotero/xpcom/rdf/rdfparser.js | 987 ++++---- chrome/content/zotero/xpcom/rdf/serialize.js | 1231 +++++----- chrome/content/zotero/xpcom/rdf/term.js | 403 ++-- chrome/content/zotero/xpcom/rdf/uri.js | 208 +- 8 files changed, 2869 insertions(+), 2937 deletions(-) diff --git a/chrome/content/zotero/xpcom/rdf/identity.js b/chrome/content/zotero/xpcom/rdf/identity.js index f2c803200f..9aef4c8c65 100644 --- a/chrome/content/zotero/xpcom/rdf/identity.js +++ b/chrome/content/zotero/xpcom/rdf/identity.js @@ -12,505 +12,489 @@ // 2007 Changed so as not to munge statements from documents when smushing // // +/*jsl:option explicit*/ +// Turn on JavaScriptLint variable declaration checking +$rdf.IndexedFormula = function () { -/*jsl:option explicit*/ // Turn on JavaScriptLint variable declaration checking - -$rdf.IndexedFormula = function() { - -var owl_ns = "http://www.w3.org/2002/07/owl#"; -// var link_ns = "http://www.w3.org/2007/ont/link#"; - -/* hashString functions are used as array indeces. This is done to avoid -** conflict with existing properties of arrays such as length and map. -** See issue 139. -*/ -$rdf.Literal.prototype.hashString = $rdf.Literal.prototype.toNT; -$rdf.Symbol.prototype.hashString = $rdf.Symbol.prototype.toNT; -$rdf.BlankNode.prototype.hashString = $rdf.BlankNode.prototype.toNT; -$rdf.Collection.prototype.hashString = $rdf.Collection.prototype.toNT; + var owl_ns = "http://www.w3.org/2002/07/owl#"; + // var link_ns = "http://www.w3.org/2007/ont/link#"; + /* hashString functions are used as array indeces. This is done to avoid + ** conflict with existing properties of arrays such as length and map. + ** See issue 139. + */ + $rdf.Literal.prototype.hashString = $rdf.Literal.prototype.toNT; + $rdf.Symbol.prototype.hashString = $rdf.Symbol.prototype.toNT; + $rdf.BlankNode.prototype.hashString = $rdf.BlankNode.prototype.toNT; + $rdf.Collection.prototype.hashString = $rdf.Collection.prototype.toNT; -//Stores an associative array that maps URIs to functions -$rdf.IndexedFormula = function(features) { - this.statements = []; // As in Formula + //Stores an associative array that maps URIs to functions + $rdf.IndexedFormula = function (features) { + this.statements = []; // As in Formula this.optional = []; this.propertyActions = []; // Array of functions to call when getting statement with {s X o} //maps to [f(F,s,p,o),...] - this.classActions = []; // Array of functions to call when adding { s type X } - this.redirections = []; // redirect to lexically smaller equivalent symbol - this.aliases = []; // reverse mapping to redirection: aliases for this + this.classActions = []; // Array of functions to call when adding { s type X } + this.redirections = []; // redirect to lexically smaller equivalent symbol + this.aliases = []; // reverse mapping to redirection: aliases for this this.HTTPRedirects = []; // redirections we got from HTTP - this.subjectIndex = []; // Array of statements with this X as subject - this.predicateIndex = []; // Array of statements with this X as subject - this.objectIndex = []; // Array of statements with this X as object - this.whyIndex = []; // Array of statements with X as provenance - this.index = [ this.subjectIndex, this.predicateIndex, this.objectIndex, this.whyIndex ]; + this.subjectIndex = []; // Array of statements with this X as subject + this.predicateIndex = []; // Array of statements with this X as subject + this.objectIndex = []; // Array of statements with this X as object + this.whyIndex = []; // Array of statements with X as provenance + this.index = [this.subjectIndex, this.predicateIndex, this.objectIndex, this.whyIndex]; this.namespaces = {} // Dictionary of namespace prefixes - if (features === undefined) features = ["sameAs", - "InverseFunctionalProperty", "FunctionalProperty"]; -// this.features = features + if(features === undefined) features = ["sameAs", + "InverseFunctionalProperty", "FunctionalProperty"]; + // this.features = features // Callbackify? function handleRDFType(formula, subj, pred, obj, why) { - if (formula.typeCallback != undefined) - formula.typeCallback(formula, obj, why); + if(formula.typeCallback != undefined) + formula.typeCallback(formula, obj, why); - var x = formula.classActions[obj.hashString()]; - var done = false; - if (x) { - for (var i=0; i'] = [ handleRDFType ]; + this.propertyActions[''] = [handleRDFType]; // Assumption: these terms are not redirected @@fixme - if ($rdf.Util.ArrayIndexOf(features,"sameAs") >= 0) - this.propertyActions[''] = [ - function(formula, subj, pred, obj, why) { - // tabulator.log.warn("Equating "+subj.uri+" sameAs "+obj.uri); //@@ - formula.equate(subj,obj); - return true; // true if statement given is NOT needed in the store - }]; //sameAs -> equate & don't add to index - - if ($rdf.Util.ArrayIndexOf(features,"InverseFunctionalProperty") >= 0) - this.classActions["<"+owl_ns+"InverseFunctionalProperty>"] = [ - function(formula, subj, pred, obj, addFn) { - return formula.newPropertyAction(subj, handle_IFP); // yes subj not pred! - }]; //IFP -> handle_IFP, do add to index - - if ($rdf.Util.ArrayIndexOf(features,"FunctionalProperty") >= 0) - this.classActions["<"+owl_ns+"FunctionalProperty>"] = [ - function(formula, subj, proj, obj, addFn) { - return formula.newPropertyAction(subj, handle_FP); - }]; //FP => handleFP, do add to index - - function handle_IFP(formula, subj, pred, obj) { - var s1 = formula.any(undefined, pred, obj); - if (s1 == undefined) return false; // First time with this value - // tabulator.log.warn("Equating "+s1.uri+" and "+subj.uri + " because IFP "+pred.uri); //@@ - formula.equate(s1, subj); - return true; + if($rdf.Util.ArrayIndexOf(features, "sameAs") >= 0) + this.propertyActions[''] = [ + function (formula, subj, pred, obj, why) { + // tabulator.log.warn("Equating "+subj.uri+" sameAs "+obj.uri); //@@ + formula.equate(subj, obj); + return true; // true if statement given is NOT needed in the store + }]; //sameAs -> equate & don't add to index + if($rdf.Util.ArrayIndexOf(features, "InverseFunctionalProperty") >= 0) + this.classActions["<" + owl_ns + "InverseFunctionalProperty>"] = [ + function (formula, subj, pred, obj, addFn) { + return formula.newPropertyAction(subj, handle_IFP); // yes subj not pred! + }]; //IFP -> handle_IFP, do add to index + if($rdf.Util.ArrayIndexOf(features, "FunctionalProperty") >= 0) + this.classActions["<" + owl_ns + "FunctionalProperty>"] = [ + function (formula, subj, proj, obj, addFn) { + return formula.newPropertyAction(subj, handle_FP); + } + ]; //FP => handleFP, do add to index + function handle_IFP(formula, subj, pred, obj) { + var s1 = formula.any(undefined, pred, obj); + if(s1 == undefined) return false; // First time with this value + // tabulator.log.warn("Equating "+s1.uri+" and "+subj.uri + " because IFP "+pred.uri); //@@ + formula.equate(s1, subj); + return true; } //handle_IFP - - function handle_FP(formula, subj, pred, obj) { - var o1 = formula.any(subj, pred, undefined); - if (o1 == undefined) return false; // First time with this value - // tabulator.log.warn("Equating "+o1.uri+" and "+obj.uri + " because FP "+pred.uri); //@@ - formula.equate(o1, obj); - return true ; + function handle_FP(formula, subj, pred, obj) { + var o1 = formula.any(subj, pred, undefined); + if(o1 == undefined) return false; // First time with this value + // tabulator.log.warn("Equating "+o1.uri+" and "+obj.uri + " because FP "+pred.uri); //@@ + formula.equate(o1, obj); + return true; } //handle_FP + } /* end IndexedFormula */ -} /* end IndexedFormula */ + $rdf.IndexedFormula.prototype = new $rdf.Formula(); + $rdf.IndexedFormula.prototype.constructor = $rdf.IndexedFormula; + $rdf.IndexedFormula.SuperClass = $rdf.Formula; -$rdf.IndexedFormula.prototype = new $rdf.Formula(); -$rdf.IndexedFormula.prototype.constructor = $rdf.IndexedFormula; -$rdf.IndexedFormula.SuperClass = $rdf.Formula; - -$rdf.IndexedFormula.prototype.newPropertyAction = function newPropertyAction(pred, action) { + $rdf.IndexedFormula.prototype.newPropertyAction = function newPropertyAction(pred, action) { //$rdf.log.debug("newPropertyAction: "+pred); var hash = pred.hashString(); - if (this.propertyActions[hash] == undefined) - this.propertyActions[hash] = []; + if(this.propertyActions[hash] == undefined) + this.propertyActions[hash] = []; this.propertyActions[hash].push(action); // Now apply the function to to statements already in the store var toBeFixed = this.statementsMatching(undefined, pred, undefined); var done = false; - for (var i=0; i'; - return (!!this.subjectIndex[hash] || !!this.objectIndex[hash] - || !!this.predicateIndex[hash]); -} + return (!!this.subjectIndex[hash] + || !!this.objectIndex[hash] + || !!this.predicateIndex[hash]); + } -// Find an unused id for a file being edited: return a symbol -// (Note: Slow iff a lot of them -- could be O(log(k)) ) -$rdf.IndexedFormula.prototype.nextSymbol = function(doc) { - for(var i=0;;i++) { - var uri = doc.uri + '#n' + i; - if (!this.mentionsURI(uri)) return this.sym(uri); + // Find an unused id for a file being edited: return a symbol + // (Note: Slow iff a lot of them -- could be O(log(k)) ) + $rdf.IndexedFormula.prototype.nextSymbol = function (doc) { + for(var i = 0;; i++) { + var uri = doc.uri + '#n' + i; + if(!this.mentionsURI(uri)) return this.sym(uri); } -} + } -$rdf.IndexedFormula.prototype.anyStatementMatching = function(subj,pred,obj,why) { - var x = this.statementsMatching(subj,pred,obj,why,true); - if (!x || x == []) return undefined; + $rdf.IndexedFormula.prototype.anyStatementMatching = function (subj, pred, obj, why) { + var x = this.statementsMatching(subj, pred, obj, why, true); + if(!x || x == []) return undefined; return x[0]; -}; + }; -// Return statements matching a pattern -// ALL CONVENIENCE LOOKUP FUNCTIONS RELY ON THIS! -$rdf.IndexedFormula.prototype.statementsMatching = function(subj,pred,obj,why,justOne) { + // Return statements matching a pattern + // ALL CONVENIENCE LOOKUP FUNCTIONS RELY ON THIS! + $rdf.IndexedFormula.prototype.statementsMatching = function (subj, pred, obj, why, justOne) { //$rdf.log.debug("Matching {"+subj+" "+pred+" "+obj+"}"); - - var pat = [ subj, pred, obj, why ]; + var pat = [subj, pred, obj, why]; var pattern = []; var hash = []; var wild = []; // wildcards var given = []; // Not wild - for (var p=0; p<4; p++) { - pattern[p] = this.canon(RDFMakeTerm(this, pat[p])); - if (pattern[p] == undefined) { - wild.push(p); - } else { - given.push(p); - hash[p] = pattern[p].hashString(); - } + for(var p = 0; p < 4; p++) { + pattern[p] = this.canon(RDFMakeTerm(this, pat[p])); + if(pattern[p] == undefined) { + wild.push(p); + } else { + given.push(p); + hash[p] = pattern[p].hashString(); + } } - if (given.length == 0) { - return this.statements; + if(given.length == 0) { + return this.statements; } - if (given.length == 1) { // Easy too, we have an index for that - var p = given[0]; - var list = this.index[p][hash[p]]; - if(list && justOne) { - if(list.length>1) - list = list.slice(0,1); - } - return list == undefined ? [] : list; + if(given.length == 1) { // Easy too, we have an index for that + var p = given[0]; + var list = this.index[p][hash[p]]; + if(list && justOne) { + if(list.length > 1) + list = list.slice(0, 1); + } + return list == undefined ? [] : list; } - + // Now given.length is 2, 3 or 4. // We hope that the scale-free nature of the data will mean we tend to get // a short index in there somewhere! - var best = 1e10; // really bad var best_i; - for (var i=0; i1) - results = results.slice(0,1); + if(results.length > 1) + results = results.slice(0, 1); } return results; -}; // statementsMatching - -/** remove a particular statement from the bank **/ -$rdf.IndexedFormula.prototype.remove = function (st) { + }; // statementsMatching + /** remove a particular statement from the bank **/ + $rdf.IndexedFormula.prototype.remove = function (st) { //$rdf.log.debug("entering remove w/ st=" + st); - var term = [ st.subject, st.predicate, st.object, st.why]; - for (var p=0; p<4; p++) { - var c = this.canon(term[p]); - var h = c.hashString(); - if (this.index[p][h] == undefined) { - //$rdf.log.warn ("Statement removal: no index '+p+': "+st); - } else { - $rdf.Util.RDFArrayRemove(this.index[p][h], st); - } + var term = [st.subject, st.predicate, st.object, st.why]; + for(var p = 0; p < 4; p++) { + var c = this.canon(term[p]); + var h = c.hashString(); + if(this.index[p][h] == undefined) { + //$rdf.log.warn ("Statement removal: no index '+p+': "+st); + } else { + $rdf.Util.RDFArrayRemove(this.index[p][h], st); + } } $rdf.Util.RDFArrayRemove(this.statements, st); -}; //remove - -/** remove all statements matching args (within limit) **/ -$rdf.IndexedFormula.prototype.removeMany = function (subj, pred, obj, why, limit) { + }; //remove + /** remove all statements matching args (within limit) **/ + $rdf.IndexedFormula.prototype.removeMany = function (subj, pred, obj, why, limit) { //$rdf.log.debug("entering removeMany w/ subj,pred,obj,why,limit = " + subj +", "+ pred+", " + obj+", " + why+", " + limit); - var sts = this.statementsMatching (subj, pred, obj, why, false); + var sts = this.statementsMatching(subj, pred, obj, why, false); //This is a subtle bug that occcured in updateCenter.js too. //The fact is, this.statementsMatching returns this.whyIndex instead of a copy of it //but for perfromance consideration, it's better to just do that //so make a copy here. var statements = []; - for (var i=0;i other.classOrder) return +1 + if(this.value < other.value) return -1 + if(this.value > other.value) return +1 + return 0 +} -$rdf.Literal.prototype.compareTerm = function(other) { - if (this.classOrder < other.classOrder) return -1 - if (this.classOrder > other.classOrder) return +1 - if (this.value < other.value) return -1 - if (this.value > other.value) return +1 - return 0 -} +$rdf.Symbol.prototype.compareTerm = function (other) { + if(this.classOrder < other.classOrder) return -1 + if(this.classOrder > other.classOrder) return +1 + if(this.uri < other.uri) return -1 + if(this.uri > other.uri) return +1 + return 0 +} -$rdf.Symbol.prototype.compareTerm = function(other) { - if (this.classOrder < other.classOrder) return -1 - if (this.classOrder > other.classOrder) return +1 - if (this.uri < other.uri) return -1 - if (this.uri > other.uri) return +1 - return 0 -} - -$rdf.BlankNode.prototype.compareTerm = function(other) { - if (this.classOrder < other.classOrder) return -1 - if (this.classOrder > other.classOrder) return +1 - if (this.id < other.id) return -1 - if (this.id > other.id) return +1 - return 0 -} +$rdf.BlankNode.prototype.compareTerm = function (other) { + if(this.classOrder < other.classOrder) return -1 + if(this.classOrder > other.classOrder) return +1 + if(this.id < other.id) return -1 + if(this.id > other.id) return +1 + return 0 +} $rdf.Collection.prototype.compareTerm = $rdf.BlankNode.prototype.compareTerm // Convenience routines - // Only one of s p o can be undefined, and w is optional. -$rdf.Formula.prototype.each = function(s,p,o,w) { - var results = [] - var st, sts = this.statementsMatching(s,p,o,w,false) - var i, n=sts.length - if (typeof s == 'undefined') { - for (i=0; i 0) - throw "missing.js: oops nnonempty dict not imp"; - return []; -} - -var pyjslib_len = function(s) { return s.length } - -var pyjslib_slice = function(str, i, j) { - if (typeof str.slice == 'undefined') - throw '@@ mising.js: No .slice function for '+str+' of type '+(typeof str) - if ((typeof j == 'undefined') || (j ==null)) return str.slice(i); - return str.slice(i, j) // @ exactly the same spec? -} -var StopIteration = Error('dummy error stop iteration'); - -var pyjslib_Iterator = function(theList) { - this.last = 0; - this.li = theList; - this.next = function() { - if (this.last == this.li.length) throw StopIteration; - return this.li[this.last++]; + var pyjslib_Dict = function (listOfPairs) { + if(listOfPairs.length > 0) + throw "missing.js: oops nnonempty dict not imp"; + return []; } - return this; -}; -var ord = function(str) { - return str.charCodeAt(0) -} + var pyjslib_len = function (s) { + return s.length + } -var string_find = function(str, s) { - return str.indexOf(s) -} + var pyjslib_slice = function (str, i, j) { + if(typeof str.slice == 'undefined') + throw '@@ mising.js: No .slice function for ' + str + ' of type ' + (typeof str) + if((typeof j == 'undefined') || (j == null)) return str.slice(i); + return str.slice(i, j) // @ exactly the same spec? + } + var StopIteration = Error('dummy error stop iteration'); -var assertFudge = function(condition, desc) { - if (condition) return; - if (desc) throw "python Assertion failed: "+desc; - throw "(python) Assertion failed."; -} + var pyjslib_Iterator = function (theList) { + this.last = 0; + this.li = theList; + this.next = function () { + if(this.last == this.li.length) throw StopIteration; + return this.li[this.last++]; + } + return this; + }; + + var ord = function (str) { + return str.charCodeAt(0) + } + + var string_find = function (str, s) { + return str.indexOf(s) + } + + var assertFudge = function (condition, desc) { + if(condition) return; + if(desc) throw "python Assertion failed: " + desc; + throw "(python) Assertion failed."; + } -var stringFromCharCode = function(uesc) { - return String.fromCharCode(uesc); -} + var stringFromCharCode = function (uesc) { + return String.fromCharCode(uesc); + } -var uripath_join = function(base, given) { - return $rdf.Util.uri.join(given, base) // sad but true -} + var uripath_join = function (base, given) { + return $rdf.Util.uri.join(given, base) // sad but true + } -var becauseSubexpression = null; // No reason needed -var diag_tracking = 0; -var diag_chatty_flag = 0; -var diag_progress = function(str) { /*$rdf.log.debug(str);*/ } + var becauseSubexpression = null; // No reason needed + var diag_tracking = 0; + var diag_chatty_flag = 0; + var diag_progress = function (str) { + /*$rdf.log.debug(str);*/ + } -// why_BecauseOfData = function(doc, reason) { return doc }; + // why_BecauseOfData = function(doc, reason) { return doc }; + var RDF_type_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; + var DAML_sameAs_URI = "http://www.w3.org/2002/07/owl#sameAs"; -var RDF_type_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; -var DAML_sameAs_URI = "http://www.w3.org/2002/07/owl#sameAs"; - -/* + /* function SyntaxError(details) { return new __SyntaxError(details); } */ -function __SyntaxError(details) { + function __SyntaxError(details) { this.details = details -} + } -/* + /* $Id: n3parser.js 14561 2008-02-23 06:37:26Z kennyluck $ @@ -117,49 +122,51 @@ the module, including tests and test harness. */ -var ADDED_HASH = "#"; -var LOG_implies_URI = "http://www.w3.org/2000/10/swap/log#implies"; -var INTEGER_DATATYPE = "http://www.w3.org/2001/XMLSchema#integer"; -var FLOAT_DATATYPE = "http://www.w3.org/2001/XMLSchema#double"; -var DECIMAL_DATATYPE = "http://www.w3.org/2001/XMLSchema#decimal"; -var BOOLEAN_DATATYPE = "http://www.w3.org/2001/XMLSchema#boolean"; -var option_noregen = 0; -var _notQNameChars = "\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~"; -var _notNameChars = ( _notQNameChars + ":" ) ; -var _rdfns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; -var N3CommentCharacter = "#"; -var eol = new RegExp("^[ \\t]*(#[^\\n]*)?\\r?\\n", 'g'); -var eof = new RegExp("^[ \\t]*(#[^\\n]*)?$", 'g'); -var ws = new RegExp("^[ \\t]*", 'g'); -var signed_integer = new RegExp("^[-+]?[0-9]+", 'g'); -var number_syntax = new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?(e[-+]?[0-9]+)?", 'g'); -var digitstring = new RegExp("^[0-9]+", 'g'); -var interesting = new RegExp("[\\\\\\r\\n\\\"]", 'g'); -var langcode = new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)?", 'g'); -function SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) { + var ADDED_HASH = "#"; + var LOG_implies_URI = "http://www.w3.org/2000/10/swap/log#implies"; + var INTEGER_DATATYPE = "http://www.w3.org/2001/XMLSchema#integer"; + var FLOAT_DATATYPE = "http://www.w3.org/2001/XMLSchema#double"; + var DECIMAL_DATATYPE = "http://www.w3.org/2001/XMLSchema#decimal"; + var BOOLEAN_DATATYPE = "http://www.w3.org/2001/XMLSchema#boolean"; + var option_noregen = 0; + var _notQNameChars = "\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~"; + var _notNameChars = (_notQNameChars + ":"); + var _rdfns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; + var N3CommentCharacter = "#"; + var eol = new RegExp("^[ \\t]*(#[^\\n]*)?\\r?\\n", 'g'); + var eof = new RegExp("^[ \\t]*(#[^\\n]*)?$", 'g'); + var ws = new RegExp("^[ \\t]*", 'g'); + var signed_integer = new RegExp("^[-+]?[0-9]+", 'g'); + var number_syntax = new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?(e[-+]?[0-9]+)?", 'g'); + var digitstring = new RegExp("^[0-9]+", 'g'); + var interesting = new RegExp("[\\\\\\r\\n\\\"]", 'g'); + var langcode = new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)?", 'g'); + + function SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) { return new __SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why); -} -function __SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) { - if (typeof openFormula == 'undefined') openFormula=null; - if (typeof thisDoc == 'undefined') thisDoc=""; - if (typeof baseURI == 'undefined') baseURI=null; - if (typeof genPrefix == 'undefined') genPrefix=""; - if (typeof metaURI == 'undefined') metaURI=null; - if (typeof flags == 'undefined') flags=""; - if (typeof why == 'undefined') why=null; + } + + function __SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) { + if(typeof openFormula == 'undefined') openFormula = null; + if(typeof thisDoc == 'undefined') thisDoc = ""; + if(typeof baseURI == 'undefined') baseURI = null; + if(typeof genPrefix == 'undefined') genPrefix = ""; + if(typeof metaURI == 'undefined') metaURI = null; + if(typeof flags == 'undefined') flags = ""; + if(typeof why == 'undefined') why = null; /* note: namespace names should *not* end in #; the # will get added during qname processing */ - + this._bindings = new pyjslib_Dict([]); this._flags = flags; - if ((thisDoc != "")) { - assertFudge((thisDoc.indexOf(":") >= 0), ( "Document URI not absolute: " + thisDoc ) ); - this._bindings[""] = ( ( thisDoc + "#" ) ); + if((thisDoc != "")) { + assertFudge((thisDoc.indexOf(":") >= 0), ("Document URI not absolute: " + thisDoc)); + this._bindings[""] = ((thisDoc + "#")); } this._store = store; - if (genPrefix) { - store.setGenPrefix(genPrefix); + if(genPrefix) { + store.setGenPrefix(genPrefix); } this._thisDoc = thisDoc; this.source = store.sym(thisDoc); @@ -175,61 +182,56 @@ function __SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, this._parentVariables = new pyjslib_Dict([]); this._reason = why; this._reason2 = null; - if (diag_tracking) { - this._reason2 = why_BecauseOfData(store.sym(thisDoc), this._reason); + if(diag_tracking) { + this._reason2 = why_BecauseOfData(store.sym(thisDoc), this._reason); } - if (baseURI) { - this._baseURI = baseURI; - } - else { - if (thisDoc) { - this._baseURI = thisDoc; - } - else { - this._baseURI = null; - } + if(baseURI) { + this._baseURI = baseURI; + } else { + if(thisDoc) { + this._baseURI = thisDoc; + } else { + this._baseURI = null; + } } assertFudge(!(this._baseURI) || (this._baseURI.indexOf(":") >= 0)); - if (!(this._genPrefix)) { - if (this._thisDoc) { - this._genPrefix = ( this._thisDoc + "#_g" ) ; - } - else { - this._genPrefix = RDFSink_uniqueURI(); - } + if(!(this._genPrefix)) { + if(this._thisDoc) { + this._genPrefix = (this._thisDoc + "#_g"); + } else { + this._genPrefix = RDFSink_uniqueURI(); + } } - if ((openFormula == null)) { - if (this._thisDoc) { - this._formula = store.formula( ( thisDoc + "#_formula" ) ); - } - else { - this._formula = store.formula(); - } - } - else { - this._formula = openFormula; + if((openFormula == null)) { + if(this._thisDoc) { + this._formula = store.formula((thisDoc + "#_formula")); + } else { + this._formula = store.formula(); + } + } else { + this._formula = openFormula; } this._context = this._formula; this._parentContext = null; -} -__SinkParser.prototype.here = function(i) { - return ( ( ( ( this._genPrefix + "_L" ) + this.lines ) + "C" ) + ( ( i - this.startOfLine ) + 1 ) ) ; -}; -__SinkParser.prototype.formula = function() { + } + __SinkParser.prototype.here = function (i) { + return((((this._genPrefix + "_L") + this.lines) + "C") + ((i - this.startOfLine) + 1)); + }; + __SinkParser.prototype.formula = function () { return this._formula; -}; -__SinkParser.prototype.loadStream = function(stream) { + }; + __SinkParser.prototype.loadStream = function (stream) { return this.loadBuf(stream.read()); -}; -__SinkParser.prototype.loadBuf = function(buf) { + }; + __SinkParser.prototype.loadBuf = function (buf) { /* Parses a buffer and returns its top level formula*/ - + this.startDoc(); this.feed(buf); return this.endDoc(); -}; -__SinkParser.prototype.feed = function(octets) { + }; + __SinkParser.prototype.feed = function (octets) { /* Feed an octet stream tothe parser @@ -238,219 +240,212 @@ __SinkParser.prototype.feed = function(octets) { remainder after any statements have been parsed. So if there is more data to feed to the parser, it should be straightforward to recover.*/ - + var str = octets; var i = 0; - while ((i >= 0)) { - var j = this.skipSpace(str, i); - if ((j < 0)) { - return; - } - var i = this.directiveOrStatement(str, j); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "expected directive or statement"); - } + while((i >= 0)) { + var j = this.skipSpace(str, i); + if((j < 0)) { + return; + } + var i = this.directiveOrStatement(str, j); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "expected directive or statement"); + } } -}; -__SinkParser.prototype.directiveOrStatement = function(str, h) { + }; + __SinkParser.prototype.directiveOrStatement = function (str, h) { var i = this.skipSpace(str, h); - if ((i < 0)) { - return i; + if((i < 0)) { + return i; } var j = this.directive(str, i); - if ((j >= 0)) { - return this.checkDot(str, j); + if((j >= 0)) { + return this.checkDot(str, j); } var j = this.statement(str, i); - if ((j >= 0)) { - return this.checkDot(str, j); + if((j >= 0)) { + return this.checkDot(str, j); } return j; -}; -__SinkParser.prototype.tok = function(tok, str, i) { + }; + __SinkParser.prototype.tok = function (tok, str, i) { /* Check for keyword. Space must have been stripped on entry and we must not be at end of file.*/ var whitespace = "\t\n\v\f\r "; - if ((pyjslib_slice(str, i, ( i + 1 ) ) == "@")) { - var i = ( i + 1 ) ; - } - else { - if (($rdf.Util.ArrayIndexOf(this.keywords,tok) < 0)) { - return -1; - } - } - var k = ( i + pyjslib_len(tok) ) ; - if ((pyjslib_slice(str, i, k) == tok) && (_notQNameChars.indexOf(str.charAt(k)) >= 0)) { - return k; - } - else { + if((pyjslib_slice(str, i, (i + 1)) == "@")) { + var i = (i + 1); + } else { + if(($rdf.Util.ArrayIndexOf(this.keywords, tok) < 0)) { return -1; + } } -}; -__SinkParser.prototype.directive = function(str, i) { + var k = (i + pyjslib_len(tok)); + if((pyjslib_slice(str, i, k) == tok) && (_notQNameChars.indexOf(str.charAt(k)) >= 0)) { + return k; + } else { + return -1; + } + }; + __SinkParser.prototype.directive = function (str, i) { var j = this.skipSpace(str, i); - if ((j < 0)) { - return j; + if((j < 0)) { + return j; } var res = new pyjslib_List([]); var j = this.tok("bind", str, i); - if ((j > 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "keyword bind is obsolete: use @prefix"); + if((j > 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "keyword bind is obsolete: use @prefix"); } var j = this.tok("keywords", str, i); - if ((j > 0)) { - var i = this.commaSeparatedList(str, j, res, false); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "'@keywords' needs comma separated list of words"); - } - this.setKeywords(pyjslib_slice(res, null, null)); - if ((diag_chatty_flag > 80)) { - diag_progress("Keywords ", this.keywords); - } - return i; + if((j > 0)) { + var i = this.commaSeparatedList(str, j, res, false); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "'@keywords' needs comma separated list of words"); + } + this.setKeywords(pyjslib_slice(res, null, null)); + if((diag_chatty_flag > 80)) { + diag_progress("Keywords ", this.keywords); + } + return i; } var j = this.tok("forAll", str, i); - if ((j > 0)) { - var i = this.commaSeparatedList(str, j, res, true); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forAll"); + if((j > 0)) { + var i = this.commaSeparatedList(str, j, res, true); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forAll"); + } + + var __x = new pyjslib_Iterator(res); + try { + while(true) { + var x = __x.next(); + + + if($rdf.Util.ArrayIndexOf(this._variables, x) < 0 || ($rdf.Util.ArrayIndexOf(this._parentVariables, x) >= 0)) { + this._variables[x] = (this._context.newUniversal(x)); + } + } - - var __x = new pyjslib_Iterator(res); - try { - while (true) { - var x = __x.next(); - - - if ($rdf.Util.ArrayIndexOf(this._variables,x) < 0 || ($rdf.Util.ArrayIndexOf(this._parentVariables,x) >= 0)) { - this._variables[x] = ( this._context.newUniversal(x)); - } - - } - } catch (e) { - if (e != StopIteration) { - throw e; - } + } catch(e) { + if(e != StopIteration) { + throw e; } - - return i; + } + + return i; } var j = this.tok("forSome", str, i); - if ((j > 0)) { - var i = this.commaSeparatedList(str, j, res, this.uri_ref2); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forSome"); + if((j > 0)) { + var i = this.commaSeparatedList(str, j, res, this.uri_ref2); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forSome"); + } + + var __x = new pyjslib_Iterator(res); + try { + while(true) { + var x = __x.next(); + + + this._context.declareExistential(x); + } - - var __x = new pyjslib_Iterator(res); - try { - while (true) { - var x = __x.next(); - - - this._context.declareExistential(x); - - } - } catch (e) { - if (e != StopIteration) { - throw e; - } + } catch(e) { + if(e != StopIteration) { + throw e; } - - return i; + } + + return i; } var j = this.tok("prefix", str, i); - if ((j >= 0)) { - var t = new pyjslib_List([]); - var i = this.qname(str, j, t); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "expected qname after @prefix"); - } - var j = this.uri_ref2(str, i, t); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "expected after @prefix _qname_"); - } - var ns = t[1].uri; - if (this._baseURI) { - var ns = uripath_join(this._baseURI, ns); - } - else { - assertFudge((ns.indexOf(":") >= 0), "With no base URI, cannot handle relative URI for NS"); - } - assertFudge((ns.indexOf(":") >= 0)); - this._bindings[t[0][0]] = ( ns); - - this.bind(t[0][0], hexify(ns)); - return j; + if((j >= 0)) { + var t = new pyjslib_List([]); + var i = this.qname(str, j, t); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "expected qname after @prefix"); + } + var j = this.uri_ref2(str, i, t); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "expected after @prefix _qname_"); + } + var ns = t[1].uri; + if(this._baseURI) { + var ns = uripath_join(this._baseURI, ns); + } else { + assertFudge((ns.indexOf(":") >= 0), "With no base URI, cannot handle relative URI for NS"); + } + assertFudge((ns.indexOf(":") >= 0)); + this._bindings[t[0][0]] = (ns); + + this.bind(t[0][0], hexify(ns)); + return j; } var j = this.tok("base", str, i); - if ((j >= 0)) { - var t = new pyjslib_List([]); - var i = this.uri_ref2(str, j, t); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "expected after @base "); - } - var ns = t[0].uri; - if (this._baseURI) { - var ns = uripath_join(this._baseURI, ns); - } - else { - throw BadSyntax(this._thisDoc, this.lines, str, j, ( ( "With no previous base URI, cannot use relative URI in @base <" + ns ) + ">" ) ); - } - assertFudge((ns.indexOf(":") >= 0)); - this._baseURI = ns; - return i; + if((j >= 0)) { + var t = new pyjslib_List([]); + var i = this.uri_ref2(str, j, t); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "expected after @base "); + } + var ns = t[0].uri; + if(this._baseURI) { + var ns = uripath_join(this._baseURI, ns); + } else { + throw BadSyntax(this._thisDoc, this.lines, str, j, (("With no previous base URI, cannot use relative URI in @base <" + ns) + ">")); + } + assertFudge((ns.indexOf(":") >= 0)); + this._baseURI = ns; + return i; } return -1; -}; -__SinkParser.prototype.bind = function(qn, uri) { - if ((qn == "")) { + }; + __SinkParser.prototype.bind = function (qn, uri) { + if((qn == "")) { + } else { + this._store.setPrefixForURI(qn, uri); } - else { - this._store.setPrefixForURI(qn, uri); - } -}; -__SinkParser.prototype.setKeywords = function(k) { + }; + __SinkParser.prototype.setKeywords = function (k) { /* Takes a list of strings*/ - - if ((k == null)) { - this.keywordsSet = 0; + + if((k == null)) { + this.keywordsSet = 0; + } else { + this.keywords = k; + this.keywordsSet = 1; } - else { - this.keywords = k; - this.keywordsSet = 1; - } -}; -__SinkParser.prototype.startDoc = function() { -}; -__SinkParser.prototype.endDoc = function() { + }; + __SinkParser.prototype.startDoc = function () {}; + __SinkParser.prototype.endDoc = function () { /* Signal end of document and stop parsing. returns formula*/ - + return this._formula; -}; -__SinkParser.prototype.makeStatement = function(quad) { + }; + __SinkParser.prototype.makeStatement = function (quad) { quad[0].add(quad[2], quad[1], quad[3], this.source); this.statementCount += 1; -}; -__SinkParser.prototype.statement = function(str, i) { + }; + __SinkParser.prototype.statement = function (str, i) { var r = new pyjslib_List([]); var i = this.object(str, i, r); - if ((i < 0)) { - return i; + if((i < 0)) { + return i; } var j = this.property_list(str, i, r[0]); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "expected propertylist"); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "expected propertylist"); } return j; -}; -__SinkParser.prototype.subject = function(str, i, res) { + }; + __SinkParser.prototype.subject = function (str, i, res) { return this.item(str, i, res); -}; -__SinkParser.prototype.verb = function(str, i, res) { + }; + __SinkParser.prototype.verb = function (str, i, res) { /* has _prop_ is _prop_ of @@ -460,398 +455,392 @@ __SinkParser.prototype.verb = function(str, i, res) { >- prop -> <- prop -< _operator_*/ - + var j = this.skipSpace(str, i); - if ((j < 0)) { - return j; + if((j < 0)) { + return j; } var r = new pyjslib_List([]); var j = this.tok("has", str, i); - if ((j >= 0)) { - var i = this.prop(str, j, r); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "expected property after 'has'"); - } - res.push(new pyjslib_Tuple(["->", r[0]])); - return i; + if((j >= 0)) { + var i = this.prop(str, j, r); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "expected property after 'has'"); + } + res.push(new pyjslib_Tuple(["->", r[0]])); + return i; } var j = this.tok("is", str, i); - if ((j >= 0)) { - var i = this.prop(str, j, r); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "expected after 'is'"); - } - var j = this.skipSpace(str, i); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "End of file found, expected property after 'is'"); - return j; - } - var i = j; - var j = this.tok("of", str, i); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "expected 'of' after 'is' "); - } - res.push(new pyjslib_Tuple(["<-", r[0]])); + if((j >= 0)) { + var i = this.prop(str, j, r); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "expected after 'is'"); + } + var j = this.skipSpace(str, i); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "End of file found, expected property after 'is'"); return j; + } + var i = j; + var j = this.tok("of", str, i); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "expected 'of' after 'is' "); + } + res.push(new pyjslib_Tuple(["<-", r[0]])); + return j; } var j = this.tok("a", str, i); - if ((j >= 0)) { - res.push(new pyjslib_Tuple(["->", this._store.sym(RDF_type_URI)])); - return j; + if((j >= 0)) { + res.push(new pyjslib_Tuple(["->", this._store.sym(RDF_type_URI)])); + return j; } - if ((pyjslib_slice(str, i, ( i + 2 ) ) == "<=")) { - res.push(new pyjslib_Tuple(["<-", this._store.sym( ( Logic_NS + "implies" ) )])); - return ( i + 2 ) ; + if((pyjslib_slice(str, i, (i + 2)) == "<=")) { + res.push(new pyjslib_Tuple(["<-", this._store.sym((Logic_NS + "implies"))])); + return(i + 2); } - if ((pyjslib_slice(str, i, ( i + 1 ) ) == "=")) { - if ((pyjslib_slice(str, ( i + 1 ) , ( i + 2 ) ) == ">")) { - res.push(new pyjslib_Tuple(["->", this._store.sym( ( Logic_NS + "implies" ) )])); - return ( i + 2 ) ; - } - res.push(new pyjslib_Tuple(["->", this._store.sym(DAML_sameAs_URI)])); - return ( i + 1 ) ; + if((pyjslib_slice(str, i, (i + 1)) == "=")) { + if((pyjslib_slice(str, (i + 1), (i + 2)) == ">")) { + res.push(new pyjslib_Tuple(["->", this._store.sym((Logic_NS + "implies"))])); + return(i + 2); + } + res.push(new pyjslib_Tuple(["->", this._store.sym(DAML_sameAs_URI)])); + return(i + 1); } - if ((pyjslib_slice(str, i, ( i + 2 ) ) == ":=")) { - res.push(new pyjslib_Tuple(["->", ( Logic_NS + "becomes" ) ])); - return ( i + 2 ) ; + if((pyjslib_slice(str, i, (i + 2)) == ":=")) { + res.push(new pyjslib_Tuple(["->", (Logic_NS + "becomes")])); + return(i + 2); } var j = this.prop(str, i, r); - if ((j >= 0)) { - res.push(new pyjslib_Tuple(["->", r[0]])); - return j; + if((j >= 0)) { + res.push(new pyjslib_Tuple(["->", r[0]])); + return j; } - if ((pyjslib_slice(str, i, ( i + 2 ) ) == ">-") || (pyjslib_slice(str, i, ( i + 2 ) ) == "<-")) { - throw BadSyntax(this._thisDoc, this.lines, str, j, ">- ... -> syntax is obsolete."); + if((pyjslib_slice(str, i, (i + 2)) == ">-") || (pyjslib_slice(str, i, (i + 2)) == "<-")) { + throw BadSyntax(this._thisDoc, this.lines, str, j, ">- ... -> syntax is obsolete."); } return -1; -}; -__SinkParser.prototype.prop = function(str, i, res) { + }; + __SinkParser.prototype.prop = function (str, i, res) { return this.item(str, i, res); -}; -__SinkParser.prototype.item = function(str, i, res) { + }; + __SinkParser.prototype.item = function (str, i, res) { return this.path(str, i, res); -}; -__SinkParser.prototype.blankNode = function(uri) { + }; + __SinkParser.prototype.blankNode = function (uri) { return this._context.bnode(uri, this._reason2); -}; -__SinkParser.prototype.path = function(str, i, res) { + }; + __SinkParser.prototype.path = function (str, i, res) { /* Parse the path production. */ - + var j = this.nodeOrLiteral(str, i, res); - if ((j < 0)) { - return j; + if((j < 0)) { + return j; } - while (("!^.".indexOf(pyjslib_slice(str, j, ( j + 1 ) )) >= 0)) { - var ch = pyjslib_slice(str, j, ( j + 1 ) ); - if ((ch == ".")) { - var ahead = pyjslib_slice(str, ( j + 1 ) , ( j + 2 ) ); - if (!(ahead) || (_notNameChars.indexOf(ahead) >= 0) && (":?<[{(".indexOf(ahead) < 0)) { - break; - } + while(("!^.".indexOf(pyjslib_slice(str, j, (j + 1))) >= 0)) { + var ch = pyjslib_slice(str, j, (j + 1)); + if((ch == ".")) { + var ahead = pyjslib_slice(str, (j + 1), (j + 2)); + if(!(ahead) || (_notNameChars.indexOf(ahead) >= 0) && (":?<[{(".indexOf(ahead) < 0)) { + break; } - var subj = res.pop(); - var obj = this.blankNode(this.here(j)); - var j = this.node(str, ( j + 1 ) , res); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in middle of path syntax"); - } - var pred = res.pop(); - if ((ch == "^")) { - this.makeStatement(new pyjslib_Tuple([this._context, pred, obj, subj])); - } - else { - this.makeStatement(new pyjslib_Tuple([this._context, pred, subj, obj])); - } - res.push(obj); + } + var subj = res.pop(); + var obj = this.blankNode(this.here(j)); + var j = this.node(str, (j + 1), res); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in middle of path syntax"); + } + var pred = res.pop(); + if((ch == "^")) { + this.makeStatement(new pyjslib_Tuple([this._context, pred, obj, subj])); + } else { + this.makeStatement(new pyjslib_Tuple([this._context, pred, subj, obj])); + } + res.push(obj); } return j; -}; -__SinkParser.prototype.anonymousNode = function(ln) { + }; + __SinkParser.prototype.anonymousNode = function (ln) { /* Remember or generate a term for one of these _: anonymous nodes*/ - + var term = this._anonymousNodes[ln]; - if (term) { - return term; + if(term) { + return term; } var term = this._store.bnode(this._context, this._reason2); - this._anonymousNodes[ln] = ( term); + this._anonymousNodes[ln] = (term); return term; -}; -__SinkParser.prototype.node = function(str, i, res, subjectAlready) { - if (typeof subjectAlready == 'undefined') subjectAlready=null; + }; + __SinkParser.prototype.node = function (str, i, res, subjectAlready) { + if(typeof subjectAlready == 'undefined') subjectAlready = null; /* Parse the production. Space is now skipped once at the beginning instead of in multipe calls to self.skipSpace(). */ - + var subj = subjectAlready; var j = this.skipSpace(str, i); - if ((j < 0)) { - return j; + if((j < 0)) { + return j; } var i = j; - var ch = pyjslib_slice(str, i, ( i + 1 ) ); - if ((ch == "[")) { - var bnodeID = this.here(i); - var j = this.skipSpace(str, ( i + 1 ) ); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF after '['"); - } - if ((pyjslib_slice(str, j, ( j + 1 ) ) == "=")) { - var i = ( j + 1 ) ; - var objs = new pyjslib_List([]); - var j = this.objectList(str, i, objs); - - if ((j >= 0)) { - var subj = objs[0]; - if ((pyjslib_len(objs) > 1)) { - - var __obj = new pyjslib_Iterator(objs); - try { - while (true) { - var obj = __obj.next(); - - - this.makeStatement(new pyjslib_Tuple([this._context, this._store.sym(DAML_sameAs_URI), subj, obj])); - - } - } catch (e) { - if (e != StopIteration) { - throw e; - } - } - - } - var j = this.skipSpace(str, j); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when objectList expected after [ = "); - } - if ((pyjslib_slice(str, j, ( j + 1 ) ) == ";")) { - var j = ( j + 1 ) ; - } - } - else { - throw BadSyntax(this._thisDoc, this.lines, str, i, "objectList expected after [= "); + var ch = pyjslib_slice(str, i, (i + 1)); + if((ch == "[")) { + var bnodeID = this.here(i); + var j = this.skipSpace(str, (i + 1)); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF after '['"); + } + if((pyjslib_slice(str, j, (j + 1)) == "=")) { + var i = (j + 1); + var objs = new pyjslib_List([]); + var j = this.objectList(str, i, objs); + + if((j >= 0)) { + var subj = objs[0]; + if((pyjslib_len(objs) > 1)) { + + var __obj = new pyjslib_Iterator(objs); + try { + while(true) { + var obj = __obj.next(); + + + this.makeStatement(new pyjslib_Tuple([this._context, this._store.sym(DAML_sameAs_URI), subj, obj])); + + } + } catch(e) { + if(e != StopIteration) { + throw e; + } } + + } + var j = this.skipSpace(str, j); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when objectList expected after [ = "); + } + if((pyjslib_slice(str, j, (j + 1)) == ";")) { + var j = (j + 1); + } + } else { + throw BadSyntax(this._thisDoc, this.lines, str, i, "objectList expected after [= "); } - if ((subj == null)) { - var subj = this.blankNode(bnodeID); - } - var i = this.property_list(str, j, subj); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "property_list expected"); - } - var j = this.skipSpace(str, i); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when ']' expected after [ "); - } - if ((pyjslib_slice(str, j, ( j + 1 ) ) != "]")) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "']' expected"); - } - res.push(subj); - return ( j + 1 ) ; + } + if((subj == null)) { + var subj = this.blankNode(bnodeID); + } + var i = this.property_list(str, j, subj); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "property_list expected"); + } + var j = this.skipSpace(str, i); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when ']' expected after [ "); + } + if((pyjslib_slice(str, j, (j + 1)) != "]")) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "']' expected"); + } + res.push(subj); + return(j + 1); } - if ((ch == "{")) { - var ch2 = pyjslib_slice(str, ( i + 1 ) , ( i + 2 ) ); - if ((ch2 == "$")) { - i += 1; - var j = ( i + 1 ) ; - var mylist = new pyjslib_List([]); - var first_run = true; - while (1) { - var i = this.skipSpace(str, j); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '$}', found end."); - } - if ((pyjslib_slice(str, i, ( i + 2 ) ) == "$}")) { - var j = ( i + 2 ) ; - break; - } - if (!(first_run)) { - if ((pyjslib_slice(str, i, ( i + 1 ) ) == ",")) { - i += 1; - } - else { - throw BadSyntax(this._thisDoc, this.lines, str, i, "expected: ','"); - } - } - else { - var first_run = false; - } - var item = new pyjslib_List([]); - var j = this.item(str, i, item); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in set or '$}'"); - } - mylist.push(item[0]); - } - res.push(this._store.newSet(mylist, this._context)); - return j; - } - else { - var j = ( i + 1 ) ; - var oldParentContext = this._parentContext; - this._parentContext = this._context; - var parentAnonymousNodes = this._anonymousNodes; - var grandParentVariables = this._parentVariables; - this._parentVariables = this._variables; - this._anonymousNodes = new pyjslib_Dict([]); - this._variables = this._variables.slice(); - var reason2 = this._reason2; - this._reason2 = becauseSubexpression; - if ((subj == null)) { - var subj = this._store.formula(); - } - this._context = subj; - while (1) { - var i = this.skipSpace(str, j); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '}', found end."); - } - if ((pyjslib_slice(str, i, ( i + 1 ) ) == "}")) { - var j = ( i + 1 ) ; - break; - } - var j = this.directiveOrStatement(str, i); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "expected statement or '}'"); - } - } - this._anonymousNodes = parentAnonymousNodes; - this._variables = this._parentVariables; - this._parentVariables = grandParentVariables; - this._context = this._parentContext; - this._reason2 = reason2; - this._parentContext = oldParentContext; - res.push(subj.close()); - return j; - } - } - if ((ch == "(")) { - var thing_type = this._store.list; - var ch2 = pyjslib_slice(str, ( i + 1 ) , ( i + 2 ) ); - if ((ch2 == "$")) { - var thing_type = this._store.newSet; - i += 1; - } - var j = ( i + 1 ) ; + if((ch == "{")) { + var ch2 = pyjslib_slice(str, (i + 1), (i + 2)); + if((ch2 == "$")) { + i += 1; + var j = (i + 1); var mylist = new pyjslib_List([]); - while (1) { - var i = this.skipSpace(str, j); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "needed ')', found end."); + var first_run = true; + while(1) { + var i = this.skipSpace(str, j); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '$}', found end."); + } + if((pyjslib_slice(str, i, (i + 2)) == "$}")) { + var j = (i + 2); + break; + } + if(!(first_run)) { + if((pyjslib_slice(str, i, (i + 1)) == ",")) { + i += 1; + } else { + throw BadSyntax(this._thisDoc, this.lines, str, i, "expected: ','"); } - if ((pyjslib_slice(str, i, ( i + 1 ) ) == ")")) { - var j = ( i + 1 ) ; - break; - } - var item = new pyjslib_List([]); - var j = this.item(str, i, item); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in list or ')'"); - } - mylist.push(item[0]); + } else { + var first_run = false; + } + var item = new pyjslib_List([]); + var j = this.item(str, i, item); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in set or '$}'"); + } + mylist.push(item[0]); } - res.push(thing_type(mylist, this._context)); + res.push(this._store.newSet(mylist, this._context)); return j; + } else { + var j = (i + 1); + var oldParentContext = this._parentContext; + this._parentContext = this._context; + var parentAnonymousNodes = this._anonymousNodes; + var grandParentVariables = this._parentVariables; + this._parentVariables = this._variables; + this._anonymousNodes = new pyjslib_Dict([]); + this._variables = this._variables.slice(); + var reason2 = this._reason2; + this._reason2 = becauseSubexpression; + if((subj == null)) { + var subj = this._store.formula(); + } + this._context = subj; + while(1) { + var i = this.skipSpace(str, j); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '}', found end."); + } + if((pyjslib_slice(str, i, (i + 1)) == "}")) { + var j = (i + 1); + break; + } + var j = this.directiveOrStatement(str, i); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "expected statement or '}'"); + } + } + this._anonymousNodes = parentAnonymousNodes; + this._variables = this._parentVariables; + this._parentVariables = grandParentVariables; + this._context = this._parentContext; + this._reason2 = reason2; + this._parentContext = oldParentContext; + res.push(subj.close()); + return j; + } + } + if((ch == "(")) { + var thing_type = this._store.list; + var ch2 = pyjslib_slice(str, (i + 1), (i + 2)); + if((ch2 == "$")) { + var thing_type = this._store.newSet; + i += 1; + } + var j = (i + 1); + var mylist = new pyjslib_List([]); + while(1) { + var i = this.skipSpace(str, j); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "needed ')', found end."); + } + if((pyjslib_slice(str, i, (i + 1)) == ")")) { + var j = (i + 1); + break; + } + var item = new pyjslib_List([]); + var j = this.item(str, i, item); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in list or ')'"); + } + mylist.push(item[0]); + } + res.push(thing_type(mylist, this._context)); + return j; } var j = this.tok("this", str, i); - if ((j >= 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords."); - res.push(this._context); - return j; + if((j >= 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords."); + res.push(this._context); + return j; } var j = this.tok("true", str, i); - if ((j >= 0)) { - res.push(true); - return j; + if((j >= 0)) { + res.push(true); + return j; } var j = this.tok("false", str, i); - if ((j >= 0)) { - res.push(false); - return j; + if((j >= 0)) { + res.push(false); + return j; } - if ((subj == null)) { - var j = this.uri_ref2(str, i, res); - if ((j >= 0)) { - return j; - } + if((subj == null)) { + var j = this.uri_ref2(str, i, res); + if((j >= 0)) { + return j; + } } return -1; -}; -__SinkParser.prototype.property_list = function(str, i, subj) { + }; + __SinkParser.prototype.property_list = function (str, i, subj) { /* Parse property list Leaves the terminating punctuation in the buffer */ - - while (1) { - var j = this.skipSpace(str, i); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found when expected verb in property list"); - return j; - } - if ((pyjslib_slice(str, j, ( j + 2 ) ) == ":-")) { - var i = ( j + 2 ) ; - var res = new pyjslib_List([]); - var j = this.node(str, i, res, subj); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "bad {} or () or [] node after :- "); - } - var i = j; - continue; + + while(1) { + var j = this.skipSpace(str, i); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found when expected verb in property list"); + return j; + } + if((pyjslib_slice(str, j, (j + 2)) == ":-")) { + var i = (j + 2); + var res = new pyjslib_List([]); + var j = this.node(str, i, res, subj); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "bad {} or () or [] node after :- "); } var i = j; - var v = new pyjslib_List([]); - var j = this.verb(str, i, v); - if ((j <= 0)) { - return i; + continue; + } + var i = j; + var v = new pyjslib_List([]); + var j = this.verb(str, i, v); + if((j <= 0)) { + return i; + } + var objs = new pyjslib_List([]); + var i = this.objectList(str, j, objs); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "objectList expected"); + } + + var __obj = new pyjslib_Iterator(objs); + try { + while(true) { + var obj = __obj.next(); + + + var pairFudge = v[0]; + var dir = pairFudge[0]; + var sym = pairFudge[1]; + if((dir == "->")) { + this.makeStatement(new pyjslib_Tuple([this._context, sym, subj, obj])); + } else { + this.makeStatement(new pyjslib_Tuple([this._context, sym, obj, subj])); + } + } - var objs = new pyjslib_List([]); - var i = this.objectList(str, j, objs); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "objectList expected"); + } catch(e) { + if(e != StopIteration) { + throw e; } - - var __obj = new pyjslib_Iterator(objs); - try { - while (true) { - var obj = __obj.next(); - - - var pairFudge = v[0]; - var dir = pairFudge[0]; - var sym = pairFudge[1]; - if ((dir == "->")) { - this.makeStatement(new pyjslib_Tuple([this._context, sym, subj, obj])); - } - else { - this.makeStatement(new pyjslib_Tuple([this._context, sym, obj, subj])); - } - - } - } catch (e) { - if (e != StopIteration) { - throw e; - } - } - - var j = this.skipSpace(str, i); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in list of objects"); - return j; - } - if ((pyjslib_slice(str, i, ( i + 1 ) ) != ";")) { - return i; - } - var i = ( i + 1 ) ; + } + + var j = this.skipSpace(str, i); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in list of objects"); + return j; + } + if((pyjslib_slice(str, i, (i + 1)) != ";")) { + return i; + } + var i = (i + 1); } -}; -__SinkParser.prototype.commaSeparatedList = function(str, j, res, ofUris) { + }; + __SinkParser.prototype.commaSeparatedList = function (str, j, res, ofUris) { /* return value: -1 bad syntax; >1 new position in str res has things found appended @@ -859,86 +848,84 @@ __SinkParser.prototype.commaSeparatedList = function(str, j, res, ofUris) { Used to use a final value of the function to be called, e.g. this.bareWord but passing the function didn't work fo js converion pyjs */ - + var i = this.skipSpace(str, j); - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found expecting comma sep list"); + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found expecting comma sep list"); + return i; + } + if((str.charAt(i) == ".")) { + return j; + } + if(ofUris) { + var i = this.uri_ref2(str, i, res); + } else { + var i = this.bareWord(str, i, res); + } + if((i < 0)) { + return -1; + } + while(1) { + var j = this.skipSpace(str, i); + if((j < 0)) { + return j; + } + var ch = pyjslib_slice(str, j, (j + 1)); + if((ch != ",")) { + if((ch != ".")) { + return -1; + } + return j; + } + if(ofUris) { + var i = this.uri_ref2(str, (j + 1), res); + } else { + var i = this.bareWord(str, (j + 1), res); + } + if((i < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "bad list content"); return i; + } } - if ((str.charAt(i) == ".")) { - return j; - } - if (ofUris) { - var i = this.uri_ref2(str, i, res); - } - else { - var i = this.bareWord(str, i, res); - } - if ((i < 0)) { - return -1; - } - while (1) { - var j = this.skipSpace(str, i); - if ((j < 0)) { - return j; - } - var ch = pyjslib_slice(str, j, ( j + 1 ) ); - if ((ch != ",")) { - if ((ch != ".")) { - return -1; - } - return j; - } - if (ofUris) { - var i = this.uri_ref2(str, ( j + 1 ) , res); - } - else { - var i = this.bareWord(str, ( j + 1 ) , res); - } - if ((i < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "bad list content"); - return i; - } - } -}; -__SinkParser.prototype.objectList = function(str, i, res) { + }; + __SinkParser.prototype.objectList = function (str, i, res) { var i = this.object(str, i, res); - if ((i < 0)) { - return -1; + if((i < 0)) { + return -1; } - while (1) { - var j = this.skipSpace(str, i); - if ((j < 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found after object"); - return j; - } - if ((pyjslib_slice(str, j, ( j + 1 ) ) != ",")) { - return j; - } - var i = this.object(str, ( j + 1 ) , res); - if ((i < 0)) { - return i; - } + while(1) { + var j = this.skipSpace(str, i); + if((j < 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found after object"); + return j; + } + if((pyjslib_slice(str, j, (j + 1)) != ",")) { + return j; + } + var i = this.object(str, (j + 1), res); + if((i < 0)) { + return i; + } } -}; -__SinkParser.prototype.checkDot = function(str, i) { + }; + __SinkParser.prototype.checkDot = function (str, i) { var j = this.skipSpace(str, i); - if ((j < 0)) { - return j; + if((j < 0)) { + return j; } - if ((pyjslib_slice(str, j, ( j + 1 ) ) == ".")) { - return ( j + 1 ) ; + if((pyjslib_slice(str, j, (j + 1)) == ".")) { + return(j + 1); } - if ((pyjslib_slice(str, j, ( j + 1 ) ) == "}")) { - return j; + if((pyjslib_slice(str, j, (j + 1)) == "}")) { + return j; } - if ((pyjslib_slice(str, j, ( j + 1 ) ) == "]")) { - return j; + if((pyjslib_slice(str, j, (j + 1)) == "]")) { + return j; } throw BadSyntax(this._thisDoc, this.lines, str, j, "expected '.' or '}' or ']' at end of statement"); return i; -}; -__SinkParser.prototype.uri_ref2 = function(str, i, res) { + }; + __SinkParser.prototype.uri_ref2 = function (str, i, res) { /* Generate uri from n3 representation. @@ -946,479 +933,452 @@ __SinkParser.prototype.uri_ref2 = function(str, i, res) { NS and local name is now used though I prefer inserting a '#' to make the namesapces look more like what XML folks expect. */ - + var qn = new pyjslib_List([]); var j = this.qname(str, i, qn); - if ((j >= 0)) { - var pairFudge = qn[0]; - var pfx = pairFudge[0]; - var ln = pairFudge[1]; - if ((pfx == null)) { - assertFudge(0, "not used?"); - var ns = ( this._baseURI + ADDED_HASH ) ; + if((j >= 0)) { + var pairFudge = qn[0]; + var pfx = pairFudge[0]; + var ln = pairFudge[1]; + if((pfx == null)) { + assertFudge(0, "not used?"); + var ns = (this._baseURI + ADDED_HASH); + } else { + var ns = this._bindings[pfx]; + if(!(ns)) { + if((pfx == "_")) { + res.push(this.anonymousNode(ln)); + return j; + } + throw BadSyntax(this._thisDoc, this.lines, str, i, (("Prefix " + pfx) + " not bound.")); } - else { - var ns = this._bindings[pfx]; - if (!(ns)) { - if ((pfx == "_")) { - res.push(this.anonymousNode(ln)); - return j; - } - throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Prefix " + pfx ) + " not bound." ) ); - } - } - var symb = this._store.sym( ( ns + ln ) ); - if (($rdf.Util.ArrayIndexOf(this._variables, symb) >= 0)) { - res.push(this._variables[symb]); - } - else { - res.push(symb); - } - return j; + } + var symb = this._store.sym((ns + ln)); + if(($rdf.Util.ArrayIndexOf(this._variables, symb) >= 0)) { + res.push(this._variables[symb]); + } else { + res.push(symb); + } + return j; } var i = this.skipSpace(str, i); - if ((i < 0)) { - return -1; + if((i < 0)) { + return -1; } - if ((str.charAt(i) == "?")) { - var v = new pyjslib_List([]); - var j = this.variable(str, i, v); - if ((j > 0)) { - res.push(v[0]); - return j; - } - return -1; - } - else if ((str.charAt(i) == "<")) { - var i = ( i + 1 ) ; - var st = i; - while ((i < pyjslib_len(str))) { - if ((str.charAt(i) == ">")) { - var uref = pyjslib_slice(str, st, i); - if (this._baseURI) { - var uref = uripath_join(this._baseURI, uref); - } - else { - assertFudge((uref.indexOf(":") >= 0), "With no base URI, cannot deal with relative URIs"); - } - if ((pyjslib_slice(str, ( i - 1 ) , i) == "#") && !((pyjslib_slice(uref, -1, null) == "#"))) { - var uref = ( uref + "#" ) ; - } - var symb = this._store.sym(uref); - if (($rdf.Util.ArrayIndexOf(this._variables,symb) >= 0)) { - res.push(this._variables[symb]); - } - else { - res.push(symb); - } - return ( i + 1 ) ; - } - var i = ( i + 1 ) ; - } - throw BadSyntax(this._thisDoc, this.lines, str, j, "unterminated URI reference"); - } - else if (this.keywordsSet) { - var v = new pyjslib_List([]); - var j = this.bareWord(str, i, v); - if ((j < 0)) { - return -1; - } - if (($rdf.Util.ArrayIndexOf(this.keywords, v[0]) >= 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Keyword \"" + v[0] ) + "\" not allowed here." ) ); - } - res.push(this._store.sym( ( this._bindings[""] + v[0] ) )); + if((str.charAt(i) == "?")) { + var v = new pyjslib_List([]); + var j = this.variable(str, i, v); + if((j > 0)) { + res.push(v[0]); return j; - } - else { + } + return -1; + } else if((str.charAt(i) == "<")) { + var i = (i + 1); + var st = i; + while((i < pyjslib_len(str))) { + if((str.charAt(i) == ">")) { + var uref = pyjslib_slice(str, st, i); + if(this._baseURI) { + var uref = uripath_join(this._baseURI, uref); + } else { + assertFudge((uref.indexOf(":") >= 0), "With no base URI, cannot deal with relative URIs"); + } + if((pyjslib_slice(str, (i - 1), i) == "#") && !((pyjslib_slice(uref, -1, null) == "#"))) { + var uref = (uref + "#"); + } + var symb = this._store.sym(uref); + if(($rdf.Util.ArrayIndexOf(this._variables, symb) >= 0)) { + res.push(this._variables[symb]); + } else { + res.push(symb); + } + return(i + 1); + } + var i = (i + 1); + } + throw BadSyntax(this._thisDoc, this.lines, str, j, "unterminated URI reference"); + } else if(this.keywordsSet) { + var v = new pyjslib_List([]); + var j = this.bareWord(str, i, v); + if((j < 0)) { return -1; + } + if(($rdf.Util.ArrayIndexOf(this.keywords, v[0]) >= 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, (("Keyword \"" + v[0]) + "\" not allowed here.")); + } + res.push(this._store.sym((this._bindings[""] + v[0]))); + return j; + } else { + return -1; } -}; -__SinkParser.prototype.skipSpace = function(str, i) { + }; + __SinkParser.prototype.skipSpace = function (str, i) { /* Skip white space, newlines and comments. return -1 if EOF, else position of first non-ws character*/ var tmp = str; var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000'; - for (var j = (i ? i : 0); j < str.length; j++) { - if (whitespace.indexOf(str.charAt(j)) === -1) { - if( str.charAt(j)==='#' ) { - str = str.slice(i).replace(/^[^\n]*\n/,""); - i=0; - j=-1; - } else { - break; - } + for(var j = (i ? i : 0); j < str.length; j++) { + if(whitespace.indexOf(str.charAt(j)) === -1) { + if(str.charAt(j) === '#') { + str = str.slice(i).replace(/^[^\n]*\n/, ""); + i = 0; + j = -1; + } else { + break; } + } } var val = (tmp.length - str.length) + j; - if( val === tmp.length ) { - return -1; + if(val === tmp.length) { + return -1; } return val; -}; -__SinkParser.prototype.variable = function(str, i, res) { + }; + __SinkParser.prototype.variable = function (str, i, res) { /* ?abc -> variable(:abc) */ - + var j = this.skipSpace(str, i); - if ((j < 0)) { - return -1; + if((j < 0)) { + return -1; } - if ((pyjslib_slice(str, j, ( j + 1 ) ) != "?")) { - return -1; + if((pyjslib_slice(str, j, (j + 1)) != "?")) { + return -1; } - var j = ( j + 1 ) ; + var j = (j + 1); var i = j; - if (("0123456789-".indexOf(str.charAt(j)) >= 0)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, ( ( "Varible name can't start with '" + str.charAt(j) ) + "s'" ) ); - return -1; + if(("0123456789-".indexOf(str.charAt(j)) >= 0)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, (("Varible name can't start with '" + str.charAt(j)) + "s'")); + return -1; } - while ((i < pyjslib_len(str)) && (_notNameChars.indexOf(str.charAt(i)) < 0)) { - var i = ( i + 1 ) ; + while((i < pyjslib_len(str)) && (_notNameChars.indexOf(str.charAt(i)) < 0)) { + var i = (i + 1); } - if ((this._parentContext == null)) { - throw BadSyntax(this._thisDoc, this.lines, str, j, ( "Can't use ?xxx syntax for variable in outermost level: " + pyjslib_slice(str, ( j - 1 ) , i) ) ); + if((this._parentContext == null)) { + throw BadSyntax(this._thisDoc, this.lines, str, j, ("Can't use ?xxx syntax for variable in outermost level: " + pyjslib_slice(str, (j - 1), i))); } res.push(this._store.variable(pyjslib_slice(str, j, i))); return i; -}; -__SinkParser.prototype.bareWord = function(str, i, res) { + }; + __SinkParser.prototype.bareWord = function (str, i, res) { /* abc -> :abc */ - + var j = this.skipSpace(str, i); - if ((j < 0)) { - return -1; + if((j < 0)) { + return -1; } var ch = str.charAt(j); - if (("0123456789-".indexOf(ch) >= 0)) { - return -1; + if(("0123456789-".indexOf(ch) >= 0)) { + return -1; } - if ((_notNameChars.indexOf(ch) >= 0)) { - return -1; + if((_notNameChars.indexOf(ch) >= 0)) { + return -1; } var i = j; - while ((i < pyjslib_len(str)) && (_notNameChars.indexOf(str.charAt(i)) < 0)) { - var i = ( i + 1 ) ; + while((i < pyjslib_len(str)) && (_notNameChars.indexOf(str.charAt(i)) < 0)) { + var i = (i + 1); } res.push(pyjslib_slice(str, j, i)); return i; -}; -__SinkParser.prototype.qname = function(str, i, res) { + }; + __SinkParser.prototype.qname = function (str, i, res) { /* xyz:def -> ('xyz', 'def') If not in keywords and keywordsSet: def -> ('', 'def') :def -> ('', 'def') */ - + var i = this.skipSpace(str, i); - if ((i < 0)) { - return -1; + if((i < 0)) { + return -1; } var c = str.charAt(i); - if (("0123456789-+".indexOf(c) >= 0)) { - return -1; + if(("0123456789-+".indexOf(c) >= 0)) { + return -1; } - if ((_notNameChars.indexOf(c) < 0)) { - var ln = c; - var i = ( i + 1 ) ; - while ((i < pyjslib_len(str))) { - var c = str.charAt(i); - if ((_notNameChars.indexOf(c) < 0)) { - var ln = ( ln + c ) ; - var i = ( i + 1 ) ; - } - else { - break; - } + if((_notNameChars.indexOf(c) < 0)) { + var ln = c; + var i = (i + 1); + while((i < pyjslib_len(str))) { + var c = str.charAt(i); + if((_notNameChars.indexOf(c) < 0)) { + var ln = (ln + c); + var i = (i + 1); + } else { + break; } + } + } else { + var ln = ""; } - else { - var ln = ""; - } - if ((i < pyjslib_len(str)) && (str.charAt(i) == ":")) { - var pfx = ln; - var i = ( i + 1 ) ; - var ln = ""; - while ((i < pyjslib_len(str))) { - var c = str.charAt(i); - if ((_notNameChars.indexOf(c) < 0)) { - var ln = ( ln + c ) ; - var i = ( i + 1 ) ; - } - else { - break; - } + if((i < pyjslib_len(str)) && (str.charAt(i) == ":")) { + var pfx = ln; + var i = (i + 1); + var ln = ""; + while((i < pyjslib_len(str))) { + var c = str.charAt(i); + if((_notNameChars.indexOf(c) < 0)) { + var ln = (ln + c); + var i = (i + 1); + } else { + break; } - res.push(new pyjslib_Tuple([pfx, ln])); + } + res.push(new pyjslib_Tuple([pfx, ln])); + return i; + } else { + if(ln && this.keywordsSet && ($rdf.Util.ArrayIndexOf(this.keywords, ln) < 0)) { + res.push(new pyjslib_Tuple(["", ln])); return i; + } + return -1; } - else { - if (ln && this.keywordsSet && ($rdf.Util.ArrayIndexOf(this.keywords, ln) < 0)) { - res.push(new pyjslib_Tuple(["", ln])); - return i; - } - return -1; - } -}; -__SinkParser.prototype.object = function(str, i, res) { + }; + __SinkParser.prototype.object = function (str, i, res) { var j = this.subject(str, i, res); - if ((j >= 0)) { + if((j >= 0)) { + return j; + } else { + var j = this.skipSpace(str, i); + if((j < 0)) { + return -1; + } else { + var i = j; + } + if((str.charAt(i) == "\"")) { + if((pyjslib_slice(str, i, (i + 3)) == "\"\"\"")) { + var delim = "\"\"\""; + } else { + var delim = "\""; + } + var i = (i + pyjslib_len(delim)); + var pairFudge = this.strconst(str, i, delim); + var j = pairFudge[0]; + var s = pairFudge[1]; + res.push(this._store.literal(s)); + diag_progress("New string const ", s, j); return j; + } else { + return -1; + } } - else { - var j = this.skipSpace(str, i); - if ((j < 0)) { - return -1; - } - else { - var i = j; - } - if ((str.charAt(i) == "\"")) { - if ((pyjslib_slice(str, i, ( i + 3 ) ) == "\"\"\"")) { - var delim = "\"\"\""; - } - else { - var delim = "\""; - } - var i = ( i + pyjslib_len(delim) ) ; - var pairFudge = this.strconst(str, i, delim); - var j = pairFudge[0]; - var s = pairFudge[1]; - res.push(this._store.literal(s)); - diag_progress("New string const ", s, j); - return j; - } - else { - return -1; - } - } -}; -__SinkParser.prototype.nodeOrLiteral = function(str, i, res) { + }; + __SinkParser.prototype.nodeOrLiteral = function (str, i, res) { var j = this.node(str, i, res); - if ((j >= 0)) { + if((j >= 0)) { + return j; + } else { + var j = this.skipSpace(str, i); + if((j < 0)) { + return -1; + } else { + var i = j; + } + var ch = str.charAt(i); + if(("-+0987654321".indexOf(ch) >= 0)) { + number_syntax.lastIndex = 0; + var m = number_syntax.exec(str.slice(i)); + if((m == null)) { + throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad number syntax"); + } + var j = (i + number_syntax.lastIndex); + var val = pyjslib_slice(str, i, j); + if((val.indexOf("e") >= 0)) { + res.push(this._store.literal(parseFloat(val), undefined, this._store.sym(FLOAT_DATATYPE))); + } else if((pyjslib_slice(str, i, j).indexOf(".") >= 0)) { + res.push(this._store.literal(parseFloat(val), undefined, this._store.sym(DECIMAL_DATATYPE))); + } else { + res.push(this._store.literal(parseInt(val), undefined, this._store.sym(INTEGER_DATATYPE))); + } return j; + } + if((str.charAt(i) == "\"")) { + if((pyjslib_slice(str, i, (i + 3)) == "\"\"\"")) { + var delim = "\"\"\""; + } else { + var delim = "\""; + } + var i = (i + pyjslib_len(delim)); + var dt = null; + var pairFudge = this.strconst(str, i, delim); + var j = pairFudge[0]; + var s = pairFudge[1]; + var lang = null; + if((pyjslib_slice(str, j, (j + 1)) == "@")) { + langcode.lastIndex = 0; + + var m = langcode.exec(str.slice((j + 1))); + if((m == null)) { + throw BadSyntax(this._thisDoc, startline, str, i, "Bad language code syntax on string literal, after @"); + } + var i = ((langcode.lastIndex + j) + 1); + + var lang = pyjslib_slice(str, (j + 1), i); + var j = i; + } + if((pyjslib_slice(str, j, (j + 2)) == "^^")) { + var res2 = new pyjslib_List([]); + var j = this.uri_ref2(str, (j + 2), res2); + var dt = res2[0]; + } + res.push(this._store.literal(s, lang, dt)); + return j; + } else { + return -1; + } } - else { - var j = this.skipSpace(str, i); - if ((j < 0)) { - return -1; - } - else { - var i = j; - } - var ch = str.charAt(i); - if (("-+0987654321".indexOf(ch) >= 0)) { - number_syntax.lastIndex = 0; - var m = number_syntax.exec(str.slice(i)); - if ((m == null)) { - throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad number syntax"); - } - var j = ( i + number_syntax.lastIndex ) ; - var val = pyjslib_slice(str, i, j); - if ((val.indexOf("e") >= 0)) { - res.push(this._store.literal(parseFloat(val), undefined, this._store.sym(FLOAT_DATATYPE))); - } - else if ((pyjslib_slice(str, i, j).indexOf(".") >= 0)) { - res.push(this._store.literal(parseFloat(val), undefined, this._store.sym(DECIMAL_DATATYPE))); - } - else { - res.push(this._store.literal(parseInt(val), undefined, this._store.sym(INTEGER_DATATYPE))); - } - return j; - } - if ((str.charAt(i) == "\"")) { - if ((pyjslib_slice(str, i, ( i + 3 ) ) == "\"\"\"")) { - var delim = "\"\"\""; - } - else { - var delim = "\""; - } - var i = ( i + pyjslib_len(delim) ) ; - var dt = null; - var pairFudge = this.strconst(str, i, delim); - var j = pairFudge[0]; - var s = pairFudge[1]; - var lang = null; - if ((pyjslib_slice(str, j, ( j + 1 ) ) == "@")) { - langcode.lastIndex = 0; - - var m = langcode.exec(str.slice( ( j + 1 ) )); - if ((m == null)) { - throw BadSyntax(this._thisDoc, startline, str, i, "Bad language code syntax on string literal, after @"); - } - var i = ( ( langcode.lastIndex + j ) + 1 ) ; - - var lang = pyjslib_slice(str, ( j + 1 ) , i); - var j = i; - } - if ((pyjslib_slice(str, j, ( j + 2 ) ) == "^^")) { - var res2 = new pyjslib_List([]); - var j = this.uri_ref2(str, ( j + 2 ) , res2); - var dt = res2[0]; - } - res.push(this._store.literal(s, lang, dt)); - return j; - } - else { - return -1; - } - } -}; -__SinkParser.prototype.strconst = function(str, i, delim) { + }; + __SinkParser.prototype.strconst = function (str, i, delim) { /* parse an N3 string constant delimited by delim. return index, val */ - + var j = i; var ustr = ""; var startline = this.lines; - while ((j < pyjslib_len(str))) { - var i = ( j + pyjslib_len(delim) ) ; - if ((pyjslib_slice(str, j, i) == delim)) { - return new pyjslib_Tuple([i, ustr]); + while((j < pyjslib_len(str))) { + var i = (j + pyjslib_len(delim)); + if((pyjslib_slice(str, j, i) == delim)) { + return new pyjslib_Tuple([i, ustr]); + } + if((str.charAt(j) == "\"")) { + var ustr = (ustr + "\""); + var j = (j + 1); + continue; + } + interesting.lastIndex = 0; + var m = interesting.exec(str.slice(j)); + if(!(m)) { + throw BadSyntax(this._thisDoc, startline, str, j, ((("Closing quote missing in string at ^ in " + pyjslib_slice(str, (j - 20), j)) + "^") + pyjslib_slice(str, j, (j + 20)))); + } + var i = ((j + interesting.lastIndex) - 1); + var ustr = (ustr + pyjslib_slice(str, j, i)); + var ch = str.charAt(i); + if((ch == "\"")) { + var j = i; + continue; + } else if((ch == "\r")) { + var j = (i + 1); + continue; + } else if((ch == "\n")) { + if((delim == "\"")) { + throw BadSyntax(this._thisDoc, startline, str, i, "newline found in string literal"); } - if ((str.charAt(j) == "\"")) { - var ustr = ( ustr + "\"" ) ; - var j = ( j + 1 ) ; - continue; + this.lines = (this.lines + 1); + var ustr = (ustr + ch); + var j = (i + 1); + this.previousLine = this.startOfLine; + this.startOfLine = j; + } else if((ch == "\\")) { + var j = (i + 1); + var ch = pyjslib_slice(str, j, (j + 1)); + if(!(ch)) { + throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal (2)"); } - interesting.lastIndex = 0; - var m = interesting.exec(str.slice(j)); - if (!(m)) { - throw BadSyntax(this._thisDoc, startline, str, j, ( ( ( "Closing quote missing in string at ^ in " + pyjslib_slice(str, ( j - 20 ) , j) ) + "^" ) + pyjslib_slice(str, j, ( j + 20 ) ) ) ); - } - var i = ( ( j + interesting.lastIndex ) - 1 ) ; - var ustr = ( ustr + pyjslib_slice(str, j, i) ) ; - var ch = str.charAt(i); - if ((ch == "\"")) { - var j = i; - continue; - } - else if ((ch == "\r")) { - var j = ( i + 1 ) ; - continue; - } - else if ((ch == "\n")) { - if ((delim == "\"")) { - throw BadSyntax(this._thisDoc, startline, str, i, "newline found in string literal"); - } - this.lines = ( this.lines + 1 ) ; - var ustr = ( ustr + ch ) ; - var j = ( i + 1 ) ; - this.previousLine = this.startOfLine; - this.startOfLine = j; - } - else if ((ch == "\\")) { - var j = ( i + 1 ) ; - var ch = pyjslib_slice(str, j, ( j + 1 ) ); - if (!(ch)) { - throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal (2)"); - } - var k = string_find("abfrtvn\\\"", ch); - if ((k >= 0)) { - var uch = "\a\b\f\r\t\v\n\\\"".charAt(k); - var ustr = ( ustr + uch ) ; - var j = ( j + 1 ) ; - } - else if ((ch == "u")) { - var pairFudge = this.uEscape(str, ( j + 1 ) , startline); - var j = pairFudge[0]; - var ch = pairFudge[1]; - var ustr = ( ustr + ch ) ; - } - else if ((ch == "U")) { - var pairFudge = this.UEscape(str, ( j + 1 ) , startline); - var j = pairFudge[0]; - var ch = pairFudge[1]; - var ustr = ( ustr + ch ) ; - } - else { - throw BadSyntax(this._thisDoc, this.lines, str, i, "bad escape"); - } + var k = string_find("abfrtvn\\\"", ch); + if((k >= 0)) { + var uch = "\a\b\f\r\t\v\n\\\"".charAt(k); + var ustr = (ustr + uch); + var j = (j + 1); + } else if((ch == "u")) { + var pairFudge = this.uEscape(str, (j + 1), startline); + var j = pairFudge[0]; + var ch = pairFudge[1]; + var ustr = (ustr + ch); + } else if((ch == "U")) { + var pairFudge = this.UEscape(str, (j + 1), startline); + var j = pairFudge[0]; + var ch = pairFudge[1]; + var ustr = (ustr + ch); + } else { + throw BadSyntax(this._thisDoc, this.lines, str, i, "bad escape"); } + } } throw BadSyntax(this._thisDoc, this.lines, str, i, "unterminated string literal"); -}; -__SinkParser.prototype.uEscape = function(str, i, startline) { + }; + __SinkParser.prototype.uEscape = function (str, i, startline) { var j = i; var count = 0; var value = 0; - while ((count < 4)) { - var chFudge = pyjslib_slice(str, j, ( j + 1 ) ); - var ch = chFudge.toLowerCase(); - var j = ( j + 1 ) ; - if ((ch == "")) { - throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)"); - } - var k = string_find("0123456789abcdef", ch); - if ((k < 0)) { - throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape"); - } - var value = ( ( value * 16 ) + k ) ; - var count = ( count + 1 ) ; + while((count < 4)) { + var chFudge = pyjslib_slice(str, j, (j + 1)); + var ch = chFudge.toLowerCase(); + var j = (j + 1); + if((ch == "")) { + throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)"); + } + var k = string_find("0123456789abcdef", ch); + if((k < 0)) { + throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape"); + } + var value = ((value * 16) + k); + var count = (count + 1); } var uch = String.fromCharCode(value); return new pyjslib_Tuple([j, uch]); -}; -__SinkParser.prototype.UEscape = function(str, i, startline) { + }; + __SinkParser.prototype.UEscape = function (str, i, startline) { var j = i; var count = 0; var value = "\\U"; - while ((count < 8)) { - var chFudge = pyjslib_slice(str, j, ( j + 1 ) ); - var ch = chFudge.toLowerCase(); - var j = ( j + 1 ) ; - if ((ch == "")) { - throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)"); - } - var k = string_find("0123456789abcdef", ch); - if ((k < 0)) { - throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape"); - } - var value = ( value + ch ) ; - var count = ( count + 1 ) ; + while((count < 8)) { + var chFudge = pyjslib_slice(str, j, (j + 1)); + var ch = chFudge.toLowerCase(); + var j = (j + 1); + if((ch == "")) { + throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)"); + } + var k = string_find("0123456789abcdef", ch); + if((k < 0)) { + throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape"); + } + var value = (value + ch); + var count = (count + 1); } - var uch = stringFromCharCode( ( ( "0x" + pyjslib_slice(value, 2, 10) ) - 0 ) ); + var uch = stringFromCharCode((("0x" + pyjslib_slice(value, 2, 10)) - 0)); return new pyjslib_Tuple([j, uch]); -}; + }; -function BadSyntax(uri, lines, str, i, why) { - return ( ( ( ( ( ( ( ( "Line " + ( lines + 1 ) ) + " of <" ) + uri ) + ">: Bad syntax: " ) + why ) + "\nat: \"" ) + pyjslib_slice(str, i, ( i + 30 ) ) ) + "\"" ) ; -} + function BadSyntax(uri, lines, str, i, why) { + return(((((((("Line " + (lines + 1)) + " of <") + uri) + ">: Bad syntax: ") + why) + "\nat: \"") + pyjslib_slice(str, i, (i + 30))) + "\""); + } -function stripCR(str) { + function stripCR(str) { var res = ""; - + var __ch = new pyjslib_Iterator(str); try { - while (true) { - var ch = __ch.next(); - - - if ((ch != "\r")) { - var res = ( res + ch ) ; - } - - } - } catch (e) { - if (e != StopIteration) { - throw e; + while(true) { + var ch = __ch.next(); + + + if((ch != "\r")) { + var res = (res + ch); } + + } + } catch(e) { + if(e != StopIteration) { + throw e; + } } - + return res; -} + } -function dummyWrite(x) { -} + function dummyWrite(x) { + } -return SinkParser; + return SinkParser; -}(); +}(); \ No newline at end of file diff --git a/chrome/content/zotero/xpcom/rdf/rdfparser.js b/chrome/content/zotero/xpcom/rdf/rdfparser.js index 8ab32a545e..bbfa0f10e5 100644 --- a/chrome/content/zotero/xpcom/rdf/rdfparser.js +++ b/chrome/content/zotero/xpcom/rdf/rdfparser.js @@ -62,536 +62,503 @@ * @param {RDFStore} store An RDFStore object */ $rdf.RDFParser = function (store) { - var RDFParser = {}; + var RDFParser = {}; - /** Standard namespaces that we know how to handle @final - * @member RDFParser - */ - RDFParser['ns'] = {'RDF': - "http://www.w3.org/1999/02/22-rdf-syntax-ns#", - 'RDFS': - "http://www.w3.org/2000/01/rdf-schema#"} - /** DOM Level 2 node type magic numbers @final - * @member RDFParser - */ - RDFParser['nodeType'] = {'ELEMENT': 1, 'ATTRIBUTE': 2, 'TEXT': 3, - 'CDATA_SECTION': 4, 'ENTITY_REFERENCE': 5, - 'ENTITY': 6, 'PROCESSING_INSTRUCTION': 7, - 'COMMENT': 8, 'DOCUMENT': 9, 'DOCUMENT_TYPE': 10, - 'DOCUMENT_FRAGMENT': 11, 'NOTATION': 12} + /** Standard namespaces that we know how to handle @final + * @member RDFParser + */ + RDFParser['ns'] = { + 'RDF': "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + 'RDFS': "http://www.w3.org/2000/01/rdf-schema#" + } + /** DOM Level 2 node type magic numbers @final + * @member RDFParser + */ + RDFParser['nodeType'] = { + 'ELEMENT': 1, + 'ATTRIBUTE': 2, + 'TEXT': 3, + 'CDATA_SECTION': 4, + 'ENTITY_REFERENCE': 5, + 'ENTITY': 6, + 'PROCESSING_INSTRUCTION': 7, + 'COMMENT': 8, + 'DOCUMENT': 9, + 'DOCUMENT_TYPE': 10, + 'DOCUMENT_FRAGMENT': 11, + 'NOTATION': 12 + } - /** - * Frame class for namespace and base URI lookups - * Base lookups will always resolve because the parser knows - * the default base. - * - * @private - */ - this['frameFactory'] = function (parser, parent, element) { - return {'NODE': 1, - 'ARC': 2, - 'parent': parent, - 'parser': parser, - 'store': parser['store'], - 'element': element, - 'lastChild': 0, - 'base': null, - 'lang': null, - 'node': null, - 'nodeType': null, - 'listIndex': 1, - 'rdfid': null, - 'datatype': null, - 'collection': false, + /** + * Frame class for namespace and base URI lookups + * Base lookups will always resolve because the parser knows + * the default base. + * + * @private + */ + this['frameFactory'] = function (parser, parent, element) { + return { + 'NODE': 1, + 'ARC': 2, + 'parent': parent, + 'parser': parser, + 'store': parser['store'], + 'element': element, + 'lastChild': 0, + 'base': null, + 'lang': null, + 'node': null, + 'nodeType': null, + 'listIndex': 1, + 'rdfid': null, + 'datatype': null, + 'collection': false, - /** Terminate the frame and notify the store that we're done */ - 'terminateFrame': function () { - if (this['collection']) { - this['node']['close']() - } - }, - - /** Add a symbol of a certain type to the this frame */ - 'addSymbol': function (type, uri) { - uri = $rdf.Util.uri.join(uri, this['base']) - this['node'] = this['store']['sym'](uri) - this['nodeType'] = type - }, - - /** Load any constructed triples into the store */ - 'loadTriple': function () { - if (this['parent']['parent']['collection']) { - this['parent']['parent']['node']['append'](this['node']) - } - else { - this['store']['add'](this['parent']['parent']['node'], - this['parent']['node'], - this['node'], - this['parser']['why']) - } - if (this['parent']['rdfid'] != null) { // reify - var triple = this['store']['sym']( - $rdf.Util.uri.join("#"+this['parent']['rdfid'], - this['base'])) - this['store']['add'](triple, - this['store']['sym']( - RDFParser['ns']['RDF'] - +"type"), - this['store']['sym']( - RDFParser['ns']['RDF'] - +"Statement"), - this['parser']['why']) - this['store']['add'](triple, - this['store']['sym']( - RDFParser['ns']['RDF'] - +"subject"), - this['parent']['parent']['node'], - this['parser']['why']) - this['store']['add'](triple, - this['store']['sym']( - RDFParser['ns']['RDF'] - +"predicate"), - this['parent']['node'], - this['parser']['why']) - this['store']['add'](triple, - this['store']['sym']( - RDFParser['ns']['RDF'] - +"object"), - this['node'], - this['parser']['why']) - } - }, + /** Terminate the frame and notify the store that we're done */ + 'terminateFrame': function () { + if(this['collection']) { + this['node']['close']() + } + }, - /** Check if it's OK to load a triple */ - 'isTripleToLoad': function () { - return (this['parent'] != null - && this['parent']['parent'] != null - && this['nodeType'] == this['NODE'] - && this['parent']['nodeType'] == this['ARC'] - && this['parent']['parent']['nodeType'] - == this['NODE']) - }, + /** Add a symbol of a certain type to the this frame */ + 'addSymbol': function (type, uri) { + uri = $rdf.Util.uri.join(uri, this['base']) + this['node'] = this['store']['sym'](uri) + this['nodeType'] = type + }, - /** Add a symbolic node to this frame */ - 'addNode': function (uri) { - this['addSymbol'](this['NODE'],uri) - if (this['isTripleToLoad']()) { - this['loadTriple']() - } - }, - - /** Add a collection node to this frame */ - 'addCollection': function () { - this['nodeType'] = this['NODE'] - this['node'] = this['store']['collection']() - this['collection'] = true - if (this['isTripleToLoad']()) { - this['loadTriple']() - } - }, - - /** Add a collection arc to this frame */ - 'addCollectionArc': function () { - this['nodeType'] = this['ARC'] - }, - - /** Add a bnode to this frame */ - 'addBNode': function (id) { - if (id != null) { - if (this['parser']['bnodes'][id] != null) { - this['node'] = this['parser']['bnodes'][id] - } else { - this['node'] = this['parser']['bnodes'][id] = this['store']['bnode']() - } - } else { this['node'] = this['store']['bnode']() } - - this['nodeType'] = this['NODE'] - if (this['isTripleToLoad']()) { - this['loadTriple']() - } - }, - - /** Add an arc or property to this frame */ - 'addArc': function (uri) { - if (uri == RDFParser['ns']['RDF']+"li") { - uri = RDFParser['ns']['RDF']+"_"+this['parent']['listIndex']++ - } - this['addSymbol'](this['ARC'], uri) - }, - - /** Add a literal to this frame */ - 'addLiteral': function (value) { - if (this['parent']['datatype']) { - this['node'] = this['store']['literal']( - value, "", this['store']['sym']( - this['parent']['datatype'])) - } - else { - this['node'] = this['store']['literal']( - value, this['lang']) - } - this['nodeType'] = this['NODE'] - if (this['isTripleToLoad']()) { - this['loadTriple']() - } - } - } - } - - //from the OpenLayers source .. needed to get around IE problems. - this['getAttributeNodeNS'] = function(node, uri, name) { - var attributeNode = null; - if(node.getAttributeNodeNS) { - attributeNode = node.getAttributeNodeNS(uri, name); + /** Load any constructed triples into the store */ + 'loadTriple': function () { + if(this['parent']['parent']['collection']) { + this['parent']['parent']['node']['append'](this['node']) } else { - var attributes = node.attributes; - var potentialNode, fullName; - for(var i=0; i= 0) + result = result + el['nodeName'].split(":")[1]; + else + result = result + el['nodeName']; + } + return result; + } + var dig = true // if we'll dig down in the tree on the next iter + while(frame['parent']) { + var dom = frame['element'] + var attrs = dom['attributes'] + + if(dom['nodeType'] == RDFParser['nodeType']['TEXT'] + || dom['nodeType'] == RDFParser['nodeType']['CDATA_SECTION']) { + //we have a literal + frame['addLiteral'](dom['nodeValue']) + } else if(elementURI(dom) != RDFParser['ns']['RDF'] + "RDF") { + // not root + if(frame['parent'] && frame['parent']['collection']) { + // we're a collection element + frame['addCollectionArc']() + frame = this['buildFrame'](frame, frame['element']) + frame['parent']['element'] = null + } + if(!frame['parent'] || !frame['parent']['nodeType'] + || frame['parent']['nodeType'] == frame['ARC']) { + // we need a node + var about = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'], "about") + var rdfid = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'], "ID") + if(about && rdfid) { + throw new Error("RDFParser: " + dom['nodeName'] + + " has both rdf:id and rdf:about." + " Halting. Only one of these" + + " properties may be specified on a" + " node."); + } + if(about == null && rdfid) { + frame['addNode']("#" + rdfid['nodeValue']) + dom['removeAttributeNode'](rdfid) + } else if(about == null && rdfid == null) { + var bnid = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'], "nodeID") + if(bnid) { + frame['addBNode'](bnid['nodeValue']) + dom['removeAttributeNode'](bnid) + } else { + frame['addBNode']() } - if( el['namespaceURI'] ) { - result = result + el['namespaceURI']; + } else { + frame['addNode'](about['nodeValue']) + dom['removeAttributeNode'](about) + } + + // Typed nodes + var rdftype = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'], "type") + if(RDFParser['ns']['RDF'] + "Description" != elementURI(dom)) { + rdftype = { + 'nodeValue': elementURI(dom) + } + } + if(rdftype != null) { + this['store']['add'](frame['node'], + this['store']['sym'](RDFParser['ns']['RDF'] + "type"), + this['store']['sym']( + $rdf.Util.uri.join( + rdftype['nodeValue'], + frame['base'])), + this['why']) + if(rdftype['nodeName']) { + dom['removeAttributeNode'](rdftype) + } + } + + // Property Attributes + for(var x = attrs['length'] - 1; x >= 0; x--) { + this['store']['add'](frame['node'], + this['store']['sym'](elementURI(attrs[x])), + this['store']['literal']( + attrs[x]['nodeValue'], + frame['lang']), + this['why']) + } + } else { + // we should add an arc (or implicit bnode+arc) + frame['addArc'](elementURI(dom)) + + // save the arc's rdf:ID if it has one + if(this['reify']) { + var rdfid = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'], "ID") + if(rdfid) { + frame['rdfid'] = rdfid['nodeValue'] + dom['removeAttributeNode'](rdfid) + } + } + + var parsetype = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'], "parseType") + var datatype = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'], "datatype") + if(datatype) { + frame['datatype'] = datatype['nodeValue'] + dom['removeAttributeNode'](datatype) + } + + if(parsetype) { + var nv = parsetype['nodeValue'] + if(nv == "Literal") { + frame['datatype'] = RDFParser['ns']['RDF'] + "XMLLiteral" + // (this.buildFrame(frame)).addLiteral(dom) + // should work but doesn't + frame = this['buildFrame'](frame) + frame['addLiteral'](dom) + dig = false + } else if(nv == "Resource") { + frame = this['buildFrame'](frame, frame['element']) + frame['parent']['element'] = null + frame['addBNode']() + } else if(nv == "Collection") { + frame = this['buildFrame'](frame, frame['element']) + frame['parent']['element'] = null + frame['addCollection']() + } + dom['removeAttributeNode'](parsetype) + } + + if(attrs['length'] != 0) { + var resource = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'], "resource") + var bnid = this['getAttributeNodeNS'](dom, RDFParser['ns']['RDF'], "nodeID") + + frame = this['buildFrame'](frame) + if(resource) { + frame['addNode'](resource['nodeValue']) + dom['removeAttributeNode'](resource) + } else { + if(bnid) { + frame['addBNode'](bnid['nodeValue']) + dom['removeAttributeNode'](bnid) + } else { + frame['addBNode']() + } + } + + for(var x = attrs['length'] - 1; x >= 0; x--) { + var f = this['buildFrame'](frame) + f['addArc'](elementURI(attrs[x])) + if(elementURI(attrs[x]) == RDFParser['ns']['RDF'] + "type") { + (this['buildFrame'](f))['addNode']( + attrs[x]['nodeValue']) + } else { + (this['buildFrame'](f))['addLiteral']( + attrs[x]['nodeValue']) + } + } + } else if(dom['childNodes']['length'] == 0) { + (this['buildFrame'](frame))['addLiteral']("") + } } - if( el['localName'] ) { - result = result + el['localName']; - } else if( el['nodeName'] ) { - if(el['nodeName'].indexOf(":")>=0) - result = result + el['nodeName'].split(":")[1]; - else - result = result + el['nodeName']; + } // rdf:RDF + // dig dug + dom = frame['element'] + while(frame['parent']) { + var pframe = frame + while(dom == null) { + frame = frame['parent'] + dom = frame['element'] } - return result; - } - var dig = true // if we'll dig down in the tree on the next iter + var candidate = dom['childNodes'][frame['lastChild']] + if(candidate == null || !dig) { + frame['terminateFrame']() + if(!(frame = frame['parent'])) { + break + } // done + dom = frame['element'] + dig = true + } else if((candidate['nodeType'] != RDFParser['nodeType']['ELEMENT'] + && candidate['nodeType'] != RDFParser['nodeType']['TEXT'] + && candidate['nodeType'] != RDFParser['nodeType']['CDATA_SECTION']) + || ((candidate['nodeType'] == RDFParser['nodeType']['TEXT'] + || candidate['nodeType'] == RDFParser['nodeType']['CDATA_SECTION']) + && dom['childNodes']['length'] != 1)) { + frame['lastChild']++ + } else { + // not a leaf + frame['lastChild']++; + frame = this['buildFrame'](pframe, dom['childNodes'][frame['lastChild'] - 1]) + break + } + } + } // while + } - while (frame['parent']) { - var dom = frame['element'] - var attrs = dom['attributes'] + /** + * Cleans out state from a previous parse run + * @private + */ + this['cleanParser'] = function () { + this['bnodes'] = {} + this['why'] = null + } - if (dom['nodeType'] - == RDFParser['nodeType']['TEXT'] - || dom['nodeType'] - == RDFParser['nodeType']['CDATA_SECTION']) {//we have a literal - frame['addLiteral'](dom['nodeValue']) - } - else if (elementURI(dom) - != RDFParser['ns']['RDF']+"RDF") { // not root - if (frame['parent'] && frame['parent']['collection']) { - // we're a collection element - frame['addCollectionArc']() - frame = this['buildFrame'](frame,frame['element']) - frame['parent']['element'] = null - } - if (!frame['parent'] || !frame['parent']['nodeType'] - || frame['parent']['nodeType'] == frame['ARC']) { - // we need a node - var about =this['getAttributeNodeNS'](dom, - RDFParser['ns']['RDF'],"about") - var rdfid =this['getAttributeNodeNS'](dom, - RDFParser['ns']['RDF'],"ID") - if (about && rdfid) { - throw new Error("RDFParser: " + dom['nodeName'] - + " has both rdf:id and rdf:about." - + " Halting. Only one of these" - + " properties may be specified on a" - + " node."); - } - if (about == null && rdfid) { - frame['addNode']("#"+rdfid['nodeValue']) - dom['removeAttributeNode'](rdfid) - } - else if (about == null && rdfid == null) { - var bnid = this['getAttributeNodeNS'](dom, - RDFParser['ns']['RDF'],"nodeID") - if (bnid) { - frame['addBNode'](bnid['nodeValue']) - dom['removeAttributeNode'](bnid) - } else { frame['addBNode']() } - } - else { - frame['addNode'](about['nodeValue']) - dom['removeAttributeNode'](about) - } - - // Typed nodes - var rdftype = this['getAttributeNodeNS'](dom, - RDFParser['ns']['RDF'],"type") - if (RDFParser['ns']['RDF']+"Description" - != elementURI(dom)) { - rdftype = {'nodeValue': elementURI(dom)} - } - if (rdftype != null) { - this['store']['add'](frame['node'], - this['store']['sym']( - RDFParser['ns']['RDF']+"type"), - this['store']['sym']( - $rdf.Util.uri.join( - rdftype['nodeValue'], - frame['base'])), - this['why']) - if (rdftype['nodeName']){ - dom['removeAttributeNode'](rdftype) - } - } - - // Property Attributes - for (var x = attrs['length']-1; x >= 0; x--) { - this['store']['add'](frame['node'], - this['store']['sym']( - elementURI(attrs[x])), - this['store']['literal']( - attrs[x]['nodeValue'], - frame['lang']), - this['why']) - } - } - else { // we should add an arc (or implicit bnode+arc) - frame['addArc'](elementURI(dom)) - - // save the arc's rdf:ID if it has one - if (this['reify']) { - var rdfid = this['getAttributeNodeNS'](dom, - RDFParser['ns']['RDF'],"ID") - if (rdfid) { - frame['rdfid'] = rdfid['nodeValue'] - dom['removeAttributeNode'](rdfid) - } - } - - var parsetype = this['getAttributeNodeNS'](dom, - RDFParser['ns']['RDF'],"parseType") - var datatype = this['getAttributeNodeNS'](dom, - RDFParser['ns']['RDF'],"datatype") - if (datatype) { - frame['datatype'] = datatype['nodeValue'] - dom['removeAttributeNode'](datatype) - } - - if (parsetype) { - var nv = parsetype['nodeValue'] - if (nv == "Literal") { - frame['datatype'] - = RDFParser['ns']['RDF']+"XMLLiteral" - // (this.buildFrame(frame)).addLiteral(dom) - // should work but doesn't - frame = this['buildFrame'](frame) - frame['addLiteral'](dom) - dig = false - } - else if (nv == "Resource") { - frame = this['buildFrame'](frame,frame['element']) - frame['parent']['element'] = null - frame['addBNode']() - } - else if (nv == "Collection") { - frame = this['buildFrame'](frame,frame['element']) - frame['parent']['element'] = null - frame['addCollection']() - } - dom['removeAttributeNode'](parsetype) - } - - if (attrs['length'] != 0) { - var resource = this['getAttributeNodeNS'](dom, - RDFParser['ns']['RDF'],"resource") - var bnid = this['getAttributeNodeNS'](dom, - RDFParser['ns']['RDF'],"nodeID") - - frame = this['buildFrame'](frame) - if (resource) { - frame['addNode'](resource['nodeValue']) - dom['removeAttributeNode'](resource) - } else { - if (bnid) { - frame['addBNode'](bnid['nodeValue']) - dom['removeAttributeNode'](bnid) - } else { frame['addBNode']() } - } - - for (var x = attrs['length']-1; x >= 0; x--) { - var f = this['buildFrame'](frame) - f['addArc'](elementURI(attrs[x])) - if (elementURI(attrs[x]) - ==RDFParser['ns']['RDF']+"type"){ - (this['buildFrame'](f))['addNode']( - attrs[x]['nodeValue']) - } else { - (this['buildFrame'](f))['addLiteral']( - attrs[x]['nodeValue']) - } - } - } - else if (dom['childNodes']['length'] == 0) { - (this['buildFrame'](frame))['addLiteral']("") - } - } - } // rdf:RDF - - // dig dug - dom = frame['element'] - while (frame['parent']) { - var pframe = frame - while (dom == null) { - frame = frame['parent'] - dom = frame['element'] - } - var candidate = dom['childNodes'][frame['lastChild']] - if (candidate == null || !dig) { - frame['terminateFrame']() - if (!(frame = frame['parent'])) { break } // done - dom = frame['element'] - dig = true - } - else if ((candidate['nodeType'] - != RDFParser['nodeType']['ELEMENT'] - && candidate['nodeType'] - != RDFParser['nodeType']['TEXT'] - && candidate['nodeType'] - != RDFParser['nodeType']['CDATA_SECTION']) - || ((candidate['nodeType'] - == RDFParser['nodeType']['TEXT'] - || candidate['nodeType'] - == RDFParser['nodeType']['CDATA_SECTION']) - && dom['childNodes']['length'] != 1)) { - frame['lastChild']++ - } - else { // not a leaf - frame['lastChild']++ - frame = this['buildFrame'](pframe, - dom['childNodes'][frame['lastChild']-1]) - break - } - } - } // while + /** + * Builds scope frame + * @private + */ + this['buildFrame'] = function (parent, element) { + var frame = this['frameFactory'](this, parent, element) + if(parent) { + frame['base'] = parent['base'] + frame['lang'] = parent['lang'] + } + if(element == null + || element['nodeType'] == RDFParser['nodeType']['TEXT'] + || element['nodeType'] == RDFParser['nodeType']['CDATA_SECTION']) { + return frame } - /** - * Cleans out state from a previous parse run - * @private - */ - this['cleanParser'] = function () { - this['bnodes'] = {} - this['why'] = null + var attrs = element['attributes'] + + var base = element['getAttributeNode']("xml:base") + if(base != null) { + frame['base'] = base['nodeValue'] + element['removeAttribute']("xml:base") + } + var lang = element['getAttributeNode']("xml:lang") + if(lang != null) { + frame['lang'] = lang['nodeValue'] + element['removeAttribute']("xml:lang") } - /** - * Builds scope frame - * @private - */ - this['buildFrame'] = function (parent, element) { - var frame = this['frameFactory'](this,parent,element) - if (parent) { - frame['base'] = parent['base'] - frame['lang'] = parent['lang'] - } - if (element == null - || element['nodeType'] == RDFParser['nodeType']['TEXT'] - || element['nodeType'] == RDFParser['nodeType']['CDATA_SECTION']) { - return frame - } - - var attrs = element['attributes'] - - var base = element['getAttributeNode']("xml:base") - if (base != null) { - frame['base'] = base['nodeValue'] - element['removeAttribute']("xml:base") - } - var lang = element['getAttributeNode']("xml:lang") - if (lang != null) { - frame['lang'] = lang['nodeValue'] - element['removeAttribute']("xml:lang") - } - - // remove all extraneous xml and xmlns attributes - for (var x = attrs['length']-1; x >= 0; x--) { - if (attrs[x]['nodeName']['substr'](0,3) == "xml") { - if (attrs[x].name.slice(0,6)=='xmlns:') { - var uri = attrs[x].nodeValue; - // alert('base for namespac attr:'+this.base); - if (this.base) uri = $rdf.Util.uri.join(uri, this.base); - this.store.setPrefixForURI(attrs[x].name.slice(6), - uri); - } -// alert('rdfparser: xml atribute: '+attrs[x].name) //@@ - element['removeAttributeNode'](attrs[x]) - } - } - return frame + // remove all extraneous xml and xmlns attributes + for(var x = attrs['length'] - 1; x >= 0; x--) { + if(attrs[x]['nodeName']['substr'](0, 3) == "xml") { + if(attrs[x].name.slice(0, 6) == 'xmlns:') { + var uri = attrs[x].nodeValue; + // alert('base for namespac attr:'+this.base); + if(this.base) uri = $rdf.Util.uri.join(uri, this.base); + this.store.setPrefixForURI(attrs[x].name.slice(6), uri); + } + // alert('rdfparser: xml atribute: '+attrs[x].name) //@@ + element['removeAttributeNode'](attrs[x]) + } } -} + return frame + } +} \ No newline at end of file diff --git a/chrome/content/zotero/xpcom/rdf/serialize.js b/chrome/content/zotero/xpcom/rdf/serialize.js index 9181293ef2..3e28a6d3fe 100644 --- a/chrome/content/zotero/xpcom/rdf/serialize.js +++ b/chrome/content/zotero/xpcom/rdf/serialize.js @@ -1,162 +1,167 @@ /* Serialization of RDF Graphs -** -** Tim Berners-Lee 2006 -** This is or was http://dig.csail.mit.edu/2005/ajar/ajaw/js/rdf/serialize.js -** -** Bug: can't serialize http://data.semanticweb.org/person/abraham-bernstein/rdf -** in XML (from mhausenblas) -*/ - + ** + ** Tim Berners-Lee 2006 + ** This is or was http://dig.csail.mit.edu/2005/ajar/ajaw/js/rdf/serialize.js + ** + ** Bug: can't serialize http://data.semanticweb.org/person/abraham-bernstein/rdf + ** in XML (from mhausenblas) + */ // @@@ Check the whole toStr thing tosee whetehr it still makes sense -- tbl // -$rdf.Serializer = function() { +$rdf.Serializer = function () { -var __Serializer = function( store ){ - this.flags = ""; - this.base = null; - this.prefixes = []; - this.keywords = ['a']; // The only one we generate at the moment - this.prefixchars = "abcdefghijklmnopqustuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - this.incoming = null; // Array not calculated yet - this.formulas = []; // remebering original formulae from hashes - this.store = store; + var __Serializer = function (store) { + this.flags = ""; + this.base = null; + this.prefixes = []; + this.keywords = ['a']; // The only one we generate at the moment + this.prefixchars = "abcdefghijklmnopqustuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + this.incoming = null; // Array not calculated yet + this.formulas = []; // remebering original formulae from hashes + this.store = store; - /* pass */ -} - -var Serializer = function( store ) {return new __Serializer( store )}; - -__Serializer.prototype.setBase = function(base) - { this.base = base }; - -__Serializer.prototype.setFlags = function(flags) - { this.flags = flags?flags: '' }; - - -__Serializer.prototype.toStr = function(x) { - var s = x.toNT(); - if (x.termType == 'formula') { - this.formulas[s] = x; // remember as reverse does not work - } - return s; -}; - -__Serializer.prototype.fromStr = function(s) { - if (s[0] == '{') { - var x = this.formulas[s]; - if (!x) alert('No formula object for '+s) - return x; - } - return this.store.fromNT(s); -}; - - - - - -/* Accumulate Namespaces -** -** These are only hints. If two overlap, only one gets used -** There is therefore no guarantee in general. -*/ - -__Serializer.prototype.suggestPrefix = function(prefix, uri) { - this.prefixes[uri] = prefix; -} - -// Takes a namespace -> prefix map -__Serializer.prototype.suggestNamespaces = function(namespaces) { - for (var px in namespaces) { - this.prefixes[namespaces[px]] = px; + /* pass */ } -} -// Make up an unused prefix for a random namespace -__Serializer.prototype.makeUpPrefix = function(uri) { + var Serializer = function (store) { + return new __Serializer(store) + }; + + __Serializer.prototype.setBase = function (base) { + this.base = base + }; + + __Serializer.prototype.setFlags = function (flags) { + this.flags = flags ? flags : '' + }; + + + __Serializer.prototype.toStr = function (x) { + var s = x.toNT(); + if(x.termType == 'formula') { + this.formulas[s] = x; // remember as reverse does not work + } + return s; + }; + + __Serializer.prototype.fromStr = function (s) { + if(s[0] == '{') { + var x = this.formulas[s]; + if(!x) alert('No formula object for ' + s) + return x; + } + return this.store.fromNT(s); + }; + + + + + + /* Accumulate Namespaces + ** + ** These are only hints. If two overlap, only one gets used + ** There is therefore no guarantee in general. + */ + + __Serializer.prototype.suggestPrefix = function (prefix, uri) { + this.prefixes[uri] = prefix; + } + + // Takes a namespace -> prefix map + __Serializer.prototype.suggestNamespaces = function (namespaces) { + for(var px in namespaces) { + this.prefixes[namespaces[px]] = px; + } + } + + // Make up an unused prefix for a random namespace + __Serializer.prototype.makeUpPrefix = function (uri) { var p = uri; var namespaces = []; var pok; var sz = this; - + function canUse(pp) { - if (namespaces[pp]) return false; // already used - - sz.prefixes[uri] = pp; - pok = pp; - return true + if(namespaces[pp]) return false; // already used + sz.prefixes[uri] = pp; + pok = pp; + return true } - for (var ns in sz.prefixes) { - namespaces[sz.prefixes[ns]] = ns; // reverse index + for(var ns in sz.prefixes) { + namespaces[sz.prefixes[ns]] = ns; // reverse index } - if ('#/'.indexOf(p[p.length-1]) >= 0) p = p.slice(0, -1); + if('#/'.indexOf(p[p.length - 1]) >= 0) p = p.slice(0, -1); var slash = p.lastIndexOf('/'); - if (slash >= 0) p = p.slice(slash+1); + if(slash >= 0) p = p.slice(slash + 1); var i = 0; - while (i < p.length) - if (sz.prefixchars.indexOf(p[i])) i++; else break; - p = p.slice(0,i); - if (p.length < 6 && canUse(p)) return pok; // exact i sbest - if (canUse(p.slice(0,3))) return pok; - if (canUse(p.slice(0,2))) return pok; - if (canUse(p.slice(0,4))) return pok; - if (canUse(p.slice(0,1))) return pok; - if (canUse(p.slice(0,5))) return pok; - for (var i=0;; i++) if (canUse(p.slice(0,3)+i)) return pok; -} + while(i < p.length) + if(sz.prefixchars.indexOf(p[i])) + i++; + else + break; + p = p.slice(0, i); + if(p.length < 6 && canUse(p)) return pok; // exact i sbest + if(canUse(p.slice(0, 3))) return pok; + if(canUse(p.slice(0, 2))) return pok; + if(canUse(p.slice(0, 4))) return pok; + if(canUse(p.slice(0, 1))) return pok; + if(canUse(p.slice(0, 5))) return pok; + for(var i = 0;; i++) if(canUse(p.slice(0, 3) + i)) return pok; + } -// Todo: -// - Sort the statements by subject, pred, object -// - do stuff about the docu first and then (or first) about its primary topic. - -__Serializer.prototype.rootSubjects = function(sts) { + // Todo: + // - Sort the statements by subject, pred, object + // - do stuff about the docu first and then (or first) about its primary topic. + __Serializer.prototype.rootSubjects = function (sts) { var incoming = {}; var subjects = {}; var sz = this; var allBnodes = {}; -/* This scan is to find out which nodes will have to be the roots of trees -** in the serialized form. This will be any symbols, and any bnodes -** which hve more or less than one incoming arc, and any bnodes which have -** one incoming arc but it is an uninterrupted loop of such nodes back to itself. -** This should be kept linear time with repect to the number of statements. -** Note it does not use any indexing of the store. -*/ + /* This scan is to find out which nodes will have to be the roots of trees + ** in the serialized form. This will be any symbols, and any bnodes + ** which hve more or less than one incoming arc, and any bnodes which have + ** one incoming arc but it is an uninterrupted loop of such nodes back to itself. + ** This should be kept linear time with repect to the number of statements. + ** Note it does not use any indexing of the store. + */ tabulator.log.debug('serialize.js Find bnodes with only one incoming arc\n') - for (var i = 0; i?@[\\]^`{|}~"; -__Serializer.prototype._notNameChars = - ( __Serializer.prototype._notQNameChars + ":" ) ; + __Serializer.prototype._notQNameChars = "\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~"; + __Serializer.prototype._notNameChars = (__Serializer.prototype._notQNameChars + ":"); - -__Serializer.prototype.statementsToN3 = function(sts) { + + __Serializer.prototype.statementsToN3 = function (sts) { var indent = 4; var width = 80; var sz = this; var namespaceCounts = []; // which have been used - var predMap = { - 'http://www.w3.org/2002/07/owl#sameAs': '=', - 'http://www.w3.org/2000/10/swap/log#implies': '=>', - 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type': 'a' + 'http://www.w3.org/2002/07/owl#sameAs': '=', + 'http://www.w3.org/2000/10/swap/log#implies': '=>', + 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type': 'a' } - - - + + + ////////////////////////// Arrange the bits of text - - var spaces=function(n) { - var s=''; - for(var i=0; i=0) { - str = str.slice(0,-1) + branch + '\n'; // slip punct'n on end - lastLength += 1; - continue; - } else if ("])}".indexOf(branch) >=0) { - str = str.slice(0,-1) + ' ' + branch + '\n'; - lastLength += 2; - continue; - } - } - if (lastLength < (indent*level+4)) { // continue - str = str.slice(0,-1) + ' ' + branch + '\n'; - lastLength += branch.length + 1; - } else { - var line = spaces(indent*level) +branch; - str += line +'\n'; - lastLength = line.length; - } - - } else { // not string + if(substr) lastLength = 10000; + str += substr; + } + if(typeof branch == 'string') { + if(branch.length == '1' && str.slice(-1) == '\n') { + if(",.;".indexOf(branch) >= 0) { + str = str.slice(0, -1) + branch + '\n'; // slip punct'n on end + lastLength += 1; + continue; + } else if("])}".indexOf(branch) >= 0) { + str = str.slice(0, -1) + ' ' + branch + '\n'; + lastLength += 2; + continue; + } } + if(lastLength < (indent * level + 4)) { // continue + str = str.slice(0, -1) + ' ' + branch + '\n'; + lastLength += branch.length + 1; + } else { + var line = spaces(indent * level) + branch; + str += line + '\n'; + lastLength = line.length; + } + + } else { // not string + } } return str; - }; + }; ////////////////////////////////////////////// Structure for N3 - - + // Convert a set of statements into a nested tree of lists and strings function statementListToTree(statements) { - // print('Statement tree for '+statements.length); - var res = []; - var stats = sz.rootSubjects(statements); - var roots = stats.roots; - var results = [] - for (var i=0; i= 0 && sz.flags.indexOf('p') < 0) { // Can split at namespace + var canSplit = true; + for(var k = j + 1; k < uri.length; k++) { + if(__Serializer.prototype._notNameChars.indexOf(uri[k]) >= 0) { + canSplit = false; + break; + } } - if (j >= 0 && sz.flags.indexOf('p') < 0) { // Can split at namespace - var canSplit = true; - for (var k=j+1; k=0) { - canSplit = false; break; - } - } - if (canSplit) { - var localid = uri.slice(j+1); - var namesp = uri.slice(0,j+1); - if (sz.defaultNamespace && sz.defaultNamespace == namesp - && sz.flags.indexOf('d') < 0) {// d -> suppress default - if (sz.flags.indexOf('k') >= 0 && - sz.keyords.indexOf(localid) <0) - return localid; - return ':' + localid; - } - var prefix = sz.prefixes[namesp]; - if (prefix) { - namespaceCounts[namesp] = true; - return prefix + ':' + localid; - } - if (uri.slice(0, j) == sz.base) - return '<#' + localid + '>'; - // Fall though if can't do qname - } + if(canSplit) { + var localid = uri.slice(j + 1); + var namesp = uri.slice(0, j + 1); + if(sz.defaultNamespace + && sz.defaultNamespace == namesp + && sz.flags.indexOf('d') < 0) { // d -> suppress default + if(sz.flags.indexOf('k') >= 0 + && sz.keyords.indexOf(localid) < 0) + return localid; + return ':' + localid; + } + var prefix = sz.prefixes[namesp]; + if(prefix) { + namespaceCounts[namesp] = true; + return prefix + ':' + localid; + } + if(uri.slice(0, j) == sz.base) + return '<#' + localid + '>'; + // Fall though if can't do qname } - if (sz.flags.indexOf('r') < 0 && sz.base) - uri = $rdf.Util.uri.refTo(sz.base, uri); - else if (sz.flags.indexOf('u') >= 0) - uri = backslashUify(uri); - else uri = hexify(uri); - return '<'+uri+'>'; + } + if(sz.flags.indexOf('r') < 0 && sz.base) + uri = $rdf.Util.uri.refTo(sz.base, uri); + else if(sz.flags.indexOf('u') >= 0) + uri = backslashUify(uri); + else uri = hexify(uri); + return '<' + uri + '>'; } - + function prefixDirectives() { - var str = ''; - if (sz.defaultNamespace) - str += '@prefix : <'+sz.defaultNamespace+'>.\n'; - for (var ns in namespaceCounts) { - str += '@prefix ' + sz.prefixes[ns] + ': <'+ns+'>.\n'; - } - return str + '\n'; + var str = ''; + if(sz.defaultNamespace) + str += '@prefix : <' + sz.defaultNamespace + '>.\n'; + for(var ns in namespaceCounts) { + str += '@prefix ' + sz.prefixes[ns] + ': <' + ns + '>.\n'; + } + return str + '\n'; } - + // stringToN3: String escaping for N3 // var forbidden1 = new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm); var forbidden3 = new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm); + function stringToN3(str, flags) { - if (!flags) flags = "e"; - var res = '', i=0, j=0; - var delim; - var forbidden; - if (str.length > 20 // Long enough to make sense - && str.slice(-1) != '"' // corner case' - && flags.indexOf('n') <0 // Force single line - && (str.indexOf('\n') >0 || str.indexOf('"') > 0)) { - delim = '"""'; - forbidden = forbidden3; + if(!flags) flags = "e"; + var res = '', i = 0, j = 0; + var delim; + var forbidden; + if(str.length > 20 // Long enough to make sense + && str.slice(-1) != '"' // corner case' + && flags.indexOf('n') < 0 // Force single line + && (str.indexOf('\n') > 0 || str.indexOf('"') > 0)) { + delim = '"""'; + forbidden = forbidden3; + } else { + delim = '"'; + forbidden = forbidden1; + } + for(i = 0; i < str.length;) { + forbidden.lastIndex = 0; + var m = forbidden.exec(str.slice(i)); + if(m == null) break; + j = i + forbidden.lastIndex - 1; + res += str.slice(i, j); + var ch = str[j]; + if(ch == '"' && delim == '"""' && str.slice(j, j + 3) != '"""') { + res += ch; } else { - delim = '"'; - forbidden = forbidden1; - } - for(i=0; i= 0) { - res += "\\" + 'bfrtvn\\"'[k]; - } else { - if (flags.indexOf('e')>=0) { - res += '\\u' + ('000'+ - ch.charCodeAt(0).toString(16).toLowerCase()).slice(-4) - } else { // no 'e' flag - res += ch; - } - } + var k = '\b\f\r\t\v\n\\"'.indexOf(ch); // No escaping of bell (7)? + if(k >= 0) { + res += "\\" + 'bfrtvn\\"' [k]; + } else { + if(flags.indexOf('e') >= 0) { + res += '\\u' + ('000' + ch.charCodeAt(0).toString(16).toLowerCase()).slice(-4) + } else { // no 'e' flag + res += ch; } - i = j+1; + } } - return delim + res + str.slice(i) + delim + i = j + 1; + } + return delim + res + str.slice(i) + delim } // Body of toN3: - var tree = statementListToTree(sts); return prefixDirectives() + treeToString(tree, -1); - -} -// String ecaping utilities + } -function hexify(str) { // also used in parser -// var res = ''; -// for (var i=0; i126 || k<33) -// res += '%' + ('0'+n.toString(16)).slice(-2); // convert to upper? -// else -// res += str[i]; -// } -// return res; - return encodeURI(str); -} + // String ecaping utilities + function hexify(str) { // also used in parser + // var res = ''; + // for (var i=0; i126 || k<33) + // res += '%' + ('0'+n.toString(16)).slice(-2); // convert to upper? + // else + // res += str[i]; + // } + // return res; + return encodeURI(str); + } -function backslashUify(str) { + function backslashUify(str) { var res = '', k; - for (var i=0; i65535) - res += '\\U' + ('00000000'+n.toString(16)).slice(-8); // convert to upper? - else if (k>126) - res += '\\u' + ('0000'+n.toString(16)).slice(-4); - else - res += str[i]; + for(var i = 0; i < str.length; i++) { + k = str.charCodeAt(i); + if(k > 65535) + res += '\\U' + ('00000000' + n.toString(16)).slice(-8); // convert to upper? + else if(k > 126) + res += '\\u' + ('0000' + n.toString(16)).slice(-4); + else + res += str[i]; } return res; -} + } -//////////////////////////////////////////////// XML serialization - -__Serializer.prototype.statementsToXML = function(sts) { + //////////////////////////////////////////////// XML serialization + __Serializer.prototype.statementsToXML = function (sts) { var indent = 4; var width = 80; var sz = this; @@ -592,276 +596,273 @@ __Serializer.prototype.statementsToXML = function(sts) { namespaceCounts['http://www.w3.org/1999/02/22-rdf-syntax-ns#'] = true; ////////////////////////// Arrange the bits of XML text - - var spaces=function(n) { - var s=''; - for(var i=0; i bb[0]) { - return 1; - } else if (aa[0] < bb[0]) { - return -1; - } else if ("undefined" !== typeof aa[1] && "undefined" !== typeof bb[1]) { - if (parseInt(aa[1], 10) > parseInt(bb[1], 10)) { - return 1; - } else if (parseInt(aa[1], 10) < parseInt(bb[1], 10)) { - return -1; - } - } - return 0; - }); - - for (var i=0; i', - subjectXMLTree(st.object, stats), - '']); - } else { - results = results.concat(['<'+ t +' rdf:nodeID="' - +st.object.toNT().slice(2)+'"/>']); - } - break; - case 'symbol': - results = results.concat(['<'+ t +' rdf:resource="' - + relURI(st.object)+'"/>']); - break; - case 'literal': - results = results.concat(['<'+ t - + (st.object.dt ? ' rdf:datatype="'+escapeForXML(st.object.dt.uri)+'"' : '') - + (st.object.lang ? ' xml:lang="'+st.object.lang+'"' : '') - + '>' + escapeForXML(st.object.value) - + '']); - break; - case 'collection': - results = results.concat(['<'+ t +' rdf:parseType="Collection">', - collectionXMLTree(st.object, stats), - '']); - break; - default: - throw "Can't serialize object of type "+st.object.termType +" into XML"; - } // switch - } - } - - var tag = type ? qname(type) : 'rdf:Description'; - - var attrs = ''; - if (subject.termType == 'bnode') { - if(sz.incoming[subject].length != 1) { // not an anonymous bnode - attrs = ' rdf:nodeID="'+subject.toNT().slice(2)+'"'; - } - } else { - attrs = ' rdf:about="'+ relURI(subject)+'"'; + const liPrefix = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#_'; + var results = []; + var type = null, t, st; + var sts = stats.subjects[sz.toStr(subject)]; // relevant statements + // Sort only on the predicate, leave the order at object + // level undisturbed. This leaves multilingual content in + // the order of entry (for partner literals), which helps + // readability. + // + // For the predicate sort, we attempt to split the uri + // as a hint to the sequence, as sequenced items seems + // to be of the form http://example.com#_1, http://example.com#_2, + // et cetera. Probably not the most optimal of fixes, but + // it does work. + sts.sort(function (a, b) { + var aa = a.predicate.uri.split('#_'); + var bb = a.predicate.uri.split('#_'); + if(aa[0] > bb[0]) { + return 1; + } else if(aa[0] < bb[0]) { + return -1; + } else if("undefined" !== typeof aa[1] && "undefined" !== typeof bb[1]) { + if(parseInt(aa[1], 10) > parseInt(bb[1], 10)) { + return 1; + } else if(parseInt(aa[1], 10) < parseInt(bb[1], 10)) { + return -1; + } } + return 0; + }); - return [ '<' + tag + attrs + '>' ].concat([results]).concat([""]); + for(var i = 0; i < sts.length; i++) { + st = sts[i]; + if(st.predicate.uri == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' && !type && st.object.termType == "symbol") { + // look for a type + type = st.object; + } else { + // see whether predicate can be replaced with "li" + if(st.predicate.uri.substr(0, liPrefix.length) == liPrefix) { + var number = st.predicate.uri.substr(liPrefix.length); + // make sure these are actually numeric list items + var intNumber = parseInt(number); + if(number == intNumber.toString()) { + // was numeric; don't need to worry about ordering since we've already + // sorted the statements + st.predicate = $rdf.Symbol('http://www.w3.org/1999/02/22-rdf-syntax-ns#li'); + } + } + t = qname(st.predicate); + switch(st.object.termType) { + case 'bnode': + if(sz.incoming[st.object].length == 1) { + results = results.concat(['<' + t + '>', + subjectXMLTree(st.object, stats), + '']); + } else { + results = results.concat(['<' + t + ' rdf:nodeID="' + + st.object.toNT().slice(2) + '"/>']); + } + break; + case 'symbol': + results = results.concat(['<' + t + ' rdf:resource="' + + relURI(st.object) + '"/>']); + break; + case 'literal': + results = results.concat(['<' + t + + (st.object.dt ? ' rdf:datatype="' + escapeForXML(st.object.dt.uri) + '"' : '') + + (st.object.lang ? ' xml:lang="' + st.object.lang + '"' : '') + + '>' + escapeForXML(st.object.value) + + '']); + break; + case 'collection': + results = results.concat(['<' + t + ' rdf:parseType="Collection">', + collectionXMLTree(st.object, stats), + '']); + break; + default: + throw "Can't serialize object of type " + st.object.termType + " into XML"; + } // switch + } + } + + var tag = type ? qname(type) : 'rdf:Description'; + + var attrs = ''; + if(subject.termType == 'bnode') { + if(sz.incoming[subject].length != 1) { // not an anonymous bnode + attrs = ' rdf:nodeID="' + subject.toNT().slice(2) + '"'; + } + } else { + attrs = ' rdf:about="' + relURI(subject) + '"'; + } + + return ['<' + tag + attrs + '>'].concat([results]).concat([""]); } + function collectionXMLTree(subject, stats) { - var res = [] - for (var i=0; i< subject.elements.length; i++) { - res.push(subjectXMLTree(subject.elements[i], stats)); - } - return res; - } + var res = [] + for(var i = 0; i < subject.elements.length; i++) { + res.push(subjectXMLTree(subject.elements[i], stats)); + } + return res; + } // The property tree for a single subject or anonymos node function propertyXMLTree(subject, stats) { - var results = [] - var sts = stats.subjects[sz.toStr(subject)]; // relevant statements - if (sts == undefined) return results; // No relevant statements - sts.sort(); - for (var i=0; i', - '']); - } else { - results = results.concat(['<'+qname(st.predicate)+' rdf:parseType="Resource">', - propertyXMLTree(st.object, stats), - '']); - } - break; - case 'symbol': - results = results.concat(['<'+qname(st.predicate)+' rdf:resource="' - + relURI(st.object)+'"/>']); - break; - case 'literal': - results = results.concat(['<'+qname(st.predicate) - + (st.object.datatype ? ' rdf:datatype="'+escapeForXML(st.object.datatype.uri)+'"' : '') - + (st.object.lang ? ' xml:lang="'+st.object.lang+'"' : '') - + '>' + escapeForXML(st.object.value) - + '']); - break; - case 'collection': - results = results.concat(['<'+qname(st.predicate)+' rdf:parseType="Collection">', - collectionXMLTree(st.object, stats), - '']); - break; - default: - throw "Can't serialize object of type "+st.object.termType +" into XML"; - - } // switch - } - return results; + var results = [] + var sts = stats.subjects[sz.toStr(subject)]; // relevant statements + if(sts == undefined) return results; // No relevant statements + sts.sort(); + for(var i = 0; i < sts.length; i++) { + var st = sts[i]; + switch(st.object.termType) { + case 'bnode': + if(stats.rootsHash[st.object.toNT()]) { // This bnode has been done as a root -- no content here @@ what bout first time + results = results.concat(['<' + qname(st.predicate) + ' rdf:nodeID="' + st.object.toNT().slice(2) + '">', + '']); + } else { + results = results.concat(['<' + qname(st.predicate) + ' rdf:parseType="Resource">', + propertyXMLTree(st.object, stats), + '']); + } + break; + case 'symbol': + results = results.concat(['<' + qname(st.predicate) + ' rdf:resource="' + + relURI(st.object) + '"/>']); + break; + case 'literal': + results = results.concat(['<' + qname(st.predicate) + + (st.object.datatype ? ' rdf:datatype="' + escapeForXML(st.object.datatype.uri) + '"' : '') + + (st.object.lang ? ' xml:lang="' + st.object.lang + '"' : '') + + '>' + escapeForXML(st.object.value) + + '']); + break; + case 'collection': + results = results.concat(['<' + qname(st.predicate) + ' rdf:parseType="Collection">', + collectionXMLTree(st.object, stats), + '']); + break; + default: + throw "Can't serialize object of type " + st.object.termType + " into XML"; + + } // switch + } + return results; } function qname(term) { - var uri = term.uri; + var uri = term.uri; - var j = uri.indexOf('#'); - if (j<0 && sz.flags.indexOf('/') < 0) { - j = uri.lastIndexOf('/'); - } - if (j < 0) throw ("Cannot make qname out of <"+uri+">") + var j = uri.indexOf('#'); + if(j < 0 && sz.flags.indexOf('/') < 0) { + j = uri.lastIndexOf('/'); + } + if(j < 0) throw("Cannot make qname out of <" + uri + ">") - var canSplit = true; - for (var k=j+1; k=0) { - throw ('Invalid character "'+uri[k] +'" cannot be in XML qname for URI: '+uri); - } + var canSplit = true; + for(var k = j + 1; k < uri.length; k++) { + if(__Serializer.prototype._notNameChars.indexOf(uri[k]) >= 0) { + throw('Invalid character "' + uri[k] + '" cannot be in XML qname for URI: ' + uri); } - var localid = uri.slice(j+1); - var namesp = uri.slice(0,j+1); - if (sz.defaultNamespace && sz.defaultNamespace == namesp - && sz.flags.indexOf('d') < 0) {// d -> suppress default - return localid; - } - var prefix = sz.prefixes[namesp]; - if (!prefix) prefix = sz.makeUpPrefix(namesp); - namespaceCounts[namesp] = true; - return prefix + ':' + localid; -// throw ('No prefix for namespace "'+namesp +'" for XML qname for '+uri+', namespaces: '+sz.prefixes+' sz='+sz); + } + var localid = uri.slice(j + 1); + var namesp = uri.slice(0, j + 1); + if(sz.defaultNamespace + && sz.defaultNamespace == namesp + && sz.flags.indexOf('d') < 0) { // d -> suppress default + return localid; + } + var prefix = sz.prefixes[namesp]; + if(!prefix) prefix = sz.makeUpPrefix(namesp); + namespaceCounts[namesp] = true; + return prefix + ':' + localid; + // throw ('No prefix for namespace "'+namesp +'" for XML qname for '+uri+', namespaces: '+sz.prefixes+' sz='+sz); } // Body of toXML: - var tree = statementListToXMLTree(sts); var str = '']; //@@ namespace declrations + var tree2 = [str, tree, '']; //@@ namespace declrations return XMLtreeToString(tree2, -1); -} // End @@ body - -return Serializer; - -}(); + } // End @@ body + return Serializer; +}(); \ No newline at end of file diff --git a/chrome/content/zotero/xpcom/rdf/term.js b/chrome/content/zotero/xpcom/rdf/term.js index 4f7d1b2ae8..8a3d669bc8 100644 --- a/chrome/content/zotero/xpcom/rdf/term.js +++ b/chrome/content/zotero/xpcom/rdf/term.js @@ -7,25 +7,27 @@ // // W3C open source licence 2005. // - // Symbol - -$rdf.Empty = function() { - return this; +$rdf.Empty = function () { + return this; }; $rdf.Empty.prototype.termType = 'empty'; -$rdf.Empty.prototype.toString = function () { return "()" }; +$rdf.Empty.prototype.toString = function () { + return "()" +}; $rdf.Empty.prototype.toNT = $rdf.Empty.prototype.toString; -$rdf.Symbol = function( uri ) { - this.uri = uri; - this.value = uri; // -- why? -tim - return this; +$rdf.Symbol = function (uri) { + this.uri = uri; + this.value = uri; // -- why? -tim + return this; } $rdf.Symbol.prototype.termType = 'symbol'; -$rdf.Symbol.prototype.toString = function () { return ("<" + this.uri + ">"); }; +$rdf.Symbol.prototype.toString = function () { + return("<" + this.uri + ">"); +}; $rdf.Symbol.prototype.toNT = $rdf.Symbol.prototype.toString; // Some precalculated symbols @@ -35,132 +37,131 @@ $rdf.Symbol.prototype.XSDfloat = new $rdf.Symbol('http://www.w3.org/2001/XMLSche $rdf.Symbol.prototype.XSDinteger = new $rdf.Symbol('http://www.w3.org/2001/XMLSchema#integer'); $rdf.Symbol.prototype.XSDdateTime = new $rdf.Symbol('http://www.w3.org/2001/XMLSchema#dateTime'); $rdf.Symbol.prototype.integer = new $rdf.Symbol('http://www.w3.org/2001/XMLSchema#integer'); // Used? - // Blank Node - -if (typeof $rdf.NextId != 'undefined') { - $rdf.log.error('Attempt to re-zero existing blank node id counter at '+$rdf.NextId); +if(typeof $rdf.NextId != 'undefined') { + $rdf.log.error('Attempt to re-zero existing blank node id counter at ' + $rdf.NextId); } else { - $rdf.NextId = 0; // Global genid + $rdf.NextId = 0; // Global genid } $rdf.NTAnonymousNodePrefix = "_:n"; -$rdf.BlankNode = function ( id ) { - /*if (id) +$rdf.BlankNode = function (id) { + /*if (id) this.id = id; else*/ - this.id = $rdf.NextId++ - this.value = id ? id : this.id.toString(); - return this + this.id = $rdf.NextId++; + this.value = id ? id : this.id.toString(); + return this }; $rdf.BlankNode.prototype.termType = 'bnode'; -$rdf.BlankNode.prototype.toNT = function() { - return $rdf.NTAnonymousNodePrefix + this.id +$rdf.BlankNode.prototype.toNT = function () { + return $rdf.NTAnonymousNodePrefix + this.id }; $rdf.BlankNode.prototype.toString = $rdf.BlankNode.prototype.toNT; // Literal - $rdf.Literal = function (value, lang, datatype) { - this.value = value - if (lang == "" || lang == null) this.lang = undefined; - else this.lang = lang; // string - if (datatype == null) this.datatype = undefined; - else this.datatype = datatype; // term - return this; + this.value = value + if(lang == "" || lang == null) this.lang = undefined; + else this.lang = lang; // string + if(datatype == null) this.datatype = undefined; + else this.datatype = datatype; // term + return this; } -$rdf.Literal.prototype.termType = 'literal' -$rdf.Literal.prototype.toString = function() { - return ''+this.value; +$rdf.Literal.prototype.termType = 'literal' +$rdf.Literal.prototype.toString = function () { + return '' + this.value; }; -$rdf.Literal.prototype.toNT = function() { - var str = this.value - if (typeof str != 'string') { - if (typeof str == 'number') return ''+str; - throw Error("Value of RDF literal is not string: "+str) - } - str = str.replace(/\\/g, '\\\\'); // escape backslashes - str = str.replace(/\"/g, '\\"'); // escape quotes - str = str.replace(/\n/g, '\\n'); // escape newlines - str = '"' + str + '"' //'; - - if (this.datatype){ - str = str + '^^' + this.datatype.toNT() - } - if (this.lang) { - str = str + "@" + this.lang; - } - return str; +$rdf.Literal.prototype.toNT = function () { + var str = this.value + if(typeof str != 'string') { + if(typeof str == 'number') return '' + str; + throw Error("Value of RDF literal is not string: " + str) + } + str = str.replace(/\\/g, '\\\\'); // escape backslashes + str = str.replace(/\"/g, '\\"'); // escape quotes + str = str.replace(/\n/g, '\\n'); // escape newlines + str = '"' + str + '"' //'; + if(this.datatype) { + str = str + '^^' + this.datatype.toNT() + } + if(this.lang) { + str = str + "@" + this.lang; + } + return str; }; -$rdf.Collection = function() { - this.id = $rdf.NextId++; // Why need an id? For hashstring. - this.elements = []; - this.closed = false; +$rdf.Collection = function () { + this.id = $rdf.NextId++; // Why need an id? For hashstring. + this.elements = []; + this.closed = false; }; $rdf.Collection.prototype.termType = 'collection'; -$rdf.Collection.prototype.toNT = function() { - return $rdf.NTAnonymousNodePrefix + this.id +$rdf.Collection.prototype.toNT = function () { + return $rdf.NTAnonymousNodePrefix + this.id }; -$rdf.Collection.prototype.toString = function() { - var str='('; - for (var i=0; i=0) dt = $rdf.Symbol.prototype.XSDfloat; - else if ((''+val).indexOf('.')>=0) dt = $rdf.Symbol.prototype.XSDdecimal; - else dt = $rdf.Symbol.prototype.XSDinteger; - return new $rdf.Literal(val, undefined, dt); - } - if (typeof val == 'boolean') return new $rdf.Literal(val?"1":"0", undefined, - $rdf.Symbol.prototype.XSDboolean); - if (typeof val == 'undefined') return undefined; - throw ("Can't make term from " + val + " of type " + typeof val); + } else if(val instanceof Array) { + var x = new $rdf.Collection(); + for(var i = 0; i < val.length; i++) + x.append($rdf.term(val[i])); + return x; + } else + return val; + if(typeof val == 'string') + return new $rdf.Literal(val); + if(typeof val == 'number') { + var dt; + if(('' + val).indexOf('e') >= 0) dt = $rdf.Symbol.prototype.XSDfloat; + else if(('' + val).indexOf('.') >= 0) dt = $rdf.Symbol.prototype.XSDdecimal; + else dt = $rdf.Symbol.prototype.XSDinteger; + return new $rdf.Literal(val, undefined, dt); + } + if(typeof val == 'boolean') + return new $rdf.Literal(val ? "1" : "0", undefined, $rdf.Symbol.prototype.XSDboolean); + if(typeof val == 'undefined') + return undefined; + throw("Can't make term from " + val + " of type " + typeof val); } // Statement @@ -169,25 +170,22 @@ $rdf.term = function(val) { // // The reason can point to provenece or inference // - -$rdf.Statement = function(subject, predicate, object, why) { - this.subject = $rdf.term(subject) - this.predicate = $rdf.term(predicate) - this.object = $rdf.term(object) - if (typeof why !='undefined') { - this.why = why; - } - return this; +$rdf.Statement = function (subject, predicate, object, why) { + this.subject = $rdf.term(subject) + this.predicate = $rdf.term(predicate) + this.object = $rdf.term(object) + if(typeof why != 'undefined') { + this.why = why; + } + return this; } -$rdf.st= function(subject, predicate, object, why) { - return new $rdf.Statement(subject, predicate, object, why); +$rdf.st = function (subject, predicate, object, why) { + return new $rdf.Statement(subject, predicate, object, why); }; -$rdf.Statement.prototype.toNT = function() { - return (this.subject.toNT() + " " - + this.predicate.toNT() + " " - + this.object.toNT() +" ."); +$rdf.Statement.prototype.toNT = function () { + return (this.subject.toNT() + " " + this.predicate.toNT() + " " + this.object.toNT() + " ."); }; $rdf.Statement.prototype.toString = $rdf.Statement.prototype.toNT; @@ -195,106 +193,110 @@ $rdf.Statement.prototype.toString = $rdf.Statement.prototype.toNT; // Formula // // Set of statements. - -$rdf.Formula = function() { - this.statements = [] - this.constraints = [] - this.initBindings = [] - this.optional = [] - return this; +$rdf.Formula = function () { + this.statements = [] + this.constraints = [] + this.initBindings = [] + this.optional = [] + return this; }; $rdf.Formula.prototype.termType = 'formula'; -$rdf.Formula.prototype.toNT = function() { - return "{" + this.statements.join('\n') + "}" +$rdf.Formula.prototype.toNT = function () { + return "{" + this.statements.join('\n') + "}" }; $rdf.Formula.prototype.toString = $rdf.Formula.prototype.toNT; -$rdf.Formula.prototype.add = function(subj, pred, obj, why) { - this.statements.push(new $rdf.Statement(subj, pred, obj, why)) +$rdf.Formula.prototype.add = function (subj, pred, obj, why) { + this.statements.push(new $rdf.Statement(subj, pred, obj, why)) } // Convenience methods on a formula allow the creation of new RDF terms: - -$rdf.Formula.prototype.sym = function(uri,name) { - if (name != null) { - throw "This feature (kb.sym with 2 args) is removed. Do not assume prefix mappings." - if (!$rdf.ns[uri]) throw 'The prefix "'+uri+'" is not set in the API'; - uri = $rdf.ns[uri] + name - } - return new $rdf.Symbol(uri) +$rdf.Formula.prototype.sym = function (uri, name) { + if(name != null) { + throw "This feature (kb.sym with 2 args) is removed. Do not assume prefix mappings." + if(!$rdf.ns[uri]) throw 'The prefix "' + uri + '" is not set in the API'; + uri = $rdf.ns[uri] + name + } + return new $rdf.Symbol(uri) } -$rdf.sym = function(uri) { return new $rdf.Symbol(uri); }; +$rdf.sym = function (uri) { + return new $rdf.Symbol(uri); +}; -$rdf.Formula.prototype.literal = function(val, lang, dt) { - return new $rdf.Literal(val.toString(), lang, dt) +$rdf.Formula.prototype.literal = function (val, lang, dt) { + return new $rdf.Literal(val.toString(), lang, dt) } $rdf.lit = $rdf.Formula.prototype.literal; -$rdf.Formula.prototype.bnode = function(id) { - return new $rdf.BlankNode(id) +$rdf.Formula.prototype.bnode = function (id) { + return new $rdf.BlankNode(id) } -$rdf.Formula.prototype.formula = function() { - return new $rdf.Formula() +$rdf.Formula.prototype.formula = function () { + return new $rdf.Formula() } $rdf.Formula.prototype.collection = function () { // obsolete - return new $rdf.Collection() + return new $rdf.Collection() } $rdf.Formula.prototype.list = function (values) { - var li = new $rdf.Collection(); - if (values) { - for(var i = 0; i 0) { + return base + "/" + given + } else { + return baseScheme + given + } } - var baseScheme = base.slice(0,baseColon+1) // eg http: - if (given.indexOf("//") == 0) // Starts with // - return baseScheme + given; - if (base.indexOf('//', baseColon)==baseColon+1) { // Any hostpart? - var baseSingle = base.indexOf("/", baseColon+3) - if (baseSingle < 0) { - if (base.length-baseColon-3 > 0) { - return base + "/" + given - } else { - return baseScheme + given - } - } - } else { - var baseSingle = base.indexOf("/", baseColon+1) - if (baseSingle < 0) { - if (base.length-baseColon-1 > 0) { - return base + "/" + given - } else { - return baseScheme + given - } - } + } else { + var baseSingle = base.indexOf("/", baseColon + 1) + if(baseSingle < 0) { + if(base.length - baseColon - 1 > 0) { + return base + "/" + given + } else { + return baseScheme + given + } } + } - if (given.indexOf('/') == 0) // starts with / but not // - return base.slice(0, baseSingle) + given - - var path = base.slice(baseSingle) - var lastSlash = path.lastIndexOf("/") - if (lastSlash <0) return baseScheme + given - if ((lastSlash >=0) && (lastSlash < (path.length-1))) - path = path.slice(0, lastSlash+1) // Chop trailing filename from base - - path = path + given - while (path.match(/[^\/]*\/\.\.\//)) // must apply to result of prev - path = path.replace( /[^\/]*\/\.\.\//, '') // ECMAscript spec 7.8.5 - path = path.replace( /\.\//g, '') // spec vague on escaping - path = path.replace( /\/\.$/, '/' ) - return base.slice(0, baseSingle) + path + if(given.indexOf('/') == 0) // starts with / but not // + return base.slice(0, baseSingle) + given + + var path = base.slice(baseSingle) + var lastSlash = path.lastIndexOf("/") + if(lastSlash < 0) return baseScheme + given + if((lastSlash >= 0) + && (lastSlash < (path.length - 1))) + path = path.slice(0, lastSlash + 1) // Chop trailing filename from base + path = path + given + while(path.match(/[^\/]*\/\.\.\//)) // must apply to result of prev + path = path.replace(/[^\/]*\/\.\.\//, '') // ECMAscript spec 7.8.5 + path = path.replace(/\.\//g, '') // spec vague on escaping + path = path.replace(/\/\.$/, '/') + return base.slice(0, baseSingle) + path } -if (typeof tabulator != 'undefined' && tabulator.isExtension) { - $rdf.Util.uri.join2 = function (given, base){ - var tIOService = Components.classes['@mozilla.org/network/io-service;1'] - .getService(Components.interfaces.nsIIOService); +if(typeof tabulator != 'undefined' && tabulator.isExtension) { + $rdf.Util.uri.join2 = function (given, base) { + var tIOService = Components.classes['@mozilla.org/network/io-service;1'] + .getService(Components.interfaces.nsIIOService); - var baseURI = tIOService.newURI(base, null, null); - return tIOService.newURI(baseURI.resolve(given), null, null).spec; - } + var baseURI = tIOService.newURI(base, null, null); + return tIOService.newURI(baseURI.resolve(given), null, null).spec; + } } else - $rdf.Util.uri.join2 = $rdf.Util.uri.join; - + $rdf.Util.uri.join2 = $rdf.Util.uri.join; + // refTo: Make a URI relative to a given base // // based on code in http://www.w3.org/2000/10/swap/uripath.py // $rdf.Util.uri.commonHost = new RegExp("^[-_a-zA-Z0-9.]+:(//[^/]*)?/[^/]*$"); -$rdf.Util.uri.hostpart = function(u) { var m = /[^\/]*\/\/([^\/]*)\//.exec(u); return m? m[1]: '' }; +$rdf.Util.uri.hostpart = function (u) { + var m = /[^\/]*\/\/([^\/]*)\//.exec(u); + return m ? m[1] : '' +}; -$rdf.Util.uri.refTo = function(base, uri) { - if (!base) return uri; - if (base == uri) return ""; - var i =0; // How much are they identical? - while (i0 && uri[i-1] != '/') i--; +$rdf.Util.uri.refTo = function (base, uri) { + if(!base) return uri; + if(base == uri) return ""; + var i = 0; // How much are they identical? + while(i < uri.length && i < base.length) + if(uri[i] == base[i]) i++; + else break; + if(base.slice(0, i).match($rdf.Util.uri.commonHost)) { + var k = uri.indexOf('//'); + if(k < 0) k = -2; // no host + var l = uri.indexOf('/', k + 2); // First *single* slash + if(uri.slice(l + 1, l + 2) != '/' + && base.slice(l + 1, l + 2) != '/' + && uri.slice(0, l) == base.slice(0, l)) + // common path to single slash + return uri.slice(l); // but no other common path segments + } + // fragment of base? + if(uri.slice(i, i + 1) == '#' && base.length == i) return uri.slice(i); + while(i > 0 && uri[i - 1] != '/') i--; - if (i<3) return uri; // No way - if ((base.indexOf('//', i-2) > 0) || uri.indexOf('//', i-2) > 0) - return uri; // an unshared '//' - if (base.indexOf(':', i) >0) return uri; // unshared ':' - var n = 0; - for (var j=i; j 0) + || uri.indexOf('//', i - 2) > 0) + return uri; // an unshared '//' + if(base.indexOf(':', i) > 0) return uri; // unshared ':' + var n = 0; + for(var j = i; j < base.length; j++) if(base[j] == '/') n++; + if(n == 0 && i < uri.length && uri[i] == '#') return './' + uri.slice(i); + if(n == 0 && i == uri.length) return './'; + var str = ''; + for(var j = 0; j < n; j++) str += '../'; + return str + uri.slice(i); } /** returns URI without the frag **/ $rdf.Util.uri.docpart = function (uri) { - var i = uri.indexOf("#") - if (i < 0) return uri - return uri.slice(0,i) -} + var i = uri.indexOf("#") + if(i < 0) return uri + return uri.slice(0, i) +} /** The document in which something a thing defined **/ $rdf.Util.uri.document = function (x) { - return $rdf.sym($rdf.Util.uri.docpart(x.uri)); -} + return $rdf.sym($rdf.Util.uri.docpart(x.uri)); +} /** return the protocol of a uri **/ /** return null if there isn't one **/ $rdf.Util.uri.protocol = function (uri) { - var index = uri.indexOf(':'); - if (index >= 0) - return uri.slice(0, index); - else - return null; + var index = uri.indexOf(':'); + if(index >= 0) return uri.slice(0, index); + else return null; } //protocol - -//ends +//ends \ No newline at end of file From 1942fb676293b62549dad68a8431dc606ddd9bb5 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Sun, 29 Apr 2012 20:30:37 -0500 Subject: [PATCH 12/38] Remove compatibility hack from rdf.js. Fix Zotero code instead. Move all setup to init.js --- chrome/content/zotero/xpcom/rdf.js | 7 --- chrome/content/zotero/xpcom/rdf/init.js | 18 +++--- .../zotero/xpcom/translation/translate.js | 62 +++++++++---------- .../xpcom/translation/translate_firefox.js | 4 +- components/zotero-service.js | 3 +- 5 files changed, 43 insertions(+), 51 deletions(-) delete mode 100644 chrome/content/zotero/xpcom/rdf.js diff --git a/chrome/content/zotero/xpcom/rdf.js b/chrome/content/zotero/xpcom/rdf.js deleted file mode 100644 index e68120ce57..0000000000 --- a/chrome/content/zotero/xpcom/rdf.js +++ /dev/null @@ -1,7 +0,0 @@ -// Tweaks to get the Tabulator RDF library to work without Tabulator. All of this happens in the -// Zotero.RDF.AJAW namespace. -$rdf.RDFIndexedFormula = $rdf.IndexedFormula; -$rdf.RDFSymbol = $rdf.Symbol; -$rdf.RDFBlankNode = $rdf.BlankNode; - -Zotero.RDF.AJAW = $rdf; \ No newline at end of file diff --git a/chrome/content/zotero/xpcom/rdf/init.js b/chrome/content/zotero/xpcom/rdf/init.js index dd7173976f..6982c033f2 100644 --- a/chrome/content/zotero/xpcom/rdf/init.js +++ b/chrome/content/zotero/xpcom/rdf/init.js @@ -1,5 +1,5 @@ /* Set up the environment before loading the rest of the files into Zotero */ -var $rdf = { +Zotero.RDF.AJAW = { Util: { ArrayIndexOf: function (arr, item, i) { //supported in all browsers except IE<9 @@ -20,13 +20,13 @@ var $rdf = { throw "RDFArrayRemove: Array did not contain " + x; }, }, + tabulator: { + log: { + debug: Zotero.debug, + warn: Zotero.debug + } + }, + alert: Zotero.debug }; -var tabulator = { - log: { - debug: Zotero.debug, - warn: Zotero.debug - } -}; - -var alert = tabulator.log.warn; \ No newline at end of file +Zotero.RDF.AJAW.$rdf = Zotero.RDF.AJAW; diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index 1f1abd9b77..dbc156b7f7 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -2151,7 +2151,7 @@ Zotero.Translate.IO.String.prototype = { "_initRDF":function(callback) { Zotero.debug("Translate: Initializing RDF data store"); - this._dataStore = new Zotero.RDF.AJAW.RDFIndexedFormula(); + this._dataStore = new Zotero.RDF.IndexedFormula(); this.RDF = new Zotero.Translate.IO._RDFSandbox(this._dataStore); if(this.contentLength) { @@ -2262,9 +2262,9 @@ Zotero.Translate.IO.String.prototype = { /** * @class An API for handling RDF from the sandbox. This is exposed to translators as Zotero.RDF. * - * @property {Zotero.RDF.AJAW.RDFIndexedFormula} _dataStore + * @property {Zotero.RDF.AJAW.IndexedFormula} _dataStore * @property {Integer[]} _containerCounts - * @param {Zotero.RDF.AJAW.RDFIndexedFormula} dataStore + * @param {Zotero.RDF.AJAW.IndexedFormula} dataStore */ Zotero.Translate.IO._RDFSandbox = function(dataStore) { this._dataStore = dataStore; @@ -2289,12 +2289,12 @@ Zotero.Translate.IO._RDFSandbox.prototype = { }, /** - * Gets a resource as a Zotero.RDF.AJAW.RDFSymbol, rather than a string - * @param {String|Zotero.RDF.AJAW.RDFSymbol} about - * @return {Zotero.RDF.AJAW.RDFSymbol} + * Gets a resource as a Zotero.RDF.AJAW.Symbol, rather than a string + * @param {String|Zotero.RDF.AJAW.Symbol} about + * @return {Zotero.RDF.AJAW.Symbol} */ "_getResource":function(about) { - return (typeof about == "object" ? about : new Zotero.RDF.AJAW.RDFSymbol(about)); + return (typeof about == "object" ? about : new Zotero.RDF.AJAW.Symbol(about)); }, /** @@ -2327,9 +2327,9 @@ Zotero.Translate.IO._RDFSandbox.prototype = { /** * Adds an RDF triple - * @param {String|Zotero.RDF.AJAW.RDFSymbol} about - * @param {String|Zotero.RDF.AJAW.RDFSymbol} relation - * @param {String|Zotero.RDF.AJAW.RDFSymbol} value + * @param {String|Zotero.RDF.AJAW.Symbol} about + * @param {String|Zotero.RDF.AJAW.Symbol} relation + * @param {String|Zotero.RDF.AJAW.Symbol} value * @param {Boolean} literal Whether value should be treated as a literal (true) or a resource * (false) */ @@ -2356,16 +2356,16 @@ Zotero.Translate.IO._RDFSandbox.prototype = { /** * Creates a new anonymous resource - * @return {Zotero.RDF.AJAW.RDFSymbol} + * @return {Zotero.RDF.AJAW.Symbol} */ "newResource":function() { - return new Zotero.RDF.AJAW.RDFBlankNode(); + return new Zotero.RDF.AJAW.BlankNode(); }, /** * Creates a new container resource * @param {String} type The type of the container ("bag", "seq", or "alt") - * @param {String|Zotero.RDF.AJAW.RDFSymbol} about The URI of the resource + * @param {String|Zotero.RDF.AJAW.Symbol} about The URI of the resource * @return {Zotero.Translate.RDF.prototype.newContainer */ "newContainer":function(type, about) { @@ -2386,8 +2386,8 @@ Zotero.Translate.IO._RDFSandbox.prototype = { /** * Adds a new element to a container - * @param {String|Zotero.RDF.AJAW.RDFSymbol} about The container - * @param {String|Zotero.RDF.AJAW.RDFSymbol} element The element to add to the container + * @param {String|Zotero.RDF.AJAW.Symbol} about The container + * @param {String|Zotero.RDF.AJAW.Symbol} element The element to add to the container * @param {Boolean} literal Whether element should be treated as a literal (true) or a resource * (false) */ @@ -2395,13 +2395,13 @@ Zotero.Translate.IO._RDFSandbox.prototype = { const rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; var about = this._getResource(about); - this._dataStore.add(about, new Zotero.RDF.AJAW.RDFSymbol(rdf+"_"+(this._containerCounts[about.toNT()]++)), element, literal); + this._dataStore.add(about, new Zotero.RDF.AJAW.Symbol(rdf+"_"+(this._containerCounts[about.toNT()]++)), element, literal); }, /** * Gets all elements within a container - * @param {String|Zotero.RDF.AJAW.RDFSymbol} about The container - * @return {Zotero.RDF.AJAW.RDFSymbol[]} + * @param {String|Zotero.RDF.AJAW.Symbol} about The container + * @return {Zotero.RDF.AJAW.Symbol[]} */ "getContainerElements":function(about) { const liPrefix = "http://www.w3.org/1999/02/22-rdf-syntax-ns#_"; @@ -2439,7 +2439,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = { /** * Gets the URI a specific resource - * @param {String|Zotero.RDF.AJAW.RDFSymbol} resource + * @param {String|Zotero.RDF.AJAW.Symbol} resource * @return {String} */ "getResourceURI":function(resource) { @@ -2451,7 +2451,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = { /** * Gets all resources in the RDF data store - * @return {Zotero.RDF.AJAW.RDFSymbol[]} + * @return {Zotero.RDF.AJAW.Symbol[]} */ "getAllResources":function() { var returnArray = []; @@ -2463,7 +2463,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = { /** * Gets all arcs (predicates) into a resource - * @return {Zotero.RDF.AJAW.RDFSymbol[]} + * @return {Zotero.RDF.AJAW.Symbol[]} * @deprecated Since 2.1. Use {@link Zotero.Translate.IO["rdf"]._RDFBase#getStatementsMatching} */ "getArcsIn":function(resource) { @@ -2479,7 +2479,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = { /** * Gets all arcs (predicates) out of a resource - * @return {Zotero.RDF.AJAW.RDFSymbol[]} + * @return {Zotero.RDF.AJAW.Symbol[]} * @deprecated Since 2.1. Use {@link Zotero.Translate.IO["rdf"]._RDFBase#getStatementsMatching} */ "getArcsOut":function(resource) { @@ -2495,9 +2495,9 @@ Zotero.Translate.IO._RDFSandbox.prototype = { /** * Gets all subjects whose predicates point to a resource - * @param {String|Zotero.RDF.AJAW.RDFSymbol} resource Subject that predicates should point to - * @param {String|Zotero.RDF.AJAW.RDFSymbol} property Predicate - * @return {Zotero.RDF.AJAW.RDFSymbol[]} + * @param {String|Zotero.RDF.AJAW.Symbol} resource Subject that predicates should point to + * @param {String|Zotero.RDF.AJAW.Symbol} property Predicate + * @return {Zotero.RDF.AJAW.Symbol[]} * @deprecated Since 2.1. Use {@link Zotero.Translate.IO["rdf"]._RDFBase#getStatementsMatching} */ "getSources":function(resource, property) { @@ -2513,9 +2513,9 @@ Zotero.Translate.IO._RDFSandbox.prototype = { /** * Gets all objects of a given subject with a given predicate - * @param {String|Zotero.RDF.AJAW.RDFSymbol} resource Subject - * @param {String|Zotero.RDF.AJAW.RDFSymbol} property Predicate - * @return {Zotero.RDF.AJAW.RDFSymbol[]} + * @param {String|Zotero.RDF.AJAW.Symbol} resource Subject + * @param {String|Zotero.RDF.AJAW.Symbol} property Predicate + * @return {Zotero.RDF.AJAW.Symbol[]} * @deprecated Since 2.1. Use {@link Zotero.Translate.IO["rdf"]._RDFBase#getStatementsMatching} */ "getTargets":function(resource, property) { @@ -2532,9 +2532,9 @@ Zotero.Translate.IO._RDFSandbox.prototype = { /** * Gets statements matching a certain pattern * - * @param {String|Zotero.RDF.AJAW.RDFSymbol} subj Subject - * @param {String|Zotero.RDF.AJAW.RDFSymbol} predicate Predicate - * @param {String|Zotero.RDF.AJAW.RDFSymbol} obj Object + * @param {String|Zotero.RDF.AJAW.Symbol} subj Subject + * @param {String|Zotero.RDF.AJAW.Symbol} predicate Predicate + * @param {String|Zotero.RDF.AJAW.Symbol} obj Object * @param {Boolean} objLiteral Whether the object is a literal (as * opposed to a URI) * @param {Boolean} justOne Whether to stop when a single result is diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js index 26a8bfc1e6..181f28d4e6 100644 --- a/chrome/content/zotero/xpcom/translation/translate_firefox.js +++ b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -419,7 +419,7 @@ Zotero.Translate.IO.Read.prototype = { var baseURI = fileHandler.getURLSpecFromFile(this.file); Zotero.debug("Translate: Initializing RDF data store"); - this._dataStore = new Zotero.RDF.AJAW.RDFIndexedFormula(); + this._dataStore = new Zotero.RDF.AJAW.IndexedFormula(); var parser = new Zotero.RDF.AJAW.RDFParser(this._dataStore); try { var nodes = Zotero.Translate.IO.parseDOMXML(this._rawStream, this._charset, this.file.fileSize); @@ -521,7 +521,7 @@ Zotero.Translate.IO.Write.prototype = { "_initRDF":function() { Zotero.debug("Translate: Initializing RDF data store"); - this._dataStore = new Zotero.RDF.AJAW.RDFIndexedFormula(); + this._dataStore = new Zotero.RDF.AJAW.IndexedFormula(); this.RDF = new Zotero.Translate.IO._RDFSandbox(this._dataStore); }, diff --git a/components/zotero-service.js b/components/zotero-service.js index 2c3dcaafcc..768ac80468 100644 --- a/components/zotero-service.js +++ b/components/zotero-service.js @@ -241,8 +241,7 @@ function makeZoteroContext(isConnector) { 'rdf/match', 'rdf/n3parser', 'rdf/rdfparser', - 'rdf/serialize', - 'rdf' + 'rdf/serialize' ]; zContext.Zotero.RDF = {AJAW:{Zotero:zContext.Zotero}}; for (var i=0; i Date: Wed, 2 May 2012 01:52:37 +0200 Subject: [PATCH 13/38] Add new icons to items currently using blank documents. Update icons for some items. http://forums.zotero.org/discussion/8544/icon-for-presentation-icon-for-document/#Item_9 --- .../zotero/xpcom/connector/typeSchemaData.js | 2 +- chrome/content/zotero/xpcom/data/cachedTypes.js | 12 +++++++++++- chrome/skin/default/zotero/treeitem-bill.png | Bin 0 -> 641 bytes chrome/skin/default/zotero/treeitem-case.png | Bin 0 -> 753 bytes .../default/zotero/treeitem-dictionaryEntry.png | Bin 0 -> 611 bytes .../skin/default/zotero/treeitem-document.png | Bin 0 -> 373 bytes .../zotero/treeitem-encyclopediaArticle.png | Bin 0 -> 650 bytes .../skin/default/zotero/treeitem-forumPost.png | Bin 635 -> 743 bytes chrome/skin/default/zotero/treeitem-hearing.png | Bin 0 -> 1695 bytes .../default/zotero/treeitem-instantMessage.png | Bin 0 -> 413 bytes .../default/zotero/treeitem-magazineArticle.png | Bin 480 -> 519 bytes chrome/skin/default/zotero/treeitem-patent.png | Bin 0 -> 782 bytes .../default/zotero/treeitem-presentation.png | Bin 0 -> 588 bytes chrome/skin/default/zotero/treeitem-report.png | Bin 649 -> 493 bytes chrome/skin/default/zotero/treeitem-statute.png | Bin 0 -> 706 bytes .../default/zotero/treeitem-videoRecording.png | Bin 653 -> 728 bytes 16 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 chrome/skin/default/zotero/treeitem-bill.png create mode 100644 chrome/skin/default/zotero/treeitem-case.png create mode 100644 chrome/skin/default/zotero/treeitem-dictionaryEntry.png create mode 100644 chrome/skin/default/zotero/treeitem-document.png create mode 100644 chrome/skin/default/zotero/treeitem-encyclopediaArticle.png create mode 100644 chrome/skin/default/zotero/treeitem-hearing.png create mode 100644 chrome/skin/default/zotero/treeitem-instantMessage.png create mode 100644 chrome/skin/default/zotero/treeitem-patent.png create mode 100644 chrome/skin/default/zotero/treeitem-presentation.png create mode 100644 chrome/skin/default/zotero/treeitem-statute.png diff --git a/chrome/content/zotero/xpcom/connector/typeSchemaData.js b/chrome/content/zotero/xpcom/connector/typeSchemaData.js index 1d6fc7bf64..74e6bbaff9 100644 --- a/chrome/content/zotero/xpcom/connector/typeSchemaData.js +++ b/chrome/content/zotero/xpcom/connector/typeSchemaData.js @@ -1 +1 @@ -Zotero.Connector_Types.schema = {"itemTypes":{"1":["note","Note",[false],[],{},"treeitem-note.png"],"2":["book","Book",[1,2,3,5,4],[110,90,3,30,4,45,6,7,8,14,118,87,11,116,1,27,123,19,62,18,2,22],{},"treeitem-book.png"],"3":["bookSection","Book Section",[1,29,2,3,5,4],[110,90,115,3,30,4,45,6,7,8,14,10,87,11,116,1,27,123,19,62,18,2,22],{"115":12},"treeitem-bookSection.png"],"4":["journalArticle","Journal Article",[1,2,3,27,4],[110,90,12,4,5,10,14,3,28,29,25,87,26,13,116,1,27,123,19,62,18,2,22],{},"treeitem-journalArticle.png"],"5":["magazineArticle","Magazine Article",[1,2,27,4],[110,90,12,4,5,14,10,87,13,116,1,27,123,19,62,18,2,22],{},"treeitem-magazineArticle.png"],"6":["newspaperArticle","Newspaper Article",[1,2,27,4],[110,90,12,7,6,14,15,10,87,116,13,1,27,123,19,62,18,2,22],{},"treeitem-newspaperArticle.png"],"7":["thesis","Thesis",[1,2],[110,90,69,89,7,14,118,87,116,1,27,123,19,62,18,2,22],{"69":108,"89":8},"treeitem-thesis.png"],"8":["letter","Letter",[1,2,16],[110,90,65,14,87,116,1,27,123,19,62,18,2,22],{"65":108},"treeitem-letter.png"],"9":["manuscript","Manuscript",[1,2,4],[110,90,66,7,14,118,87,116,1,27,123,19,62,18,2,22],{"66":108},"treeitem-manuscript.png"],"10":["interview","Interview",[6,2,7,4],[110,90,14,64,87,116,1,27,123,19,62,18,2,22],{"64":109},"treeitem-interview.png"],"11":["film","Film",[8,2,10,9],[110,90,21,14,122,63,77,87,116,1,27,123,19,62,18,2,22],{"21":8,"122":108,"63":109},"treeitem-film.png"],"12":["artwork","Artwork",[22,2],[110,90,59,61,14,87,116,123,19,62,18,1,27,2,22],{"59":109},"treeitem-artwork.png"],"13":["webpage","Web Page",[1,2,4],[110,90,91,70,14,116,1,27,87,2,22],{"91":12,"70":108},"treeitem-webpage.png"],"14":["attachment","Attachment",[false],[110,27,1],{},"treeitem.png"],"15":["report","Report",[1,2,5,4],[110,90,92,32,28,7,31,14,10,87,116,1,27,123,19,62,18,2,22],{"92":60,"32":108,"31":8},"treeitem-report.png"],"16":["bill","Bill",[12,2,28],[110,90,93,36,94,15,95,41,40,42,14,87,1,27,116,2,22],{"93":60,"94":4,"95":10},"treeitem.png"],"17":["case","Case",[1,2,13],[111,90,43,97,44,117,98,42,96,87,116,1,27,2,22],{"111":110,"97":4,"117":60,"98":10,"96":14},"treeitem.png"],"18":["hearing","Hearing",[2],[110,90,46,7,8,45,99,10,41,40,42,14,87,116,1,27,2,22],{"99":60},"treeitem.png"],"19":["patent","Patent",[14,15,2],[110,90,7,102,48,120,50,121,10,103,51,52,53,54,87,116,1,27,2,22],{"50":60,"52":14},"treeitem.png"],"20":["statute","Statute",[1,2],[112,90,36,55,101,100,10,15,40,42,87,116,1,27,2,22],{"112":110,"101":60,"100":14},"treeitem.png"],"21":["email","E-mail",[1,2,16],[113,90,14,116,1,27,87,2,22],{"113":110},"treeitem-email.png"],"22":["map","Map",[20,2,5],[110,90,67,68,28,6,7,8,14,87,11,116,1,27,123,19,62,18,2,22],{"67":108},"treeitem-map.png"],"23":["blogPost","Blog Post",[1,23,2],[110,90,107,70,14,1,27,87,116,2,22],{"107":12,"70":108},"treeitem-blogPost.png"],"24":["instantMessage","Instant Message",[1,2,16],[110,90,14,87,116,1,27,2,22],{},"treeitem.png"],"25":["forumPost","Forum Post",[1,2],[110,90,104,79,14,87,116,1,27,2,22],{"104":12,"79":108},"treeitem-forumPost.png"],"26":["audioRecording","Audio Recording",[17,18,2,19],[110,90,71,28,4,45,7,72,14,77,87,11,116,123,19,62,18,1,27,2,22],{"71":109,"72":8},"treeitem-audioRecording.png"],"27":["presentation","Presentation",[24,2],[110,90,74,14,7,75,1,27,87,116,2,22],{"74":108},"treeitem.png"],"28":["videoRecording","Video Recording",[8,11,2,10,9],[110,90,63,28,4,45,7,76,14,77,87,11,116,1,27,123,19,62,18,2,22],{"63":109,"76":8},"treeitem-videoRecording.png"],"29":["tvBroadcast","TV Broadcast",[8,11,2,25,10,9],[110,90,119,105,63,7,78,14,77,87,116,1,27,123,19,62,18,2,22],{"119":12,"105":60,"63":109,"78":8},"treeitem-tvBroadcast.png"],"30":["radioBroadcast","Radio Broadcast",[8,11,2,25,10,9],[110,90,119,105,71,7,78,14,77,87,116,1,27,123,19,62,18,2,22],{"119":12,"105":60,"71":109,"78":8},"treeitem-radioBroadcast.png"],"31":["podcast","Podcast",[26,2,25],[110,90,28,105,80,77,1,27,87,116,2,22],{"105":60,"80":109},"treeitem-podcast.png"],"32":["computerProgram","Computer Program",[21,2],[110,90,28,81,14,82,7,83,88,11,116,1,2,123,19,62,18,27,22],{"83":8},"treeitem-computerProgram.png"],"33":["conferencePaper","Conference Paper",[1,2,3,5,4],[110,90,14,114,84,7,8,4,10,3,87,26,11,116,1,27,123,19,62,18,2,22],{"114":12},"treeitem-conferencePaper.png"],"34":["document","Document",[1,2,3,27,4],[110,90,8,14,87,116,1,27,123,19,62,18,2,22],{},"treeitem.png"],"35":["encyclopediaArticle","Encyclopedia Article",[1,2,3,5,4],[110,90,85,3,30,4,45,6,7,8,14,10,11,116,1,27,87,123,19,62,18,2,22],{"85":12},"treeitem.png"],"36":["dictionaryEntry","Dictionary Entry",[1,2,3,5,4],[110,90,86,3,30,4,45,6,7,8,14,10,87,11,116,1,27,123,19,62,18,2,22],{"86":12},"treeitem.png"]},"creatorTypes":{"1":["author","Author"],"2":["contributor","Contributor"],"3":["editor","Editor"],"4":["translator","Translator"],"5":["seriesEditor","Series Editor"],"6":["interviewee","Interview With"],"7":["interviewer","Interviewer"],"8":["director","Director"],"9":["scriptwriter","Scriptwriter"],"10":["producer","Producer"],"11":["castMember","Cast Member"],"12":["sponsor","Sponsor"],"13":["counsel","Counsel"],"14":["inventor","Inventor"],"15":["attorneyAgent","Attorney/Agent"],"16":["recipient","Recipient"],"17":["performer","Performer"],"18":["composer","Composer"],"19":["wordsBy","Words By"],"20":["cartographer","Cartographer"],"21":["programmer","Programmer"],"22":["artist","Artist"],"23":["commenter","Commenter"],"24":["presenter","Presenter"],"25":["guest","Guest"],"26":["podcaster","Podcaster"],"27":["reviewedAuthor","Reviewed Author"],"28":["cosponsor","Cosponsor"],"29":["bookAuthor","Book Author"]},"fields":{"1":["url"],"2":["rights"],"3":["series"],"4":["volume"],"5":["issue"],"6":["edition"],"7":["place"],"8":["publisher"],"10":["pages"],"11":["ISBN"],"12":["publicationTitle"],"13":["ISSN"],"14":["date"],"15":["section"],"18":["callNumber"],"19":["archiveLocation"],"21":["distributor"],"22":["extra"],"25":["journalAbbreviation"],"26":["DOI"],"27":["accessDate"],"28":["seriesTitle"],"29":["seriesText"],"30":["seriesNumber"],"31":["institution"],"32":["reportType"],"36":["code"],"40":["session"],"41":["legislativeBody"],"42":["history"],"43":["reporter"],"44":["court"],"45":["numberOfVolumes"],"46":["committee"],"48":["assignee"],"50":["patentNumber"],"51":["priorityNumbers"],"52":["issueDate"],"53":["references"],"54":["legalStatus"],"55":["codeNumber"],"59":["artworkMedium"],"60":["number"],"61":["artworkSize"],"62":["libraryCatalog"],"63":["videoRecordingFormat"],"64":["interviewMedium"],"65":["letterType"],"66":["manuscriptType"],"67":["mapType"],"68":["scale"],"69":["thesisType"],"70":["websiteType"],"71":["audioRecordingFormat"],"72":["label"],"74":["presentationType"],"75":["meetingName"],"76":["studio"],"77":["runningTime"],"78":["network"],"79":["postType"],"80":["audioFileType"],"81":["version"],"82":["system"],"83":["company"],"84":["conferenceName"],"85":["encyclopediaTitle"],"86":["dictionaryTitle"],"87":["language"],"88":["programmingLanguage"],"89":["university"],"90":["abstractNote"],"91":["websiteTitle"],"92":["reportNumber"],"93":["billNumber"],"94":["codeVolume"],"95":["codePages"],"96":["dateDecided"],"97":["reporterVolume"],"98":["firstPage"],"99":["documentNumber"],"100":["dateEnacted"],"101":["publicLawNumber"],"102":["country"],"103":["applicationNumber"],"104":["forumTitle"],"105":["episodeNumber"],"107":["blogTitle"],"108":["type"],"109":["medium"],"110":["title"],"111":["caseName"],"112":["nameOfAct"],"113":["subject"],"114":["proceedingsTitle"],"115":["bookTitle"],"116":["shortTitle"],"117":["docketNumber"],"118":["numPages"],"119":["programTitle"],"120":["issuingAuthority"],"121":["filingDate"],"122":["genre"],"123":["archive"]}} \ No newline at end of file +Zotero.Connector_Types.schema = {"itemTypes":{"1":["note","Note",[false],[],{},"treeitem-note.png"],"2":["book","Book",[1,2,3,5,4],[110,90,3,30,4,45,6,7,8,14,118,87,11,116,1,27,123,19,62,18,2,22],{},"treeitem-book.png"],"3":["bookSection","Book Section",[1,29,2,3,5,4],[110,90,115,3,30,4,45,6,7,8,14,10,87,11,116,1,27,123,19,62,18,2,22],{"115":12},"treeitem-bookSection.png"],"4":["journalArticle","Journal Article",[1,2,3,27,4],[110,90,12,4,5,10,14,3,28,29,25,87,26,13,116,1,27,123,19,62,18,2,22],{},"treeitem-journalArticle.png"],"5":["magazineArticle","Magazine Article",[1,2,27,4],[110,90,12,4,5,14,10,87,13,116,1,27,123,19,62,18,2,22],{},"treeitem-magazineArticle.png"],"6":["newspaperArticle","Newspaper Article",[1,2,27,4],[110,90,12,7,6,14,15,10,87,116,13,1,27,123,19,62,18,2,22],{},"treeitem-newspaperArticle.png"],"7":["thesis","Thesis",[1,2],[110,90,69,89,7,14,118,87,116,1,27,123,19,62,18,2,22],{"69":108,"89":8},"treeitem-thesis.png"],"8":["letter","Letter",[1,2,16],[110,90,65,14,87,116,1,27,123,19,62,18,2,22],{"65":108},"treeitem-letter.png"],"9":["manuscript","Manuscript",[1,2,4],[110,90,66,7,14,118,87,116,1,27,123,19,62,18,2,22],{"66":108},"treeitem-manuscript.png"],"10":["interview","Interview",[6,2,7,4],[110,90,14,64,87,116,1,27,123,19,62,18,2,22],{"64":109},"treeitem-interview.png"],"11":["film","Film",[8,2,10,9],[110,90,21,14,122,63,77,87,116,1,27,123,19,62,18,2,22],{"21":8,"122":108,"63":109},"treeitem-film.png"],"12":["artwork","Artwork",[22,2],[110,90,59,61,14,87,116,123,19,62,18,1,27,2,22],{"59":109},"treeitem-artwork.png"],"13":["webpage","Web Page",[1,2,4],[110,90,91,70,14,116,1,27,87,2,22],{"91":12,"70":108},"treeitem-webpage.png"],"14":["attachment","Attachment",[false],[110,27,1],{},"treeitem.png"],"15":["report","Report",[1,2,5,4],[110,90,92,32,28,7,31,14,10,87,116,1,27,123,19,62,18,2,22],{"92":60,"32":108,"31":8},"treeitem-report.png"],"16":["bill","Bill",[12,2,28],[110,90,93,36,94,15,95,41,40,42,14,87,1,27,116,2,22],{"93":60,"94":4,"95":10},"treeitem-bill.png"],"17":["case","Case",[1,2,13],[111,90,43,97,44,117,98,42,96,87,116,1,27,2,22],{"111":110,"97":4,"117":60,"98":10,"96":14},"treeitem-case.png"],"18":["hearing","Hearing",[2],[110,90,46,7,8,45,99,10,41,40,42,14,87,116,1,27,2,22],{"99":60},"treeitem-hearing.png"],"19":["patent","Patent",[14,15,2],[110,90,7,102,48,120,50,121,10,103,51,52,53,54,87,116,1,27,2,22],{"50":60,"52":14},"treeitem-patent.png"],"20":["statute","Statute",[1,2],[112,90,36,55,101,100,10,15,40,42,87,116,1,27,2,22],{"112":110,"101":60,"100":14},"treeitem-statute.png"],"21":["email","E-mail",[1,2,16],[113,90,14,116,1,27,87,2,22],{"113":110},"treeitem-email.png"],"22":["map","Map",[20,2,5],[110,90,67,68,28,6,7,8,14,87,11,116,1,27,123,19,62,18,2,22],{"67":108},"treeitem-map.png"],"23":["blogPost","Blog Post",[1,23,2],[110,90,107,70,14,1,27,87,116,2,22],{"107":12,"70":108},"treeitem-blogPost.png"],"24":["instantMessage","Instant Message",[1,2,16],[110,90,14,87,116,1,27,2,22],{},"treeitem-instantMessage.png"],"25":["forumPost","Forum Post",[1,2],[110,90,104,79,14,87,116,1,27,2,22],{"104":12,"79":108},"treeitem-forumPost.png"],"26":["audioRecording","Audio Recording",[17,18,2,19],[110,90,71,28,4,45,7,72,14,77,87,11,116,123,19,62,18,1,27,2,22],{"71":109,"72":8},"treeitem-audioRecording.png"],"27":["presentation","Presentation",[24,2],[110,90,74,14,7,75,1,27,87,116,2,22],{"74":108},"treeitem-presentation.png"],"28":["videoRecording","Video Recording",[8,11,2,10,9],[110,90,63,28,4,45,7,76,14,77,87,11,116,1,27,123,19,62,18,2,22],{"63":109,"76":8},"treeitem-videoRecording.png"],"29":["tvBroadcast","TV Broadcast",[8,11,2,25,10,9],[110,90,119,105,63,7,78,14,77,87,116,1,27,123,19,62,18,2,22],{"119":12,"105":60,"63":109,"78":8},"treeitem-tvBroadcast.png"],"30":["radioBroadcast","Radio Broadcast",[8,11,2,25,10,9],[110,90,119,105,71,7,78,14,77,87,116,1,27,123,19,62,18,2,22],{"119":12,"105":60,"71":109,"78":8},"treeitem-radioBroadcast.png"],"31":["podcast","Podcast",[26,2,25],[110,90,28,105,80,77,1,27,87,116,2,22],{"105":60,"80":109},"treeitem-podcast.png"],"32":["computerProgram","Computer Program",[21,2],[110,90,28,81,14,82,7,83,88,11,116,1,2,123,19,62,18,27,22],{"83":8},"treeitem-computerProgram.png"],"33":["conferencePaper","Conference Paper",[1,2,3,5,4],[110,90,14,114,84,7,8,4,10,3,87,26,11,116,1,27,123,19,62,18,2,22],{"114":12},"treeitem-conferencePaper.png"],"34":["document","Document",[1,2,3,27,4],[110,90,8,14,87,116,1,27,123,19,62,18,2,22],{},"treeitem-document.png"],"35":["encyclopediaArticle","Encyclopedia Article",[1,2,3,5,4],[110,90,85,3,30,4,45,6,7,8,14,10,11,116,1,27,87,123,19,62,18,2,22],{"85":12},"treeitem-encyclopediaArticle.png"],"36":["dictionaryEntry","Dictionary Entry",[1,2,3,5,4],[110,90,86,3,30,4,45,6,7,8,14,10,87,11,116,1,27,123,19,62,18,2,22],{"86":12},"treeitem-dictionaryEntry.png"]},"creatorTypes":{"1":["author","Author"],"2":["contributor","Contributor"],"3":["editor","Editor"],"4":["translator","Translator"],"5":["seriesEditor","Series Editor"],"6":["interviewee","Interview With"],"7":["interviewer","Interviewer"],"8":["director","Director"],"9":["scriptwriter","Scriptwriter"],"10":["producer","Producer"],"11":["castMember","Cast Member"],"12":["sponsor","Sponsor"],"13":["counsel","Counsel"],"14":["inventor","Inventor"],"15":["attorneyAgent","Attorney/Agent"],"16":["recipient","Recipient"],"17":["performer","Performer"],"18":["composer","Composer"],"19":["wordsBy","Words By"],"20":["cartographer","Cartographer"],"21":["programmer","Programmer"],"22":["artist","Artist"],"23":["commenter","Commenter"],"24":["presenter","Presenter"],"25":["guest","Guest"],"26":["podcaster","Podcaster"],"27":["reviewedAuthor","Reviewed Author"],"28":["cosponsor","Cosponsor"],"29":["bookAuthor","Book Author"]},"fields":{"1":["url"],"2":["rights"],"3":["series"],"4":["volume"],"5":["issue"],"6":["edition"],"7":["place"],"8":["publisher"],"10":["pages"],"11":["ISBN"],"12":["publicationTitle"],"13":["ISSN"],"14":["date"],"15":["section"],"18":["callNumber"],"19":["archiveLocation"],"21":["distributor"],"22":["extra"],"25":["journalAbbreviation"],"26":["DOI"],"27":["accessDate"],"28":["seriesTitle"],"29":["seriesText"],"30":["seriesNumber"],"31":["institution"],"32":["reportType"],"36":["code"],"40":["session"],"41":["legislativeBody"],"42":["history"],"43":["reporter"],"44":["court"],"45":["numberOfVolumes"],"46":["committee"],"48":["assignee"],"50":["patentNumber"],"51":["priorityNumbers"],"52":["issueDate"],"53":["references"],"54":["legalStatus"],"55":["codeNumber"],"59":["artworkMedium"],"60":["number"],"61":["artworkSize"],"62":["libraryCatalog"],"63":["videoRecordingFormat"],"64":["interviewMedium"],"65":["letterType"],"66":["manuscriptType"],"67":["mapType"],"68":["scale"],"69":["thesisType"],"70":["websiteType"],"71":["audioRecordingFormat"],"72":["label"],"74":["presentationType"],"75":["meetingName"],"76":["studio"],"77":["runningTime"],"78":["network"],"79":["postType"],"80":["audioFileType"],"81":["version"],"82":["system"],"83":["company"],"84":["conferenceName"],"85":["encyclopediaTitle"],"86":["dictionaryTitle"],"87":["language"],"88":["programmingLanguage"],"89":["university"],"90":["abstractNote"],"91":["websiteTitle"],"92":["reportNumber"],"93":["billNumber"],"94":["codeVolume"],"95":["codePages"],"96":["dateDecided"],"97":["reporterVolume"],"98":["firstPage"],"99":["documentNumber"],"100":["dateEnacted"],"101":["publicLawNumber"],"102":["country"],"103":["applicationNumber"],"104":["forumTitle"],"105":["episodeNumber"],"107":["blogTitle"],"108":["type"],"109":["medium"],"110":["title"],"111":["caseName"],"112":["nameOfAct"],"113":["subject"],"114":["proceedingsTitle"],"115":["bookTitle"],"116":["shortTitle"],"117":["docketNumber"],"118":["numPages"],"119":["programTitle"],"120":["issuingAuthority"],"121":["filingDate"],"122":["genre"],"123":["archive"]}} \ No newline at end of file diff --git a/chrome/content/zotero/xpcom/data/cachedTypes.js b/chrome/content/zotero/xpcom/data/cachedTypes.js index 1b23b69de3..5666539761 100644 --- a/chrome/content/zotero/xpcom/data/cachedTypes.js +++ b/chrome/content/zotero/xpcom/data/cachedTypes.js @@ -336,7 +336,7 @@ Zotero.ItemTypes = new function() { } } - // DEBUG: only have icons for some types so far + // DEBUG: only have icons for some types so far. Done. switch (itemType) { case 'attachment-file': case 'attachment-link': @@ -345,14 +345,21 @@ Zotero.ItemTypes = new function() { case 'attachment-pdf': case 'artwork': case 'audioRecording': + case 'bill': case 'blogPost': case 'book': case 'bookSection': + case 'case': case 'computerProgram': case 'conferencePaper': + case 'dictionaryEntry': + case 'document': case 'email': + case 'encyclopediaArticle': case 'film': case 'forumPost': + case 'hearing': + case 'instantMessage': case 'interview': case 'journalArticle': case 'letter': @@ -361,9 +368,12 @@ Zotero.ItemTypes = new function() { case 'map': case 'newspaperArticle': case 'note': + case 'patent': case 'podcast': + case 'presentation': case 'radioBroadcast': case 'report': + case 'statute': case 'thesis': case 'tvBroadcast': case 'videoRecording': diff --git a/chrome/skin/default/zotero/treeitem-bill.png b/chrome/skin/default/zotero/treeitem-bill.png new file mode 100644 index 0000000000000000000000000000000000000000..0b18247da5850f3c2486373a3e179acd2772e8aa GIT binary patch literal 641 zcmV-{0)G98P);68^@7JE5sw#jpE*579S@TLkU(6yap1yN*Zuy>-hV%Q_v4Ar&!63c8OBr(ZRhFu z_kWs36-AmgZCT>x!RqM;Zu9tqvoHI~k@UmYo_g(*J3c%2{N8}7I+|qKPQzv}7t>%W zsu&9G)UmCzkDYSw{fBnuW4j;1fKV_nicw`$8C6D=F_qu`zUiK$2Oc?5UVY+D(`I@R zW`KlwqLftWHH3Z2_XVNfKn>VgT~k=@- z+N>c>0|@A_HbI9Jn`v0~7cfIF(TS69zaomDS1QtgvaBBfGEPLHccO2~3jc>n^6}^HAEh-2#VxC7YYcDXv!L9X= z-R*SOUvIs;n`8(LxP4~^2|JsiN^hq6cU}5dn4v1~Kl{eT7pm&f$PoY`hyVe%y8G*S bxB&kH@RuR86sIAS00000NkvXXu0mjfZBi!% literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/treeitem-case.png b/chrome/skin/default/zotero/treeitem-case.png new file mode 100644 index 0000000000000000000000000000000000000000..e213cd5b4af378b1e85f28f678e5d979cf4a258d GIT binary patch literal 753 zcmVMBDoPcULZ<=_XyBXH7|0cLxaW99 zlhOXrNAdJOW6cJt8c&`()A_8&cF`*F|AzV3e4iiSBK>hc(3t)iG#s{VOf3XWHF5Q1 z1M`9Qnl`&hz{Kt{#nyEUxd-SXIrTUfcc_@pi)q;Z_u9cIwjsAfE`NU6jy(SO$ zItOe{oPl#ahmOdhK|Id8q`K)okgVj zw%|eng1cCxdipvp&h4sDsdQEtw2E3l5WsK(AW^Bh7IS(NXPHQa1S8|X{sdAjdsV8j z#z0LRSjhu9rNLf9nsu}(0=^jw8KkJpRPu+$Od7Z)1aHTSDYcyf4%Xqu>N=WPEG#c& zozKas#qgF02DmPM^8Huzy&U_ae<^Q7WJ=r7-=T)C-5)$l4M0RRKRZFK=MXQ~DB}-( z)c^cl_fvgI{+r01O7-P4$&ak0B}S8aezE)Jc=hhuXuPUAYQnR8Hy^C!vrc9uV}Jaj jMZR^k^ahFlOMn3YAMS4CfxpuR00000NkvXXu0mjfaN=Z0 literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/treeitem-dictionaryEntry.png b/chrome/skin/default/zotero/treeitem-dictionaryEntry.png new file mode 100644 index 0000000000000000000000000000000000000000..8dcfb269dad3c5bddc218096662ff996699f6744 GIT binary patch literal 611 zcmV-p0-XJcP)~1D~Z+2&sR9k%T_RY?l?|biiGsf2THrNcqctv3z|F?4~<(2I9(C_zA%w}Qnf{o&% z!=0UdkCHySl;}}T=N-qv;n~@1u0>wry{GHz5X=_2AsOWR%DrwEopu|oRtwE$Q^ljb zy?r|Og0Ks^C96l^$PA_y^i7!Npy?n$K*X-=;!`?})Z*gjkLmOq%DhzsazG#$EEElH zk)%>7CC9dHoH|Y|?jRWMV2I!@67EDTN$x-bCH|J6O}cfMR5dwe$0S^YFn1D!5`-XR zSjpXeuj2HF-I&x22}BGExV6xQ?tn?!xeFLi9z)ub=;kk#oMa-QBA?YbD;SnQU^NH& zsb_MS-h2uF=PxwAb&UH7sgGQkU_j^IPwy7T_Ogvi%CHVe7Byb0` z*{$Bd^E|8^f5r0A7q#|iPel0<35`kxlQT0TxA1V|Ip)YE-2j(bJvjisQuR-HEunow zq*s{?+;W+ptrZO-t|atKqQUBYKFb)!a)I&de15i3tBnm!GY0U`*ex2MWmzyO@>#|( xmaC4F&;G7f>kpQe-r*i5JDoaXcpQHO7yxD5B8?JM16%+A002ovPDHLkV1f}o71#g( literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/treeitem-document.png b/chrome/skin/default/zotero/treeitem-document.png new file mode 100644 index 0000000000000000000000000000000000000000..0212ba5627a631112c6257b8fb49b44652e7fb0a GIT binary patch literal 373 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8gaDrq*Kgmxef|3N{{8#kzkmPx_wT1qpFV&7{OZ-Kj~_q2 zfB*i`qerJtpZ@aY%i+U^U%q_#`t|EKZ{9q9{P_9v=SPnoefI3xhYug#zI}V>(4ikc ze*F6N>*vp(zkmNedGh3$GiUz%`Sbt(|C5`Xnt^sHlmz(&1G)GBLrjeHTcFx{PZ!6K zid!M)ZVDY%;BW}+F|GdY>-g~hf1?*mdheN^?_oG$dvxzR6(xm}!qfklb9*egDq-v= zUN)7}>E-)zmV(!pj yx$kh|YP8o`o`1629(+8u#6bUJ{H#>r1cnrMi5q5X0-ge$!rhrq zV%ij;fbLQ)TPiaghHYH5xS6WipyprbeZA@2-!y{7+e%mKd3cL z(qtx`dGp3QFE6EFw7qcPy!YmuIrqL9sl2jc1Hh%{>+5BeQlBcyu45RV*5>Bk;(iyA zL|jHp2yP-&#E*^D)lE{_zHWyb<@vpOon?zf@cMoKTdihaDHL*Fo6YL<^2sojUf$zhJN1Id_jxC`h z5CqC70TTwnSqy{@TcBeTL}T{FdTa?D8VsHM69y4CPBj=M2q-5s2tX0Tig;9>=l!Pz zdfWmhJ$$&nv%@Fe$2VtBZ-MLNkyC3hfXw0|q!t$70QuPyP%oMn+^yBX$LJAm&CbFh znw(4^NzyTfeGYX5oNm0bwFS{v7}GQ`4FfXiG#IAI4WbmS{e5V6I^ei23~;~cq;tk?6WUhS&>U6ao9#vJM2Q-ZYk kbsa=|?AMGp_D6sL0Ds&aKP(yFNB{r;07*qoM6N<$f*gh>^Z)<= literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/treeitem-forumPost.png b/chrome/skin/default/zotero/treeitem-forumPost.png index 03ddd799fa0a3aec561c75d4221f195db65d6eb9..e54ebebafb5072fabac9a0f3d8a79fcee3265f9f 100644 GIT binary patch delta 666 zcmV;L0%iUC1m^{iS$}y+L_t(I%YBkw^$M;J9QqD{pIxN$0_xw9|;v%{0 zz>j;*;rxHk;W?KFfVUMF=Mo(n;1Q?Ci@c7F!0MtlD>E1Bd9dr|BR zA+Y@-m|rHaED?NOB=}?{m|S3BUf2+)s|=jg_e;uq90z7?1Yc-y>N|mHo`LZjgR!p+ zMl2hG0`(yNdjq!mG_CrPhR5d^jMDJ1g%#Kxf{dDXe}f4}`P=TC^v-%5y4!Y3mbcFK zfR$_x_9nwKjDJJQ*#r3*zEm0P3B|?jC=%>LVoC-?c{)eOtMnh7qNN{ejy2sM{pS^m zgFHJm@(buuM4>=<5Vr$&Kzw{B?uPr;(1Yf=#g)zADkWnx=MJH@SJ7*5t}drx?8z zkZa#Usy0AUZNRf(ATi%$cRx{^=@nGr#wj=z@h~+lrwz}I1jz%yjXvPI9*EQcSL+FK zy9mU|&3_~?^q!1UFk5&C1L{&Fspk>f0mNtsgf#>aRRm#A0fAxxgUw1zW&46tU{(gd zsg=hdRN9BQE+D=e5bG%Pd#wdH8`puC_oFdU7S_utFf}CcUzNoB2Shex9k|?P@r&+S z@sH|W^AmQi_=Ib%$1YVBy)KD8Y-*J7xdeXz-V=!2bQ(-0DgXcg07*qoM6N<$g29wE A^Z)<= delta 557 zcmV+|0@D5G1^Wb$S$_>lL_t&-83n<=uby)l2jJ`eKF@pF(^E&4h%*uKJ2B9R7=(p^ zE(VjuVq+sVG1+XAjs{8p1EWDpL?R@D7+53?+Eg1v&w0=D+#lCfNxbmhrPp`&PrNqD zIh;g+LW;Dd``4S-^I83Ui~r+<$Lz)H<&|z(Y4u2^&)39t8FheiViTA(TD$zw! zG^v1u23)*n9%RE;vYcDXv@!|UC-p+K_yN_@8k_@2%x9`p%VRuui^k%Am)}^n&3|0B? v#kViLQYKYTL{0$+K?Ddm?Cx*p;UfGGL^vK+HG^sr00000NkvXXu0mjfjX@4X diff --git a/chrome/skin/default/zotero/treeitem-hearing.png b/chrome/skin/default/zotero/treeitem-hearing.png new file mode 100644 index 0000000000000000000000000000000000000000..e0dc30e8568f20040eed0ffc59b56cfae43c74ad GIT binary patch literal 1695 zcmaJ?dr;GM94|$YaUvEJ6=lnUf~U|XX=!Okg|?wkBv1+)k7G(`L)$@{lBTraHeZJ) zY&)kQ1DqnBpo4>Lwru1n=VCQ{IN54$?x^~e7?`$rC1#w z?djp?!D6vIRWYcB8D~0QcQ@wy&ZAd2Gt8r-Qt2czo3`T=!IJ67ECNuOa6O?Ra9u&( zX(F7(ay1&0Q|VMJPNF4ET-=G_I!qRZ&0>W|I4rm}hoFHhLT@xn!I489AYjx2!slvkEEEc4dnl|QVEL?I8+Go7&my%{+QG+<6BG6#T#j2@ll;o?yXq;@qV1lJCq&FJ>8>r{POx$U=A?Ju@l6N;MBIW4v9JF!zX zvH^F4+mDOf%DmayXVKTHOG=(D(VjL+9$8YS3JqV$+c0)n*%!jCHI40e^YlO6jul;t z3F^{nWBL;-uR&PDa{+@>V*d{C$D< z(DM_P@cryz-Gf_O@9lW8?}_c>KONVpgV!x#&HmHnWmHI6Zt3iuBduNCDV!NtWDQ7c zz0&sA&~vHsF1^IIcZKf2(F`@Ky*lyB(nPP-9y5P+-*(Ex(R?JT%B(NxeYxz9{P);v zS;Gy@vwY>7`JZz+ZrOq&<+0c}??y0f8a(K~ieLNI!qTeFqPoCmM^+40#>I>*(hLIM zyj?aDB%$XJStWPCz;*4nP1u^)it6gb$5n}S zzxdP)oiCq$bv^BOqWAELgW|mAE$Zd)HhN?w?e06}l3sFV$?_i}7cSUvG&8dO@^qggo%Qy> z{SWL!6}Rf*)T^9BXwU=A7O(t~WKrw(f$p2sA^iLF&E!7yFka9<(1TpLdghtd|6ET& z|2%T{!iLMm$lQbL>o>UR_IlkohY=SZLethg^NmqiqzU_`h)ZKZ0 z3s$i5WY;D@x%m0g#;1>)_SkecE_H1B_Tk11|KiLxX{Guxnct{u)DLv9Tv;)Gq-j9! Rd%^k3P({U~P4dij{{pR+gXsVO literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/treeitem-instantMessage.png b/chrome/skin/default/zotero/treeitem-instantMessage.png new file mode 100644 index 0000000000000000000000000000000000000000..7bc9233ea63c89d52a99494dd0f0735a29a3ec3b GIT binary patch literal 413 zcmV;O0b>4%P)i2vikyMR~)n*keF9=!Gc_n*K2@qsNT?}H4v4a974 z1ArVJApZ0B-@pGKzWw|E^3%Wn&p!V9|K$C@{}12&`+x7vzyG&i{r!LE6~yrB1;;^# zm?0Y=moxPMSn>r>N00000NkvXX Hu0mjf$^yWL literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/treeitem-magazineArticle.png b/chrome/skin/default/zotero/treeitem-magazineArticle.png index ea086b0428b38a89060a9a375185955b46ef8a16..b4aaad9a45c9abbee2d47611a6963101b64a8023 100644 GIT binary patch delta 440 zcmV;p0Z0De1BV2VS$~;HL_t&-8KuF`i;ZC%#^KNN_Mn)f%tDevel8Uo4J*k?DQ0aJ z^A9LnrL3%3C~WN5$YQc$H%pW$gGLQyL1JpkIcMJYd*7ZXj%HzMG}o1Evk{qM>h`NE zz+T`Ka2#w*LZ)dFO#(?MSlX1maAeQ+6Ubb>cr;;~%eP+M^?!f5`RI)cGQXXsxIg=y z5wo`GiE-Y3S{hPhDtQ-w9NM{sDkc8u-IpO%f6#8G$P~7>QW$vub;x=+B2i=t%b8+& zVx09-h$>T9P85^ZpD~b-VdlnJ&fhynuh&Bol8{71@OWwlE2uJsC8}@zmNUn8GxOpz zRj)V3!2|oKY=2{m*K_k!?t-eJuuQc)2wIz;!;UIKBoeE25mZt~l_`=$H5|6|+aLxl zl_YEf1{>Q%7gX+6s4|5yBQ}3^T_6XQZDbP)D!Ze~6zXIkQ9PYpWTZE?jfD>%Y1@{S zwk5itNez`{Q)G&e7J>b9cP_BngG&!ti|rp2nJV;T@-f=;!?sT%?T|XKumY1mFXZS$}d#L_t&-8KuEHYg9oP$Kl@`Cr3E222-d6LALN#D~QCD_JX8N zihKdVRuHVLwGhNFU}qs#+NIS(@J7I3At;gy3)ww6Gwy_RR|cNi08j{eM{h>HgDqazuVv#64Nt zWK8UDbzzPVU$$FZq%fW0x3edXQiQ-%AHTH}!%7Jim9H&tG?#rawQ6EK^iCnNj>0c3io5lFeaatk=}^nwnly z(`#zRlrlwylYfa~Fv@fiyKQ1pmqnMwB(p?O;er`O+jb1QOdfUoi_#uN#0fDb@t2t+ zfj>!!BH}EWfPj0kw!x&q?jF;~BwWO0vkjpC_R$R{_2*~VkEAVJq{#Mc>CUTjlCENQ v+$@0%Sw@yX8JQsokiZ5|y~hPf9L7(i;q(Z^C>$XG015yANkvXXu0mjftqHq; diff --git a/chrome/skin/default/zotero/treeitem-patent.png b/chrome/skin/default/zotero/treeitem-patent.png new file mode 100644 index 0000000000000000000000000000000000000000..d22fde8ba46eabd4335e4fa88077e80f96b92d62 GIT binary patch literal 782 zcmV+p1M&QcP)0XYhLR!1P*SpVQi>)dUV<_*6qInHGcnEb zQfX6|c{lO4l#RKaZC-XZ&u-_k%Q@eEE?Qa!_Tt0u@H@}<^E~``A^=3}gr(l4vU*i7 zyV6Lx=4yE7RGGkx6gV71cjvY=iqb#p!ylZn>j-Cf+b>x95wMRT==lzjH$f681f9ze zR{P)>$i_z3RfAovII&B>n%*Ds>XegyS_9EX5sW0f1d*FX&^tjGBX?Rzej4t{=ddW_ z9h>UH!(o9}TURNVdq{y5qM#$E1yaxnNWKtKkRh^p1YA9U=z#4*HY{(h_k{(nnF>pQ znJ2Y6(rFb^z)nJ2pnqIQ&_2v{yl+xxUhm5uO{Q#!J8DY)klFdHU2HvUSp%6 z*n}iP63IK?dpo;h@sj9~pcxo;VVTc-XLiP@DgefqE#NE=@oyUd-&HjLpsLIuSFXV-EMck)oQ(A`s%*^&wf0(rNiNHsU%=0Rw;WC z(kbc37l6fo`-0uR!pYkYv8U^3?nsh^@pw!K0TH3uYyx1_2>|JbXPmfskJ|1YAw9w! z9`N)1^Aesr;y5Nr5-ODn)oOL|CGi}f9!&iVwpK$khlIX10X$H6^A_stBJqvLhU$?V`QXqKme*s~gVDJ4A;LTs_e15jhc1;By a82kqHEPVYFAD2!50000ZnB#|^Ee*uq4L_t(|+G1obWo7^aMut8hsn0+hxXAFIp$N_sQ&3Vm}NWQK>&e`0rmG$#Xle?IF0Akz^=!lSS- z=NHh1AHRR&#UM4znal@(m;r>bx*#?of#Kn^UszqBB*(?TnaO$($aFxFa7a%t`2Oe5 z|Ia^u;Kd*{Ovy|KftUe=vAQ5UE{@^J)8E*`K%SF?HEro3PS8=0b(H_miqkjvK*fo%Ne5b;unTH4DT6qD1fYIAY(W|4uBd)3IK)j cXMg|$0O;6E`BFhXoB#j-07*qoM6N<$f^#m+9{>OV delta 589 zcmV-T01BnHYBn<>-K}|sb0I$e51&ZmBAt!$V8%ab#R5;6xQ_pJ?Q4pT}LFwAm zL%O^1kn|{pqTs3IR1gt83PSKuY!B_J|A7ca=*g>sm$HQ(N)Ekeh_0hG(-dw<@)-1S-xc+D!@wd^?< zZJmEgrBdmp@B5#b+nrFrhqG5JaA)KDNN816=hS>YZ)daF)$yZ(m6$?r0N}drP#|Lr zh-v(+Xhm&?r{gBQ$P00lhw{i%4Vk}S&{6fH@TL_)z}?4V#xn&@O<0Ig>`O&}bF zascBGtUc5R*ANU0WFUEP{^6rYK;YSoc9DM|wEbF}e?!bL19ktcbyW{|C6NI4hqZsa zYQXRt^U)Xf0I$XGG*F?BDj);r`7+$kAMr%-d(+wTJmE)cCzHwf0fTREtVtu}83jGr zZs6NTx&ipXg%YUHTFxW}6PQ|oow+q#36%<90WnzEe zIL>ObunB*^ZUGh)5=C-F4U52)N(EA>6!}?ZU>L?=sNyORgWA(2c(C__g9%8T@AZ1nXf$|L(=_7~ z8U70xbmLa#-OnpYjSmYoh=61f3mP?NN>Z=a`M%%phe@J_EnT0QpH7V3cG~XA#&PRl b)Zh6(yXt(^KFGF}00000NkvXXu0mjf4OSw; diff --git a/chrome/skin/default/zotero/treeitem-statute.png b/chrome/skin/default/zotero/treeitem-statute.png new file mode 100644 index 0000000000000000000000000000000000000000..d3fffb6d989b4e09dbb0fb3bca876e41f42c660c GIT binary patch literal 706 zcmV;z0zLhSP)*wetruo^Ag2=LamM1T#~4RmC^m`_ zs}H7d&XJ}mg+hU?tu0noRvyjI&o2SRAeYZFesYkts79I^jJ7!A7%6nJwq8O?iT55M z1OQ` zbL{!Cp5o*IRmE9PInMCSPjTwfT~J+EYkz}tjxY=fg5Yf6EQ@DG$0kMJ9h^&$W}9BU zP1oj2;?MWVkKIEl)r=Y;L^Cx2q|>!)qJJ8zE7-V*-Cf7V8_2#1c0N975t~+&QUpQJ z5(uo(-O_`%Rj@U@t>JYAgd!>L?0Idxtd#oW2gc!jinsAEva8|kF4#Ic**mmml_{d^$s}Q5Q)KCys4sfck5bP1SyeHwh2`A<@N&t2j0^lgHC_^(pAAPCNjwl+>AN%C4Ll>_8Hjda%9 oS~i=#*e)>KsPlg0=2)Qg6BCqJ=F8HdGXMYp07*qoM6N<$f@i)wr~m)} literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/treeitem-videoRecording.png b/chrome/skin/default/zotero/treeitem-videoRecording.png index b0ce7bb198a3b268bd634d2b26e9b710f3797d37..af71c30610862c76f07e948d8c28433c7d338f9a 100644 GIT binary patch delta 651 zcmV;60(AY21=t0US$}FtL_t(I%bin8Yg%CtJy+Buz5X`Ah`g>D$SI0xH-ggKY75 zJi_OlogHj$ZenX|3tq1mM2^$b)5!Yzx{Y?_{ew*mhr@3v50lHSLi$_$)>sN#C}&x4|CBvaHzccIb3ETwGj;+u;Q&7K?12 zvbMH{jg1XNqtQJ&)1&sxeS$`i%L_t(I%cYY~XcIvg#ounbo6H)UgNX~$QcHp*N)zx8=&5>9 zK~OXYgCGdiOHUdQym|Cw4*?Ms|A1bKrz%A1Q4fk#G$K+P} zlM6p~nD4ze-|+1kVHo0np27a2TCKhhf?$+T zFKB#6u9Kx#)=kk99bq~d5sHjxqA1ehi;z+-lY68Q>43%|GD*C&^%l>23)nqy6{bIq z`POkX+7poSjDN?|Pm*+8fFey6C)@ifDBXVyT41d}nI)EtpWs=ytu+?S zv!oN(L5YG>Wb1*5aB From d7b19a05430868b36ae5f9a65da17001dd082196 Mon Sep 17 00:00:00 2001 From: gracile-fr Date: Fri, 4 May 2012 00:39:50 +0200 Subject: [PATCH 14/38] Add attribution for Fugue Icons. --- chrome/content/zotero/about.xul | 1 + 1 file changed, 1 insertion(+) diff --git a/chrome/content/zotero/about.xul b/chrome/content/zotero/about.xul index 12a1b32c03..2069077736 100644 --- a/chrome/content/zotero/about.xul +++ b/chrome/content/zotero/about.xul @@ -279,6 +279,7 @@