Text::BibTeX::Bib - defines the "Bib" database structure |
Text::BibTeX::Bib - defines the ``Bib'' database structure
$bibfile = new Text::BibTeX::File $filename; $bibfile->set_structure ('Bib', # Default option values: sortby => 'name', namestyle => 'full' nameorder => 'first', atitle => 1, labels => 'numeric');
# Alternate option values: $bibfile->set_option (sortby => 'year'); $bibfile->set_option (namestyle => 'nopunct'); $bibfile->set_option (namestyle => 'nospace'); $bibfile->set_option (nameorder => 'last'); $bibfile->set_option (atitle => 0); $bibfile->set_option (labels => 'alpha'); # not implemented yet!
# parse entry from $bibfile and automatically make it a BibEntry $entry = new Text::BibTeX::Entry $bibfile;
# or get an entry from somewhere else which is hard-coded to be # a BibEntry $entry = new Text::BibTeX::BibEntry ...;
$sortkey = $entry->sort_key; @blocks = $entry->format;
(NOTE! Do not believe everything you read in this document. The
classes described here are unfinished and only lightly tested. The
current implementation is a proof-of-principle, to convince myself (and
anyone who might be interested) that it really is possible to
reimplement BibTeX 0.99 in Perl using the core Text::BibTeX
classes;
this principle is vaguely demonstrated by the current Bib*
modules,
but not really proved. Many important features needed to reimplement
the standard styles of BibTeX 0.99 are missing, even though this
document may brashly assert otherwise. If you are interested in using
these classes, you should start by reading and grokking the code, and
contributing the missing bits and pieces that you need.)
Text::BibTeX::Bib
implements the database structure for
bibliographies as defined by the standard styles of BibTeX 0.99. It
does this by providing two classes, BibStructure
and BibEntry
(the
leading Text::BibTeX
is implied, and will be omitted for the rest of
this document). These two classes, being specific to bibliographic
data, are outside of the core Text::BibTeX
class hierarchy, but are
distributed along with it as they provide a canonical example of a
specific database structure using classes derived from the core
hierarchy.
BibStructure
, which derives from the Structure
class, deals with
the structure as a whole: it handles structure options and describes all
the types and fields that make up the database structure. If you're
interested in writing your own database structure modules, the standard
interface for both of these is described in the Text::BibTeX::Structure manpage;
if you're just interested in finding out the exact database structure or
the options supported by the Bib
structure, you've come to the right
place. (However, you may have to wade through a bit of excess verbiage
due to this module's dual purpose: first, to reimplement the standard
styles of BibTeX 0.99, and second, to provide an example for other
programmers wishing to implement new or derived database structure
modules.)
BibEntry
derives from the StructuredEntry
class and provides
methods that operate on individual entries presumed to come from a
database conforming to the structure defined by the BibStructure
class. (Actually, to be completely accurate, BibEntry
inherits from
two intermediate classes, BibSort
and BibFormat
. These two
classes just exist to reduce the amount of code in the Bib
module,
and thanks to the magic of inheritance, their existence is usually
irrelevant. But you might want to consult those two classes if you're
interested in the gory details of sorting and formatting entries from
BibTeX 0.99-style bibliography databases.)
BibStructure
handles several user-supplied ``structure options'' and
methods for dealing with them. The options currently supported by the
Bib
database structure, and the values allowed for them, are:
sortby
name
(sort on author names, year,
and title), year
(sort on year, author names, and title). Sorting on
``author names'' is a bit more complicated than just using the author
field; see the Text::BibTeX::BibSort manpage for details. Default value: name
.
namestyle
full
for unabbreviated first
names, abbrev
for first names abbreviated with periods, nopunct
for first names abbreviated with space but no periods, and nospace
to
abbreviate without space or periods. Default value: full
.
nameorder
first
for ``first von last jr''
order, and last
for ``von last jr first'' order. Default value:
first
.
atitle_lower
labels
numeric
or alpha
.
(Alphabetic labels are not yet implemented, so this option is currently
ignored.) Default value: numeric
.
Also, several ``markup options'' are supported. Markup options are
distinct because they don't change how text is extracted from the
database entries and subsequently mangled; rather, they supply bits of
markup that go around the database-derived text. Markup options are
always two-element lists: the first to ``turn on'' some feature of the
markup language, and the second to turn it off. For example, if your
target language is LaTeX2e and you want journal names emphasized, you
would supply a list reference ['\emph{','}']
for the journal_mkup
option. If you were instead generating HTML, you might supply
['<emph>','</emph>']
. To keep the structure module
general with respect to markup languages, all markup options are empty
by default. (Or, rather, they are all references to lists consisting of
two empty strings.)
name_mkup
atitle_mkup
btitle_mkup
journal_mkup
As required by the Text::BibTeX::Structure
module,
Text::BibTeX::Bib
provides two methods for handling options:
known_option
and default_option
. (The other two option methods,
set_options
and get_options
, are just inherited from
Text::BibTeX::Structure
.)
croak
s if OPTION is not a
supported option.
The other purpose of a structure class is to provide a method,
describe_entry
, that lists the allowed entry types and the known
fields for the structure. Programmers wishing to write their own
database structure module should consult the Text::BibTeX::Structure manpage for
the conventions and requirements of this method; the purpose of the
present document is to describe the Bib
database structure.
The allowed entry types, and the fields recognized for them, are:
article
author
, title
, journal
, year
.
Optional fields: volume
, number
, pages
, month
, note
.
book
title
, publisher
, year
.
Optional fields: series
, address
, edition
, month
, note
.
Constrained fields: exactly one of author
, editor
; at most one of volume
, number
.
booklet
title
.
Optional fields: author
, howpublished
, address
, month
, year
, note
.
inbook
publisher
, year
.
Optional fields: series
, type
, address
, edition
, month
, note
.
Constrained fields: exactly one of author
, editor
; at least one of chapter
, pages
; at most one of volume
, number
.
incollection
author
, title
, booktitle
, publisher
, year
.
Optional fields: editor
, series
, type
, chapter
, pages
, address
, edition
, month
, note
.
Constrained fields: at most one of volume
, number
.
inproceedings
conference
author
, title
, booktitle
, year
.
Optional fields: editor
, series
, pages
, address
, month
, organization
, publisher
, note
.
Constrained fields: at most one of volume
, number
.
manual
title
.
Optional fields: author
, organization
, address
, edition
, month
, year
, note
.
mastersthesis
author
, title
, school
, year
.
Optional fields: type
, address
, month
, note
.
misc
author
, title
, howpublished
, month
, year
, note
.
phdthesis
author
, title
, school
, year
.
Optional fields: type
, address
, month
, note
.
proceedings
title
, year
.
Optional fields: editor
, series
, address
, month
, organization
, publisher
, note
.
Constrained fields: at most one of volume
, number
.
techreport
author
, title
, institution
, year
.
Optional fields: type
, number
, address
, month
, note
.
unpublished
author
, title
, note
.
Optional fields: month
, year
.
The second class provided by the Text::BibTeX::Bib
module is
BibEntry
(again, a leading Text::BibTeX
is implied). This being a
structured entry class, it derives from StructuredEntry
. The
conventions and requirements for such a class are documented in
the Text::BibTeX::Structure manpage for the benefit of programmers implementing
their own structure modules.
If you wish to write utilities making use of the Bib
database
structure, then you should call one of the ``officially supported''
methods provided by the BibEntry
class. Currently, there are only
two of these: sort_key
and format
. These are actually implemented
in the BibSort
and BibFormat
classes, respectively, which are base
classes of BibEntry
. Thus, see the Text::BibTeX::BibSort manpage and
the Text::BibTeX::BibFormat manpage for details on these two methods.
the Text::BibTeX::Structure manpage, the Text::BibTeX::BibSort manpage, the Text::BibTeX::BibFormat manpage.
Greg Ward <gward@python.net>
Copyright (c) 1997-2000 by Gregory P. Ward. All rights reserved. This file is part of the Text::BibTeX library. This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
Text::BibTeX::Bib - defines the "Bib" database structure |