- use priority exclusively for translator ordering

- full disambiguation support (including adding additional authors to disambiguate, adding first names, or adding a letter after the year)
- brings Zotero into line with current CSL revision
- fixes miscellaneous issues with new CSL interpreter
- closes #614, Same-Year Citation Suffix problems
This commit is contained in:
Simon Kornblith 2007-08-04 22:45:08 +00:00
parent 8e8bd4dc9c
commit 2615dc9684
6 changed files with 812 additions and 544 deletions

View File

@ -356,13 +356,13 @@ var Zotero_File_Interface = new function() {
var csl = Zotero.Cite.getStyle(style);
var itemSet = csl.generateItemSet(items);
var itemIDs = [];;
var itemIDs = [];
for (var i=0; i<items.length; i++) {
itemIDs.push(items[i]);
}
// add HTML
var bibliography = csl.createCitation(itemSet, itemIDs, "HTML", 1, null, null);
var bibliography = csl.createCitation(itemSet, itemSet.getItemsByIds(itemIDs), "HTML", 1, null, null);
var str = Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
str.data = bibliography;
@ -370,7 +370,7 @@ var Zotero_File_Interface = new function() {
transferable.setTransferData("text/html", str, bibliography.length*2);
// add text
var bibliography = csl.createCitation(itemSet, itemIDs, "Text", 1, null, null);
var bibliography = csl.createCitation(itemSet, itemSet.getItemsByIds(itemIDs), "Text", 1, null, null);
var str = Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
str.data = bibliography;

View File

@ -106,7 +106,7 @@ Zotero.CSL = function(csl) {
// load localizations
this._terms = Zotero.CSL.Global.parseLocales(this._csl.terms);
// load class defaults
// load class
this.class = this._csl["@class"].toString();
Zotero.debug("CSL: style class is "+this.class);
@ -124,32 +124,6 @@ Zotero.CSL._namesVariables = {
"author":true
}
Zotero.CSL._textVariables = {
"title":true,
"container-title":true,
"collection-title":true,
"publisher":true,
"locator":true,
"pages":true,
"status":true,
"identifier":true,
"version":true,
"volume":true,
"issue":true,
"number-of-volumes":true,
"medium":true,
"edition":true,
"genre":true,
"note":true,
"annote":true,
"abstract":true,
"keyword":true,
"number":true,
"URL":true,
"DOI":true,
"status":true
}
/*
* generate an item set
*/
@ -160,42 +134,36 @@ Zotero.CSL.prototype.generateItemSet = function(items) {
/*
* create a citation (in-text or footnote)
*/
Zotero.CSL.prototype.createCitation = function(itemSet, itemIDs, format, position, locators, locatorTypes) {
Zotero.CSL.prototype.createCitation = function(itemSet, items, format, position, locators, locatorTypes) {
var context = this._csl.citation;
if(!context) {
throw "CSL: createCitation called on style with no citation context";
}
if(!items.length) {
throw "CSL: createCitation called with no items";
}
// get items
var items = itemSet.getItemsByIds(itemIDs);
var string = new Zotero.CSL.FormattedString(this, format);
var lasti = items.length-1;
var string = new Zotero.CSL.FormattedString(this, format, context.layout.@delimiter.toString());
for(var i in items) {
if(items[i] == undefined) continue;
if(locators) {
var locatorType = locatorTypes[i];
var locator = locators[i];
} else {
var locatorType = false;
var locator = false;
if(locators) {
locatorType = locatorTypes[i];
locator = locators[i];
}
var citationString = this._getCitation(items[i], context, format, position, locator, locatorType);
var citationString = new Zotero.CSL.FormattedString(this, format);
this._processElements(items[i], context.layout, citationString,
context, position, locator, locatorType);
string.concat(citationString);
if(context.@delimiter.length() && i != lasti) {
// add delimiter if one exists, and this isn't the last element
string.append(context.@delimiter.toString());
}
}
// add citation prefix or suffix
string.string = context.layout.@prefix.toString() + string.string;
if(context.layout.@suffix.length()) {
string.append(context.layout.@suffix.toString());
}
return string.get();
var returnString = new Zotero.CSL.FormattedString(this, format);
returnString.append(string.get(), context.layout);
return returnString.get();
}
/*
@ -231,8 +199,11 @@ Zotero.CSL.prototype.createBibliography = function(itemSet, format) {
for(var i in itemSet.items) {
var item = itemSet.items[i];
if(item == undefined) continue;
var string = this._getCitation(item, context, format, "first");
var string = new Zotero.CSL.FormattedString(this, format);
this._processElements(item, context.layout, string,
context, "first");
if(!string) {
continue;
}
@ -290,19 +261,6 @@ Zotero.CSL.prototype.createBibliography = function(itemSet, format) {
return output;
}
/*
* get a citation, given an item and bibCitElement
*/
Zotero.CSL.prototype._getCitation = function(item, context, format, position, locator, locatorType) {
Zotero.debug("CSL: generating citation for item");
var formattedString = new Zotero.CSL.FormattedString(this, format);
this._processElements(item, context.layout, formattedString,
context, position, locator, locatorType);
return formattedString;
}
/*
* gets a term, in singular or plural form
*/
@ -337,40 +295,14 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
if(!children.length()) return false;
var variableSucceeded = false;
// Special routine for sorted names
if(formattedString.format == "Sort") {
for(var j=0; j<variables.length; j++) {
var creators = item.getNames(variables[j]);
if(creators.length) {
newString = formattedString.clone();
for each(var creator in creators) {
var name = creator.getNameVariable("lastName");
var firstName = creator.getNameVariable("firstName");
if(name && firstName) name += ", ";
name += firstName;
newString.append(name);
}
formattedString.concat(newString);
variableSucceeded = true;
}
}
return variableSucceeded;
}
var isShort = element.@form.toString() == "short";
for(var j=0; j<variables.length; j++) {
var success = false;
newString = formattedString.clone();
if(context.option.(@name == "subsequent-author-substitute").length()
if(formattedString.format != "Sort" && variables[j] == "author"
&& context.option.(@name == "subsequent-author-substitute").length()
&& item.getProperty("subsequent-author-substitute")
&& variables[j] == "author") {
&& context.localName() == "bibliography") {
newString.append(context.option.(@name == "subsequent-author-substitute").@value.toString());
success = true;
} else {
@ -386,6 +318,7 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
if(name == "name") {
var useEtAl = false;
if(context) {
// figure out if we need to use "et al"
var etAlMin = context.option.(@name == "et-al-min").@value.toString();
var etAlUseFirst = context.option.(@name == "et-al-use-first").@value.toString();
@ -402,12 +335,37 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
useEtAl = true;
}
// parse authors into strings
// add additional names to disambiguate
if(variables[j] == "author" && useEtAl) {
var disambigNames = item.getProperty("disambiguate-add-names");
if(disambigNames != "") {
maxCreators = disambigNames;
if(disambigNames == creators.length) useEtAl = false;
}
}
var authorStrings = [];
var firstName, lastName;
if(child.@form == "short") {
var fullNames = item.getProperty("disambiguate-add-givenname").split(",");
}
}
// parse authors into strings
for(var i=0; i<maxCreators; i++) {
if(formattedString.format == "Sort") {
// for sort, we use the plain names
var name = creators[i].getNameVariable("lastName");
var firstName = creators[i].getNameVariable("firstName");
if(name && firstName) name += ", ";
name += firstName;
newString.append(name);
} else {
var firstName = "";
if(!isShort && child.@form != "short") {
if(child.@form != "short" || (fullNames && fullNames.indexOf(i) != -1)) {
if(child["@initialize-with"].length()) {
// even if initialize-with is simply an empty string, use
// initials
@ -420,6 +378,10 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
firstName += firstNames[k][0].toUpperCase()+child["@initialize-with"].toString();
}
}
if(firstName[firstName.length-1] == " ") {
firstName = firstName.substr(0, firstName.length-1);
}
} else {
firstName = creators[i].getNameVariable("firstName");
}
@ -438,7 +400,9 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
authorStrings.push((firstName ? firstName+" " : "")+lastName);
}
}
}
if(formattedString.format != "Sort") {
// figure out if we need an "and" or an "et al"
var joinString = (child["@delimiter"].length() ? child["@delimiter"].toString() : ", ");
if(creators.length > 1) {
@ -458,14 +422,16 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
}
// check whether to use a serial comma
if((authorStrings.length == 2 && child["@delimiter-precedes-last"] != "always") ||
if((authorStrings.length == 2 && (child["@delimiter-precedes-last"] != "always" || useEtAl)) ||
(authorStrings.length > 2 && child["@delimiter-precedes-last"] == "never")) {
var lastString = authorStrings.pop();
authorStrings[authorStrings.length-1] = authorStrings[authorStrings.length-1]+" "+lastString;
}
}
newString.append(authorStrings.join(joinString), child);
} else if(name == "label" && variables[j] != "author") {
}
} else if(formattedString.format != "Sort" &&
name == "label" && variables[j] != "author") {
newString.append(this._getTerm(variables[j], (maxCreators != 1), child["@form"].toString()), child);
}
}
@ -487,7 +453,6 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
*/
Zotero.CSL.prototype._processElements = function(item, element, formattedString,
context, position, locator, locatorType, ignore, isSingle) {
if(!ignore) {
ignore = new Array();
ignore[0] = new Array(); // for variables
@ -513,8 +478,8 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString,
var name = child.localName();
if(name == "text") {
if(child["@term-name"].length()) {
var term = this._getTerm(child["@term-name"].toString(), child.@plural.length(), child.@form.toString());
if(child["@term"].length()) {
var term = this._getTerm(child["@term"].toString(), child.@plural.length(), child.@form.toString());
if(term) {
formattedString.append(term, child);
}
@ -527,7 +492,12 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString,
for(var j=0; j<variables.length; j++) {
if(ignore[0][variables[j]]) continue;
if(variables[j] == "locator") {
// special case for locator
var text = locator;
} else {
var text = item.getText(variables[j], form);
}
if(text) {
newString.append(text);
@ -547,12 +517,44 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString,
if(!ignore[1][child.@macro.toString()]) {
var newString = formattedString.clone(child.@delimiter.toString());
var success = this._processElements(item, macro, newString,
context, position, locatorType, ignore);
context, position, locator, locatorType, ignore);
formattedString.concat(newString, child);
dataAppended = true;
}
}
} else if(name == "label") {
var form = child.@form.toString();
var variables = child["@variable"].toString().split(" ");
var newString = formattedString.clone(child.@delimiter.toString());
var success = false;
for(var j=0; j<variables.length; j++) {
if(ignore[0][variables[j]]) continue;
if(variables[j] == "locator") {
// special case for locator
var term = locatorType;
var value = locator;
} else {
var term = variables[j];
var value = item.getText(variables[j]);
}
if(term && value) {
var isPlural = value.indexOf("-") != -1 || value.indexOf("—") != -1 || value.indexOf(",") != -1;
var text = this._getTerm(term, isPlural, child.@form.toString());
if(text) {
newString.append(text);
success = true;
}
}
}
if(success) {
formattedString.concat(newString, child);
}
} else if(name == "names") {
var variables = child["@variable"].toString().split(" ");
var newString = formattedString.clone(child.@delimiter.toString());
@ -625,37 +627,41 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString,
var newName = newChild.localName();
var newForm = newChild.@form.toString();
if(newName == "text") {
var string = this.CSL._getTerm(newChild["@term-name"].toString(), false, form);
} else if(newName == "date-part") {
if(newName == "date-part") {
var part = newChild.@name.toString();
var string = date.getDateVariable(part);
var string = date.getDateVariable(part).toString();
if(string == "") continue;
if(part == "year") {
// if 4 digits and no B.C., use short form
if(newForm == "short" && string.length == 4 && !isNaN(string*1)) {
string = string.substr(2, 2);
}
var disambiguate = item.getProperty("disambiguate");
if(disambiguate && variable == "published" &&
context.option.(@name == "disambiguate-year-suffix").length()) {
var disambiguate = item.getProperty("disambiguate-add-year-suffix");
if(disambiguate && variables[j] == "issued") {
string += disambiguate;
}
} else if(part == "month") {
isNumeric = !isNaN(string*1);
if(isNumeric) {
if(form == "numeric") {
string = month;
// if month is a numeric month, format as such
if(!isNaN(string*1)) {
if(form == "numeric-leading-zeros") {
if(string.length == 1) {
string = "0" + string;
}
} else if(form == "short") {
string = this._terms["short"]["_months"][string];
} else {
} else if(form != "numeric") {
string = this._terms["long"]["_months"][string];
}
} else if(form == "numeric") {
string = "";
}
} else if(part == "day") {
if(form == "numeric-leading-zeros"
&& string.length() == 1) {
string = "0" + string;
}
}
}
@ -931,7 +937,12 @@ Zotero.CSL.Global = new function() {
* with "_") are implemented.
*/
Zotero.CSL.Item = function(item) {
if(!(item instanceof Zotero.Item)) {
throw "Zotero.CSL.Item called to wrap a non-item";
} else {
this.zoteroItem = item;
}
this._dates = {};
this._properties = {};
}
@ -976,15 +987,16 @@ Zotero.CSL.Item._zoteroFieldMap = {
"container-title":"publicationTitle",
"collection-title":["seriesTitle", "series"],
"publisher":"publisher",
"pages":"pages",
"publisher-place":"place",
"page":"pages",
"volume":"volume",
"issue":"issue",
"number-of-volumes":"number-of-volumes",
"number-of-volumes":"numberOfVolumes",
"edition":"edition",
"genre":"type",
"abstract":"abstract",
"URL":"url",
"DOI":"doi"
"DOI":"DOI"
}
/*
@ -1124,12 +1136,12 @@ Zotero.CSL.Item.prototype._separateNames = function() {
}
/*
* Generates an date object for a given variable (currently supported: published
* Generates an date object for a given variable (currently supported: issued
* and accessed)
*/
Zotero.CSL.Item.prototype._createDate = function(variable) {
// first, figure out what date variable to use.
if(variable == "published") {
if(variable == "issued") {
var date = this.zoteroItem.getField("date", false, true);
var sort = this.zoteroItem.getField("date", true, true);
} else if(variable == "accessed") {
@ -1203,7 +1215,7 @@ Zotero.CSL.Item.Name.prototype.getNameVariable = function(variable) {
* When an array of items are passed to create a new item set, each is wrapped
* in an item wrapper.
*/
Zotero.CSL.ItemSet = function(unwrappedItems, csl) {
Zotero.CSL.ItemSet = function(items, csl) {
var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
.getService(Components.interfaces.nsILocaleService);
var collationFactory = Components.classes["@mozilla.org/intl/collation-factory;1"]
@ -1212,91 +1224,38 @@ Zotero.CSL.ItemSet = function(unwrappedItems, csl) {
this.csl = csl;
this.postprocess = false;
this.bib = csl._csl.bibliography;
if(this.bib.option.(@name == "disambiguate").length()
|| this.bib.option.(@name == "subsequent-author-substitute").length()) {
this.postprocess = true;
this.citation = csl._csl.citation;
this.bibliography = csl._csl.bibliography;
// collect options
this.options = new Object();
options = this.citation.option.(@name.substr(0, 12) == "disambiguate")
+ this.bibliography.option.(@name == "subsequent-author-substitute");
for each(var option in options) {
this.options[option.@name.toString()] = option.@value.toString();
}
this.items = [];
this.itemsById = {};
if(!unwrappedItems) {
// add items
this.add(items);
// check which disambiguation options are enabled
enabledDisambiguationOptions = new Array();
for each(var option in ["disambiguate-add-year-suffix",
"disambiguate-add-givenname", "disambiguate-add-names",
"disambiguate-add-title"]) {
if(this.options[option]) {
enabledDisambiguationOptions.push(option);
}
}
if(!items) {
return;
}
// add data (authors, editors, translators, etc.)
for(var i in unwrappedItems) {
var newItem = new Zotero.CSL.Item(unwrappedItems[i]);
this.items.push(newItem);
this.itemsById[newItem.getID()] = newItem;
}
if(this.bib.option.(@name == "sort-algorithm").length()
&& this.bib.option.(@name == "sort-algorithm").@value != "cited") {
this.resort();
}
// run postprocessing (subsequent author substitute and disambiguation)
if(this.postprocess) {
var lastItem = false;
var lastNames = false;
var lastYear = false;
for(var i in this.items) {
var item = this.items[i];
var year = item.getDate("published");
if(year) year = year.getDateVariable("year");
var names = item.getNames("author");
if(names && lastNames && !this._compareNames(names, lastNames)) {
if(year && year == lastYear) {
var oldDisambiguate = lastItem.getProperty("disambiguate");
if(!oldDisambiguate) {
lastItem.setProperty("disambiguate", "a");
item.setProperty("disambiguate", "b");
} else {
var newDisambiguate = "";
if(oldDisambiguate.length > 1) {
newDisambiguate = oldLetter.substr(0, oldDisambiguate.length-1);
}
var charCode = oldDisambiguate.charCodeAt(oldDisambiguate.length-1);
if(charCode == 122) {
// item is z; add another letter
newDisambiguate += "a";
} else {
// next lowercase letter
newDisambiguate += String.fromCharCode(charCode+1);
}
item.setProperty("disambiguate", newDisambiguate);
}
}
item.setProperty("subsequent-author-substitute", "1");
}
item.setProperty("number", i+1);
lastItem = item;
lastNames = names;
lastYear = year;
}
}
}
/*
* Sorts the item set, running postprocessing afterwards
*/
Zotero.CSL.ItemSet.prototype.resort = function() {
var me = this;
this.items = this.items.sort(function(a, b) {
return me._compareItem(a, b);
});
}
/*
@ -1305,13 +1264,261 @@ Zotero.CSL.ItemSet.prototype.resort = function() {
Zotero.CSL.ItemSet.prototype.getItemsByIds = function(ids) {
var items = [];
for each(var id in ids) {
if(this.itemsById[id]) {
if(this.itemsById[id] != undefined) {
items.push(this.itemsById[id]);
}
}
return items;
}
/*
* Adds items to the given item set; must be passed either CSL.Item
* objects or objects that may be wrapped as CSL.Item objects
*/
Zotero.CSL.ItemSet.prototype.add = function(items) {
for(var i in items) {
if(items[i] instanceof Zotero.CSL.Item) {
var newItem = items[i];
} else {
var newItem = new Zotero.CSL.Item(items[i]);
}
this.itemsById[newItem.getID()] = newItem;
this.items.push(newItem);
}
}
/*
* Removes items from the item set; must be passed either CSL.Item objects
* or item IDs
*/
Zotero.CSL.ItemSet.prototype.remove = function(items) {
for(var i in items) {
if(items[i] instanceof Zotero.CSL.Item) {
var item = items[i];
} else {
var item = this.itemsById[items[i]];
}
this.itemsById[item.getID()] = undefined;
this.items.splice(this.items.indexOf(item), 1);
}
}
/*
* Sorts the item set, also running postprocessing and returning items whose
* citations have changed
*/
Zotero.CSL.ItemSet.prototype.resort = function() {
// sort, if necessary
if(this.bibliography.option.(@name == "sort-algorithm").length()
&& this.bibliography.option.(@name == "sort-algorithm").@value != "cited") {
var me = this;
this.items = this.items.sort(function(a, b) {
return me._compareItem(a, b);
});
}
changedCitations = new Array();
// first loop through to collect disambiguation data by item, so we can
// see if any items have changed
if(enabledDisambiguationOptions.length) {
oldDisambiguate = new Array();
for(var i in enabledDisambiguationOptions) {
oldDisambiguate[i] = new Array();
for(var j in this.items) {
if(this.items[j] == undefined) continue;
oldDisambiguate[i][j] = this.items[j].getProperty(enabledDisambiguationOptions[i]);
this.items[j].setProperty(enabledDisambiguationOptions[i], "");
}
}
}
// loop through once to determine where items equal the previous item
if(enabledDisambiguationOptions.length) {
citationsEqual = [];
for(var i in this.items) {
citationsEqual[i] = this._compareCitations(this.items[i-1], this.items[i]);
}
}
var lastItem = false;
var lastNames = false;
var lastYear = false;
for(var i in this.items) {
var item = this.items[i];
if(item == undefined) continue;
var year = item.getDate("issued");
if(year) year = year.getDateVariable("year");
var names = item.getNames("author");
var disambiguated = false;
// true only if names are an exact match
var exactMatch = this._compareNames(item, lastItem);
if(enabledDisambiguationOptions.length && i != 0 && !citationsEqual[i]
&& year == lastYear) {
// some options can only be applied if there are actual authors
if(names && lastNames) {
if(exactMatch == 0) {
// copy from previous item
this._copyDisambiguation(lastItem, item);
} else {
// these options only apply if not an _exact_ match
if(this.options["disambiguate-add-names"]) {
// try adding names to disambiguate
var oldAddNames = lastItem.getProperty("disambiguate-add-names");
// if a different number of names, disambiguation is
// easy, although we should still see if there is a
// smaller number of names that works
var numberOfNames = names.length;
if(numberOfNames > lastNames.length) {
numberOfNames = lastNames.length;
item.setProperty("disambiguate-add-names", numberOfNames+1);
// have to check old property
if(!oldAddNames || oldAddNames < numberOfNames) {
lastItem.setProperty("disambiguate-add-names", numberOfNames);
}
disambiguated = true;
} else if(numberOfNames != lastNames.length) {
item.setProperty("disambiguate-add-names", numberOfNames);
// have to check old property
if(!oldAddNames || oldAddNames < numberOfNames+1) {
lastItem.setProperty("disambiguate-add-names", numberOfNames+1);
}
disambiguated = true;
}
}
// now, loop through and see whether there's a
// dissimilarity before the end
for(var j=0; j<numberOfNames; j++) {
var lastUnequal = this.options["disambiguate-add-names"]
&& names[j].getNameVariable("lastName") != lastNames[j].getNameVariable("lastName");
var firstUnequal = this.options["disambiguate-add-givenname"]
&& names[j].getNameVariable("firstName") != lastNames[j].getNameVariable("firstName");
if(lastUnequal || firstUnequal) {
if(this.options["disambiguate-add-names"]) {
item.setProperty("disambiguate-add-names", j+1);
if(!oldAddNames || oldAddNames < j+1) {
lastItem.setProperty("disambiguate-add-names", j+1);
}
}
// if the difference is only in the first
// name, show first name
if(!lastUnequal && firstUnequal) {
oldAddGivenname = lastItem.getProperty("disambiguate-add-givenname").split(",");
if(oldAddGivenname) {
if(oldAddGivenname.indexOf(j) == -1) {
oldAddGivenname.push(j);
lastItem.setProperty("disambiguate-add-givenname", oldAddGivenname.join(","));
}
} else {
lastItem.setProperty("disambiguate-add-givenname", j);
}
item.setProperty("disambiguate-add-givenname", j);
}
// add to names before as well
for(var k=i-2; this._compareNames(lastItem, this.items[k]) == 0; k--) {
this._copyDisambiguation(lastItem, this.items[k]);
}
disambiguated = true;
break;
}
}
}
}
// add a year suffix, if the above didn't work
if(!disambiguated && year && this.options["disambiguate-add-year-suffix"]) {
var lastDisambiguate = lastItem.getProperty("disambiguate-add-year-suffix");
if(!lastDisambiguate) {
lastItem.setProperty("disambiguate-add-year-suffix", "a");
item.setProperty("disambiguate-add-year-suffix", "b");
} else {
var newDisambiguate = "";
if(lastDisambiguate.length > 1) {
newDisambiguate = oldLetter.substr(0, lastDisambiguate.length-1);
}
var charCode = lastDisambiguate.charCodeAt(lastDisambiguate.length-1);
if(charCode == 122) {
// item is z; add another letter
newDisambiguate += "a";
} else {
// next lowercase letter
newDisambiguate += String.fromCharCode(charCode+1);
}
item.setProperty("disambiguate-add-year-suffix", newDisambiguate);
}
disambiguated = true;
}
// add a title, if the above didn't work
if(!disambiguated) {
lastItem.setProperty("disambiguate-add-title", true);
item.setProperty("disambiguate-add-title", true);
disambiguated = true;
}
}
if(this.options["subsequent-author-substitute"] && names && lastNames
&& exactMatch) {
item.setProperty("subsequent-author-substitute", "1");
}
item.setProperty("number", i+1);
lastItem = item;
lastNames = names;
lastYear = year;
}
// find changed citations
if(enabledDisambiguationOptions.length) {
for(var j in this.items) {
if(this.items[j] == undefined) continue;
for(var i in enabledDisambiguationOptions) {
if(this.items[j].getProperty(enabledDisambiguationOptions[i]) != oldDisambiguate[i][j]) {
changedCitations.push(this.items[j]);
}
}
}
}
return changedCitations;
}
/*
* Copies disambiguation settings (with the exception of disambiguate-add-year-suffix)
* from one item to another
*/
Zotero.CSL.ItemSet.prototype._copyDisambiguation = function(fromItem, toItem) {
for each(var option in ["disambiguate-add-givenname", "disambiguate-add-names",
"disambiguate-add-title"]) {
var value = fromItem.getProperty(option);
if(value) {
toItem.setProperty(option, value);
}
}
}
/*
* Compares two items, in order to sort the reference list
* Returns -1 if A comes before B, 1 if B comes before A, or 0 if they are equal
@ -1321,17 +1528,17 @@ Zotero.CSL.ItemSet.prototype._compareItem = function(a, b) {
var sortB = [];
// author
if(this.bib.option.(@name == "sort-algorithm").@value == "author-date") {
if(this.bibliography.option.(@name == "sort-algorithm").@value == "author-date") {
var sortString = new Zotero.CSL.SortString();
this.csl._processElements(a, this.csl._csl.macro.(@name == "author"), sortString);
sortA.push(sortString.get().toLowerCase());
var date = a.getDate("published");
var date = a.getDate("issued");
if(date) sortA.push(date.getDateVariable("sort"));
sortString = new Zotero.CSL.SortString();
this.csl._processElements(b, this.csl._csl.macro.(@name == "author"), sortString);
sortB.push(sortString.get().toLowerCase());
var date = b.getDate("published");
var date = b.getDate("issued");
if(date) sortB.push(date.getDateVariable("sort"));
}
@ -1356,21 +1563,57 @@ Zotero.CSL.ItemSet.prototype._compareItem = function(a, b) {
return 0;
}
/*
* Compares two citations; returns true if they are different, false if they are equal
*/
Zotero.CSL.ItemSet.prototype._compareCitations = function(a, b) {
if((!a && b) || (a && !b)) {
return true;
} else if(!a && !b) {
return false;
}
var aString = new Zotero.CSL.FormattedString(this, "Text");
this.csl._processElements(a, this.citation.layout, aString,
this.citation, "subsequent");
var bString = new Zotero.CSL.FormattedString(this, "Text");
this.csl._processElements(b, this.citation.layout, bString,
this.citation, "subsequent");
return !(aString.get() == bString.get());
}
/*
* Compares the names from two items
* Returns -1 if A comes before B, 1 if B comes before A, or 0 if they are equal
*/
Zotero.CSL.ItemSet.prototype._compareNames = function(a, b) {
Zotero.CSL.ItemSet.prototype._compareNames = function(a, b, context) {
if(!a && b) {
return -1;
} else if(!b && a) {
return 1;
} else if(!b && !a) {
return 0;
}
var sortString = new Zotero.CSL.SortString();
this.csl._processElements(a, this.bib.macro.(@name == "author"), sortString);
this.csl._processElements(a, this.csl._csl.macro.(@name == "author"), sortString, context);
aString = sortString.get().toLowerCase();
sortString = new Zotero.CSL.SortString();
this.csl._processElements(b, this.bib.macro.(@name == "author"), sortString);
this.csl._processElements(b, this.csl._csl.macro.(@name == "author"), sortString, context);
bString = sortString.get().toLowerCase();
if(aString != bString) {
return this._collation.compareString(0, aString, bString);;
var b = this._collation.compareString(0, aString, bString);
if(b != 0) return b;
if(aString < bString) {
return -1;
} else {
return 1;
}
}
return 0;
}
@ -1604,16 +1847,16 @@ Zotero.CSL.FormattedString.prototype.clone = function(delimiter) {
Zotero.CSL.SortString = function() {
this.format = "Sort";
this.string = "";
this.delimiter = "\u0000"; // null character
this.delimiter = "\003"; // null character
}
Zotero.CSL.SortString.prototype.concat = function(string) {
newString = string.get();
// Replace old delimiter if concatenated string has a delimiter as wel
if(newString.match("\u0000")) {
if(newString.match("\003")) {
delimiterRegexp = new RegExp(this.delimiter, "g");
this.delimiter += "\u0000";
this.delimiter += "\003";
this.string = this.string.replace(delimiterRegexp, this.delimiter);
}

View File

@ -279,14 +279,42 @@ Zotero.CSL.Compat.Global = new function() {
* of items
*/
Zotero.CSL.Compat.prototype.generateItemSet = function(items) {
Zotero.debug("CSL: preprocessing items");
return new Zotero.CSL.Compat.ItemSet(items, this);
}
this._ignore = null;
Zotero.CSL.Compat.ItemSet = function(items, csl) {
this.items = [];
this.csl = csl;
this.add(items);
this.resort();
}
Zotero.CSL.Compat.ItemSet.prototype.getItemsByIds = function(ids) {
return Zotero.Items.get(ids);
}
Zotero.CSL.Compat.ItemSet.prototype.add = function(items) {
this.items = this.items.concat(items);
}
Zotero.CSL.Compat.ItemSet.prototype.remove = function(items) {
for(var i in items) {
if(items[i] instanceof Zotero.Item) {
var item = items[i];
} else {
var item = this.itemsById[items[i]];
}
this.items.splice(this.items.indexOf(item), 1);
}
}
Zotero.CSL.Compat.ItemSet.prototype.resort = function() {
var oldDisambiguation = {};
// get data necessary to generate citations before sorting
for(var i in items) {
var item = items[i];
var dateModified = this._getField(item, "dateModified");
for(var i in this.items) {
var item = this.items[i];
var dateModified = this.csl._getField(item, "dateModified");
if(!item._csl || item._csl.dateModified != dateModified) {
// namespace everything in item._csl so there's no chance of overlap
@ -294,34 +322,38 @@ Zotero.CSL.Compat.prototype.generateItemSet = function(items) {
item._csl.dateModified = dateModified;
// separate item into authors, editors, translators
var creators = this._separateItemCreators(item);
var creators = this.csl._separateItemCreators(item);
item._csl.authors = creators[0];
item._csl.editors = creators[1];
item._csl.translators = creators[2];
// parse date
item._csl.date = Zotero.CSL.Compat.prototype._processDate(this._getField(item, "date"));
item._csl.date = Zotero.CSL.Compat.prototype._processDate(this.csl._getField(item, "date"));
}
// clear disambiguation and subsequent author substitute
if(item._csl.date && item._csl.date.disambiguation) item._csl.date.disambiguation = undefined;
if(item._csl.date && item._csl.date.disambiguation) {
oldDisambiguation[item.getID()] = item._csl.date.disambiguation;
item._csl.date.disambiguation = undefined;
}
if(item._csl.subsequentAuthorSubstitute) item._csl.subsequentAuthorSubstitute = undefined;
}
// sort by sort order
if(this._bib.sortOrder) {
Zotero.debug("CSL: sorting items");
var me = this;
items.sort(function(a, b) {
if(this.csl._bib.sortOrder) {
Zotero.debug("CSL: sorting this.items");
var me = this.csl;
this.items.sort(function(a, b) {
return me._compareItem(a, b);
});
}
// disambiguate items after preprocessing and sorting
// disambiguate this.items after preprocessing and sorting
var usedCitations = new Array();
var lastAuthors;
for(var i in items) {
var item = items[i];
for(var i in this.items) {
var item = this.items[i];
// handle subsequent author substitutes
if(item._csl.authors.length && lastAuthors) {
@ -340,7 +372,7 @@ Zotero.CSL.Compat.prototype.generateItemSet = function(items) {
lastAuthors = item._csl.authors;
// handle (2006a) disambiguation for author-date styles
if(this.class == "author-date") {
if(this.csl.class == "author-date") {
var year = item._csl.date.year;
if(authorsAreSame) {
@ -378,13 +410,17 @@ Zotero.CSL.Compat.prototype.generateItemSet = function(items) {
item._csl.number = i;
}
// for compatibility, create an itemSet object
var me = this;
itemSet = new Object();
itemSet.items = items;
itemSet.resort = function() { this.items = me.generateItemSet(items).items };
return itemSet;
// see which items have changed
var returnItems = [];
for each(var item in this.items) {
if(item._csl.date && item._csl.date.disambiguation) {
var oldDisambig = oldDisambiguation[item.getID()];
if(!oldDisambig || oldDisambig != item._csl.date.disambiguation) {
returnItems += item;
}
}
}
return returnItems;
}
Zotero.CSL.Compat._locatorTerms = {
@ -393,9 +429,7 @@ Zotero.CSL.Compat._locatorTerms = {
l:"line"
};
Zotero.CSL.Compat.prototype.createCitation = function(itemSet, ids, format, position, locators, locatorTypes) {
var items = Zotero.Items.get(ids);
Zotero.CSL.Compat.prototype.createCitation = function(itemSet, items, format, position, locators, locatorTypes) {
var string = new Zotero.CSL.Compat.FormattedString(this, format);
if(position == "ibid" || position == "ibid-pages") { // indicates ibid
var term = this._getTerm("ibid");
@ -406,7 +440,7 @@ Zotero.CSL.Compat.prototype.createCitation = function(itemSet, ids, format, posi
var locator = locators[0];
if(locator) {
var locatorType = Zotero.CSL.Compat._locatorTerms[locatorTypes[0]];
var locatorType = locatorTypes[0];
// search for elements with the same serialization
var element = this._getFieldDefaults("locator");
@ -429,7 +463,7 @@ Zotero.CSL.Compat.prototype.createCitation = function(itemSet, ids, format, posi
var locatorType = false;
var locator = false;
if(locators) {
locatorType = Zotero.CSL.Compat._locatorTerms[locatorTypes[i]];
locatorType = locatorTypes[i];
locator = locators[i];
}
@ -1088,7 +1122,7 @@ Zotero.CSL.Compat.prototype._processCreators = function(type, element, creators,
// check whether to use a serial comma
Zotero.debug(child["delimiter-precedes-last"]);
if((authorStrings.length == 2 && child["delimiter-precedes-last"] != "always") ||
if((authorStrings.length == 2 && (useEtAl || child["delimiter-precedes-last"] != "always")) ||
(authorStrings.length > 2 && child["delimiter-precedes-last"] == "never")) {
var lastString = authorStrings.pop();
authorStrings[authorStrings.length-1] = authorStrings[authorStrings.length-1]+" "+lastString;

View File

@ -376,9 +376,7 @@ Zotero.Integration.SOAP = new function() {
for(var i=3; i<vars.length; i+=2) {
if(vars[i+1] == "X") {
// get a new citation for a field with an X
var io = new function() {
this.wrappedJSObject = this;
}
var io = new function() { this.wrappedJSObject = this; }
watcher.openWindow(null, 'chrome://zotero/content/addCitationDialog.xul', '',
'chrome,modal'+(Zotero.isWin ? ',popup' : ''), io, true);
@ -704,104 +702,85 @@ Zotero.Integration.CitationFactory = function(style) {
if(style) this.style = style;
this.cache = new Object();
this.dateModified = new Object();
this.items = new Array();
}
Zotero.Integration.CitationFactory.prototype.updateItems = function(citationSet, session, updateCitations) {
if(session) {
// check to see if an update is really necessary
var regenerateItemList = false;
var item, itemID;
for(var i in this.items) {
item = this.items[i]
itemID = item.getID();
// see if old items were deleted or changed
if(!citationSet.citationsByID[itemID] ||
(this.dateModified[itemID] != item.getField("dateModified"))) {
regenerateItemList = true;
break;
}
}
if(!regenerateItemList) {
for(var i in citationSet.citationsByID) {
// see if new items were added
if(!session.citationSet.citationsByID[i]) {
regenerateItemList = true;
break;
}
}
}
// leave if it's not
if(!regenerateItemList) {
return false;
}
}
var addedItems = [];
var deletedItems = [];
var missingItems = [];
var updateItems = [];
var resort = false;
this.items = new Array();
var updateCheck = new Array();
var disambiguation = new Array();
var missingItems = [];
for(var i in citationSet.citationsByID) {
var item = Zotero.Items.get(i);
if (!item) {
missingItems.push(i)
deletedItems.push(i);
resort = true;
continue;
}
this.items.push(item);
// see if new items were added
if(!session || !this.itemSet || !session.citationSet.citationsByID[i]) {
addedItems.push(item);
resort = true;
this.dateModified[i] = item.getField("dateModified", true, true);
}
}
if(this.dateModified[i] && this.dateModified[i] != item.getField("dateModified")) {
if(!this.itemSet) {
this.itemSet = this.style.generateItemSet(addedItems);
} else {
// see if old items were deleted or changed
for each(var item in this.itemSet.items) {
var itemID = item.getID();
if(!citationSet.citationsByID[itemID]) {
missingItems.push(itemID);
resort = true;
continue;
}
if(item.zoteroItem && this.dateModified[itemID] != item.zoteroItem.getField("dateModified", true, true)) {
// so that we can update modified this.items
updateCheck[i] = true;
}
if(item._csl && item._csl.date.disambiguation) {
// keep track of disambiguation data
disambiguation[i] = item._csl.date.disambiguation;
updateItems.push(item);
}
}
this.itemSet = this.style.generateItemSet(this.items);
if(addedItems.length) {
this.itemSet.add(addedItems);
} else if(missingItems.length || deletedItems.length) {
this.itemSet.remove(missingItems.concat(deletedItems));
}
/*var tempCache = new Object();
for(var i in this.items) {
var itemID = this.items[i].getID();
this.dateModified[itemID] = this.items[i].getField("dateModified");
if(resort) {
var citationChanged = this.itemSet.resort();
updateItems = updateItems.concat(citationChanged);
}
for each(var item in updateItems) {
itemID = item.getID();
this.dateModified[itemID] = item.zoteroItem.getField("dateModified", true, true);
if(session) {
// check to see if disambiguation has changed
if(this.items[i]._csl.date.disambiguation != disambiguation[itemID]) {
for each(var citation in citationSet.citationsByID[itemID]) {
updateCitations[citation.index] = true;
citation.updateText = true;
this.cache[citation.serialization] = null;
}
} else if(updateCheck[itemID]) {
// check against cache to see if updated item has changed
for each(var citation in citationSet.citationsByID[itemID]) {
if(this.cache[citation.serializedType][citation.serialization]) {
var citationText = this.getCitation(citation, tempCache);
if(citationText != this.cache[citation.serializedType][citation.serialization]) {
updateCitations[citation.index] = true;
citation.updateText = true;
this.cache[citation.serializedType][citation.serialization] = citationText;
if(citation.serializedType && citation.serialization) {
this.cache[citation.serializedType][citation.serialization] = undefined;
}
}
}
}
}
}*/
// TODO: clear missing items from cache?
return true;
}
Zotero.Integration.CitationFactory._locatorMap = {p:"page", g:"paragraph", l:"line"};
Zotero.Integration.CitationFactory.prototype.getCitation = function(citation, usingCache) {
// Return "!" for deleted items
for (var i=0; i<citation.itemIDs.length; i++) {
@ -816,10 +795,21 @@ Zotero.Integration.CitationFactory.prototype.getCitation = function(citation, us
return usingCache[citation.serializedType][citation.serialization];
}
if(!this.itemSet) {
throw "Zotero.Integration.CitationFactory: getCitation called before updateCitations";
}
citation.loadLocators();
var citationText = this.style.createCitation(this.itemSet, citation.itemIDs, "Integration",
// map locators to proper term names
var locatorTerms = [];
for each(var type in citation.locatorTypes) {
locatorTerms.push(Zotero.Integration.CitationFactory._locatorMap[type]);
}
var items = this.itemSet.getItemsByIds(citation.itemIDs);
var citationText = this.style.createCitation(this.itemSet, items, "Integration",
Zotero.Integration.citationTypes[citation.citationType], citation.locators,
citation.locatorTypes);
locatorTerms);
if(!usingCache[citation.serializedType]) {
usingCache[citation.serializedType] = new Object();
@ -832,4 +822,5 @@ Zotero.Integration.CitationFactory.prototype.getCitation = function(citation, us
Zotero.Integration.CitationFactory.prototype.clearCache = function() {
this.cache = new Object();
this.dateModified = new Object();
this.itemSet = undefined;
}

View File

@ -159,7 +159,7 @@ Zotero.Translate.init = function() {
// fetch translator list
var translators = Zotero.DB.query("SELECT translatorID, translatorType, label, "+
"target, detectCode IS NULL as noDetectCode FROM translators "+
"ORDER BY target IS NULL, priority, label");
"ORDER BY priority, label");
var detectCodes = Zotero.DB.query("SELECT translatorID, detectCode FROM translators WHERE target IS NULL");
Zotero.Translate.cache = new Object();
@ -492,7 +492,7 @@ Zotero.Translate.prototype.getTranslators = function() {
} else {
var sql = "SELECT translatorID, label, target, detectCode IS NULL as "+
"noDetectCode FROM translators WHERE translatorType IN ("+this._numericTypes+") "+
"ORDER BY target IS NULL, priority, label";
"ORDER BY priority, label";
var translators = Zotero.DB.query(sql);
}

View File

@ -1,4 +1,4 @@
-- 252
-- 253
-- ***** BEGIN LICENSE BLOCK *****
--
@ -22,7 +22,7 @@
-- Set the following timestamp to the most recent scraper update date
REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-07-31 19:40:00'));
REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-08-04 23:15:00'));
REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b4.r1', '', '2007-06-21 20:00:00', '1', '100', '4', 'Amazon.com', 'Sean Takats', '^https?://(?:www\.)?amazon',
'function detectWeb(doc, url) {
@ -6593,7 +6593,7 @@ function doSearch(item) {
lookupPMIDs([getPMID(item.contextObject)]);
}');
REPLACE INTO translators VALUES ('951c027d-74ac-47d4-a107-9c3069ab7b48', '1.0.0b3.r1', '', '2006-12-12 23:41:00', 1, 100, 4, 'Embedded RDF', 'Simon Kornblith', NULL,
REPLACE INTO translators VALUES ('951c027d-74ac-47d4-a107-9c3069ab7b48', '1.0.0b3.r1', '', '2007-08-04 23:15:00', 1, 400, 4, 'Embedded RDF', 'Simon Kornblith', NULL,
'function detectWeb(doc, url) {
var metaTags = doc.getElementsByTagName("meta");
@ -6647,7 +6647,7 @@ REPLACE INTO translators VALUES ('951c027d-74ac-47d4-a107-9c3069ab7b48', '1.0.0b
rdf.doImport();
}');
REPLACE INTO translators VALUES ('05d07af9-105a-4572-99f6-a8e231c0daef', '1.0.0b3.r1', '', '2006-12-15 03:40:00', 1, 100, 4, 'COinS', 'Simon Kornblith', NULL,
REPLACE INTO translators VALUES ('05d07af9-105a-4572-99f6-a8e231c0daef', '1.0.0b3.r1', '', '2007-08-04 23:15:00', 1, 300, 4, 'COinS', 'Simon Kornblith', NULL,
'function detectWeb(doc, url) {
var spanTags = doc.getElementsByTagName("span");
@ -6824,7 +6824,7 @@ function doWeb(doc, url) {
}
}');
REPLACE INTO translators VALUES ('e7e01cac-1e37-4da6-b078-a0e8343b0e98', '1.0.0b4.r1', '', '2007-03-20 17:50:13', '1', '90', '4', 'unAPI', 'Simon Kornblith', '',
REPLACE INTO translators VALUES ('e7e01cac-1e37-4da6-b078-a0e8343b0e98', '1.0.0b4.r1', '', '2007-08-04 23:15:00', '1', '200', '4', 'unAPI', 'Simon Kornblith', '',
'var RECOGNIZABLE_FORMATS = ["mods", "marc", "endnote", "ris", "bibtex", "rdf"];
var FORMAT_GUIDS = {
"mods":"0e2235e7-babf-413c-9acf-f27cce5f059c",
@ -15598,7 +15598,7 @@ function doExport() {
}
}');
REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-07-14 22:56:53', 'American Psychological Association',
REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-08-04 23:15:00', 'American Psychological Association',
'<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" xml:lang="en">
<info>
<title>American Psychological Association</title>
@ -15610,7 +15610,7 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
</author>
<category term="psychology"/>
<category term="generic-base"/>
<updated>2007-07-11T14:27:56+08:00</updated>
<updated>2007-08-04T15:15:00+08:00</updated>
</info>
<macro name="editor-translator">
<names variable="editor translator" prefix="(" suffix=")" delimiter=", ">
@ -15620,9 +15620,8 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
</macro>
<macro name="author">
<names variable="author">
<name name-as-sort-order="all" and="symbol"
sort-separator=", " initialize-with="." delimiter=", "
delimiter-precedes-last="always"/>
<name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with="."
delimiter=", " delimiter-precedes-last="always"/>
<label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/>
<substitute>
<names variable="editor"/>
@ -15633,8 +15632,7 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
</macro>
<macro name="author-short">
<names variable="author">
<name form="short" and="symbol" delimiter=", "
initialize-with="."/>
<name form="short" and="symbol" delimiter=", " initialize-with="."/>
<substitute>
<names variable="editor"/>
<names variable="translator"/>
@ -15651,14 +15649,14 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
</macro>
<macro name="access">
<group>
<text term-name="retrieved" text-transform="capitalize" suffix=" "/>
<text term="retrieved" text-transform="capitalize" suffix=" "/>
<date variable="accessed" suffix=", ">
<date-part name="month" suffix=" "/>
<date-part name="day" suffix=", "/>
<date-part name="year"/>
</date>
<group>
<text term-name="from" suffix=" "/>
<text term="from" suffix=" "/>
<text variable="URL"/>
</group>
</group>
@ -15675,7 +15673,7 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
</macro>
<macro name="publisher">
<group delimiter=": ">
<text variable="published-place"/>
<text variable="publisher-place"/>
<text variable="publisher"/>
</group>
</macro>
@ -15684,12 +15682,15 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
<option name="et-al-use-first" value="6"/>
<option name="et-al-subsequent-min" value="6"/>
<option name="et-al-subsequent-use-first" value="1"/>
<option name="disambiguate-add-year-suffix" value="true"/>
<option name="disambiguate-add-names" value="true"/>
<option name="disambiguate-add-givenname" value="true"/>
<layout prefix="(" suffix=")" delimiter="; ">
<text macro="author-short"/>
<date variable="published" prefix=", ">
<date variable="issued" prefix=", ">
<date-part name="year"/>
</date>
<locator prefix=": "/>
<text variable="locator" prefix=": "/>
</layout>
</citation>
<bibliography>
@ -15697,12 +15698,9 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
<option name="sort-algorithm" value="author-date"/>
<option name="et-al-min" value="6"/>
<option name="et-al-use-first" value="6"/>
<option name="disambiguate-year-suffix" value="true"/>
<option name="disambiguate-add-givenname" value="true"/>
<option name="disambiguate-add-names" value="true"/>
<layout>
<text macro="author" suffix="."/>
<date variable="published" prefix=" (" suffix=").">
<date variable="issued" prefix=" (" suffix=").">
<date-part name="year"/>
</date>
<choose>
@ -15716,7 +15714,7 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
<else-if type="chapter">
<text macro="title" prefix=" "/>
<group class="container" prefix=". ">
<text term-name="in" text-transform="capitalize"/>
<text term="in" text-transform="capitalize"/>
<names variable="editor translator" prefix=" " suffix="," delimiter=", ">
<name and="symbol" sort-separator=", " initialize-with="."/>
<label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/>
@ -15726,8 +15724,8 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
<group suffix=".">
<text macro="publisher" prefix=" "/>
<group prefix=" (" suffix=")">
<text term-name="page" plural="true" form="short" suffix=". "/>
<text variable="pages"/>
<label variable="page" form="short" suffix=". "/>
<text variable="page"/>
</group>
</group>
</group>
@ -15739,9 +15737,11 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
</group>
<group class="container" prefix=" " suffix=".">
<text variable="container-title" font-style="italic"/>
<text variable="volume" prefix=", " font-style="italic"/>
<group prefix=", ">
<text variable="volume" font-style="italic"/>
<text variable="issue" prefix="(" suffix=")"/>
<text variable="pages" prefix=", "/>
</group>
<text variable="page" prefix=", "/>
</group>
</else>
</choose>