Just some notes really ...
On Jan 17, 2006, at 6:10 PM, David Wilson wrote:
To make this easily usable we need to modify (or make new versions) of
The
modules
Bibliography
textfield/Bibliography
FieldMaster/Bibliography
BibliographyDataField
I'm trying to find the source code for these, but not having much
success yet.
I've been working more on my experiment porting citeproc to Ruby. I'm
not much of a Ruby coder, but did get some help from an expert.
What I have now is two main classes: Reference and ReferenceList.
The Reference class just holds the data, and the ReferenceList class is
where most of the work happens. It creates an array of references and
processes them, so that creating a bibliography just ends up involving
calling a single method; e.g. if you have a ReferenceList instance of
"reference_list" then:
reference_list.format
I've not hooked up CSL to it to configure the formatting, and may not
have time to do that, but the basic idea, then, is to modularize the
rest of the stuff: a CSL reader configures basic formatting, and then
there are pieces to handle input/output.
As I mentioned elsewhere, I think there needs to be two further
classes, and all of them need to be able to talk to each other:
Citation and CitationList. I'd like to see how the current OOo code
handles the "as cited" sort algorithm, because this is mostly for that
case (e.g. to sort a reference list, you need to know the order of
appearance of the citations).
In addition I think it makes sense to have a CitationStyle class. So
the CSL reader noted above would just create an instance of this.
So in the end that leaves:
Reference
ReferenceList
Citation
CitationList (this one may not be needed; not sure)
CitationStyle
What I'd like to see is if any of the existing code can be reused, or
if it makes more sense just to rewrite it all.
My hunch is that the hard part for this is just figuring out the logic
of it all (as embodied, for example, in CSL), but that the actual
coding problem isn't that great (for experienced coders, which is not
me!). If I'm right, then rewriting is probably easier (?). When you get
back, CPH, you might have some thoughts?
Just as an example, the most complicated code in the XSLT version of
citeproc is the one that pre-processes the reference list to enable
proper formatting of author-date citation styles. That method in Ruby
looks like:
def process_author_date
# create an array to hold the processed objects
processed = []
grouped.keys.sort.each do |creator|
by_creator = grouped[creator]
first_by_creator = true
year_suffix = "a"
by_creator.keys.sort.each do |year|
by_year = by_creator[year]
first_by_year = true
suffix = true if by_year.size > 1
by_year.each_with_index do |ref, index|
ref.bibparams[:first_by_creator] = first_by_creator
# create year suffix value where relevant
if suffix then
ref.bibparams[:suffix] = year_suffix.dup
end
year_suffix.succ!
first_by_creator = first_by_year = false
# add enhanced reference object to new array
processed << ref
end
end
end
return processed
end
That basically takes a nested hash (where references are sorted, then
grouped; first by author, then year) to create the enhanced output
needed to correctly format the references.
Bruce
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]