Replace all E4X in data syncing with DOM methods
This should make XML generation much faster and will hopefully fix remaining random XML errors in large uploads. This needs testing.
This commit is contained in:
parent
f873948740
commit
53e6b2a572
3 changed files with 320 additions and 298 deletions
|
@ -223,13 +223,23 @@ Zotero.Relation.prototype.erase = function () {
|
|||
}
|
||||
|
||||
|
||||
Zotero.Relation.prototype.toXML = function () {
|
||||
var xml = <relation/>;
|
||||
xml.@libraryID = this.libraryID;
|
||||
xml.subject = this.subject;
|
||||
xml.predicate = this.predicate;
|
||||
xml.object = this.object;
|
||||
return xml;
|
||||
Zotero.Relation.prototype.toXML = function (doc) {
|
||||
var relationXML = doc.createElement('relation');
|
||||
relationXML.setAttribute('libraryID', this.libraryID);
|
||||
|
||||
var elem = doc.createElement('subject');
|
||||
elem.appendChild(doc.createTextNode(this.subject));
|
||||
relationXML.appendChild(elem);
|
||||
|
||||
var elem = doc.createElement('predicate');
|
||||
elem.appendChild(doc.createTextNode(this.predicate));
|
||||
relationXML.appendChild(elem);
|
||||
|
||||
var elem = doc.createElement('object');
|
||||
elem.appendChild(doc.createTextNode(this.object));
|
||||
relationXML.appendChild(elem);
|
||||
|
||||
return relationXML;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -239,9 +239,9 @@ Zotero.Relations = new function () {
|
|||
}
|
||||
|
||||
|
||||
this.xmlToRelation = function (xml) {
|
||||
this.xmlToRelation = function (relationNode) {
|
||||
var relation = new Zotero.Relation;
|
||||
var libraryID = xml.@libraryID.toString();
|
||||
var libraryID = relationNode.getAttribute('libraryID');
|
||||
if (libraryID) {
|
||||
relation.libraryID = parseInt(libraryID);
|
||||
}
|
||||
|
@ -252,9 +252,9 @@ Zotero.Relations = new function () {
|
|||
}
|
||||
relation.libraryID = parseInt(libraryID);
|
||||
}
|
||||
relation.subject = xml.subject.toString();
|
||||
relation.predicate = xml.predicate.toString();
|
||||
relation.object = xml.object.toString();
|
||||
relation.subject = _getFirstChildContent(relationNode, 'subject');
|
||||
relation.predicate = _getFirstChildContent(relationNode, 'predicate');
|
||||
relation.object = _getFirstChildContent(relationNode, 'object');
|
||||
return relation;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue