Utilities for Bibliographies

A standard for collecting references (in particular to mathematical texts) is &BibTeX; (http://www.ctan.org/tex-archive/biblio/bibtex/distribs/doc/). A disadvantage of &BibTeX; is that the format of the data is specified with the use by &LaTeX; in mind. The data format is less suited for conversion to other document types like plain text or HTML.

In the first section we describe utilities for using data from &BibTeX; files in &GAP;.

In the second section we introduce a new XML based data format BibXMLext for bibliographies which seems better suited for other tasks than using it with &LaTeX;.

Another section will describe utilities to deal with BibXMLext data in &GAP;.

Parsing &BibTeX; Files

Here are functions for parsing, normalizing and printing reference lists in &BibTeX; format. The reference describing this format is .

<#Include Label="ParseBibFiles">

<#Include Label="NormalizeNameAndKey">

<#Include Label="WriteBibFile">

<#Include Label="InfoBibTools">

The BibXMLext Format

Bibliographical data in &BibTeX; files have the disadvantage that the actual data are given in &LaTeX; syntax. This makes it difficult to use the data for anything but for &LaTeX;, say for representations of the data as plain text or HTML. For example: mathematical formulae are in &LaTeX; $ environments, non-ASCII characters can be specified in many strange ways, and how to specify URLs for links if the output format allows them?

Here we propose an XML data format for bibliographical data which addresses these problems, it is called BibXMLext. In the next section we describe some tools for generating (an approximation to) this data format from &BibTeX; data, and for using data given in BibXMLext format for various purposes.

The first motivation for this development was the handling of bibliographical data in &GAPDoc;, but the format and the tools are certainly useful for other purposes as well.

We started from a DTD bibxml.dtd which is publicly available, say from http://bibtexml.sf.net/. This is essentially a reformulation of the definition of the &BibTeX; format, including several of some widely used further fields. This has already the advantage that a generic XML parser can check the validity of the data entries, for example for missing compulsary fields in entries. We applied the following changes and extensions to define the DTD for BibXMLext, stored in the file bibxmlext.dtd which can be found in the root directory of this &GAPDoc; package (and in Appendix ):

names
Lists of names in the author and editor fields in &BibTeX; are difficult to parse. Here they must be given by a sequence of <name>-elements which each contain an optional <first>- and a <last>-element for the first and last names, respectively.
<M>
and <Math>
These elements enclose mathematical formulae, the content is &LaTeX; code (without the $). These should be handled in the same way as the elements with the same names in &GAPDoc;, see and . In particular, simple formulae which have a well defined plain text representation can be given in <M>-elements.
Encoding
Note that in XML files we can use the full range of unicode characters, see http://www.unicode.org/. All non-ASCII characters should be specified as unicode characters. This makes dealing with special characters easy for plain text or HTML, only for use with &LaTeX; some sort of translation is necessary.
<URL>
These elements are allowed everywhere in the text and should be represented by links in converted formats which allow this. It is used in the same way as the element with the same name in &GAPDoc;, see .
<Alt Only="...">
and <Alt Not="...">
Sometimes information should be given in different ways, depending on the output format of the data. This is possible with the <Alt>-elements with the same definition as in &GAPDoc;, see .
<C>
This element should be used to protect text from case changes by converters (the extra {} characters in &BibTeX; title fields).
<string key="..." value="..."/>
and <value key="..."/>
The <string>-element defines key-value pairs which can be used in any field via the <value>-element (not only for whole fields but also parts of the text).
<other type="...">
This is a generic element for fields which are otherwise not supported. An arbitrary number of them is allowed for each entry, so any kind of additional data can be added to entries.
<Wrap Name="...">
This generic element is allowed inside all fields. This markup will be just ignored (but not the element content) by our standard tools. But it can be a useful hook for introducing arbitrary further markup (and our tools can easily be extended to handle it).
Extra entities
The DTD defines the standard XML entities ( and the entities &nbsp; (non-breakable space), &ndash; and &copyright;. Use &ndash; in page ranges.

For further details of the DTD we refer to the file bibxmlext.dtd itself which is shown in appendix . That file also recalls some information from the &BibTeX; documentation on how the standard fields of entries should be used. Which entry types and which fields are supported (and the ordering of the fields which is fixed by a DTD) can be either read off the DTD, or within &GAP; one can use the function to get templates for the various entry types.

Here is an example of a BibXMLext document: <#Include SYSTEM "testbib.xml">

There is a standard XML header and a DOCTYPE declaration refering to the bibxmlext.dtd DTD mentioned above. Local entities could be defined in the DOCTYPE tag as shown in the example in . The actual content of the document is inside a <file>-element, it consists of <string>- and <entry>-elements. Several of the BibXMLext markup features are shown. We will use this input document for some examples below.
Utilities for BibXMLext data
Translating &BibTeX; to BibXMLext
First we describe a tool which can translate bibliography entries from &BibTeX; data to BibXMLext <entry>-elements. It also does some validation of the data. In some cases it is desirable to improve the result by hand afterwards (editing formulae, adding <URL>-elements, translating non-ASCII characters to unicode, ...).

See below for how to write the results to a BibXMLext file.
<#Include Label="StringBibAsXMLext">

The following functions allow parsing of data which are already in BibXMLext format.

<#Include Label="ParseBibXMLextString">

<#Include Label="WriteBibXMLextFile">

Bibliography Entries as Records
For working with BibXMLext entries we find it convenient to first translate the parse tree of an entry, as returned by , to a record with the field names of the entry as components whose value is the content of the field as string. These strings are generated with respect to a result type. The records are generated by the following function which can be customized by the user.
<#Include Label="RecBibXMLEntry">

<#Include Label="AddHandlerBuildRecBibXMLEntry">

<#Include Label="StringBibXMLEntry">

The following command may be useful to generate completly new bibliography entries in BibXMLext format. It also informs about the supported entry types and field names.

<#Include Label="TemplateBibXML">

<#Include Label="SearchMRSection">