Create SGML and XML bibliographies
Prev | Chapter 10. Bibliographies | Next

## Create SGML and XML bibliographies

Although SGML documents are usually processed with a DSSSL toolchain and XML documents with a XML toolchain, the procedures to generate documents with bibliographies are similar enough to treat them in a single section. If you use the high-level tools provided by RefDB, you won't even notice a difference.

RefDB can create two types of bibliographies, cooked and raw. Cooked bibliographies are already preformatted using the information of a particular bibliography and citation style. Documents using cooked bibliographies have to be processed using the appropriate stylesheet driver files provided by RefDB. Raw bibliographies (currently supported only for XML documents) contain no particular formatting and should therefore be processed using the regular DocBook or TEI stylesheets.

RefDB provides both high-level tools which attempt to hide the entire complexity of the bibliography business, and low-level tools which allow experienced users to integrate RefDB into their own toolchains. We'll first describe the high-level approach which should always be the first choice. The subsequent sections give all the details about the low-level tools which you normally don't even want to know about.

### Keeping it simple with refdbnd

refdbnd provides the simplest approach to create, maintain, and transform documents with RefDB bibliographies. Once set up, all you'll have to do is to run something as simple as make pdf. The following subsections cover how to set up a refdbnd-managed project, how to cite, and how to process the document.

#### Setting up a project

refdbnd is an interactive script which creates a skeleton document and a custom-tailored `Makefile`. Start the script in a clean subdirectory by typing refdbnd. You'll be asked a couple of questions, each of which supplies sufficient background information for novice users. The script will then create three files (we'll assume that the basename that you provided was "foo"):

foo.short.[sgml|xml]

  The ".short" reminds you that you're supposed to use the short notation for citations in this file. This is simpler, usually more convenient, and should always be your first choice.

foo.[sgml|xml]

  This file is just a dummy in a fresh project. If you edit the file `foo.short.xml`, the file `foo.xml` will automatically be updated and fed to the subsequent processing steps next time you run make. Unless you know what you do, you don't want to touch this file.

Makefile

  This is a customized Makefile that contains all the information that you provided to refdbnd. Simply run commands like make pdf or make html to create printable or HTML output with formatted citations and bibliographies from your document.

#### Editing your document

The `foo.short[sgml|xml]` skeleton document contains the required markup to start a book or an article. You'll now want to open this file in your favourite text editor to write the contents and to add your citations. In DocBook SGML and XML documents, citations are encoded as `citation` elements. To distinguish these from `citation` elements that are not meant to be processed by RefDB, set the `role` attribute to `REFDB` in all caps. Each `citation` element contains one or more references, separated by semicolons. The trailing semicolon after the last reference is optional, so the following citations are absolutely equivalent:

    <citation role="REFDB">2;5;9</citation>
    <citation role="REFDB">2;5;9;</citation>

The values identifiy the bibliographic entries in your database. Use either numerical IDs as in the examples above, or alphanumeric citation keys as shown in the following example:

    <citation role="REFDB">Miller1999;Jones2001</citation>

The corresponding syntax for TEI XML documents is quite similar, except that we abuse the general-purpose `seg` element and tag it for use with RefDB by setting the `type` to `REFDBCITATION` in all caps:

    <seg type="REFDBCITATION">2;5;9</seg>

Again, you can use citation keys instead of the numerical IDs shown in the example above.

The examples shown above will be rendered as "regular" citations. In addition to this you can request author-only or year-only citations. These come in handy if you want to write something like: Jones et al. reported recently (2001)... Both the authors (Jones et al.) and the year (2001) need to be encoded as individual citations as shown in the following example:

    <para><citation role="REFDB">A:Jones2001</citation> reported
    recently <citation role="REFDB">Y:Jones2001</citation> ...</para>

You may have guessed that the prefix "A:" tags a citation as an author-only citation and that the prefix "Y:" means year-only.

### Note

These prefixes tag the whole citation, not a particular reference in the citation. Therefore the prefix must be the first thing right after the start tag. Multiple citations using the author-only or year-only style would make no sense anyway.

#### Transforming your document

The Makefiles created by refdbnd offer the following targets:

pdf

  This target generates a PDF file from your source document. PDF is a widely accepted document format with free viewers for essentially all current operating systems. Be aware that not all FO processors (used in transforming XML documents) offer PDF output.

html

  This runs all required commands to create HTML output, viewable with any web browser. Depending on your local setup, the output will be chunked into a collection of HTML files.

rtf

  This target generates a Rich Text Format (RTF) file. This plain text format is sort of a word processor interchange format understood by most current word processors, including MS Word, WordPerfect, and OpenOffice/StarOffice. Not all FO processors offer RTF output though.

ps

  This target is only available for SGML documents. It will create a Postscript document from your source. Postscript is the universal document format on Unix systems and can be printed directly on Postscript printers. Viewers are available for all current operating systems.

The Makefile also offers a few more targets. For each of the above targets there is a corresponding '<target>dist' target which creates a `.tar.gz` archive of the output document, along with its associated CSS stylesheet if applicable. The target 'all', which is also the default if you don't specify a target to make, builds all available output formats. Accordingly, the target 'dist' creates all archives. And finally, the target 'clean' removes all intermediate files and returns your directory to the original state.

The refdbnd-generated Makefiles should be sufficient for the average document. However, feel free to modify them in order to adapt them to specific needs. For example you can specify a different style in order to switch your output to a different citation and bibliography style. make also allows you to override variable settings on the command line. E.g. if you want to output your document using a different bibliography style without making it the permanent default, invoke make like this:

    	  ~$
    	  make clean && make pdf stylename="Eur.J.Pharmacol."

### Note

make clean removes intermediate files to let the change of the bibliography style take effect.

### Bibliographies, the hard way

If the simple approach outlined above does not suit your needs, you can turn to the low-level bibliography tools provided by RefDB. Needless to say, you can always start with a refdbnd-created project and use the low-level tools whenever you run into any limitations. However, this section describes the manual creation and transformation of documents from the ground up.

#### Prepare the document

RefDB's bibliography output is a `bibliography` element that contains all required references. You can redirect the output into a file and include this file at the spot where your bibliography should appear. To achieve this you need two modifications in your document:

1. When using DTD-based documents (i.e. DocBook 4.x or TEI P4), extend the document type declaration at the beginning of your document to declare the external entity. The first example is from a DocBook SGML document:

       <!DOCTYPE BOOK PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
       	    <!ENTITY bibliography "foo.bib.sgml">
       	    ]>
       	    ...

   The second example shows a TEI XML document:

       <?xml version="1.0"?>
       	    <!DOCTYPE TEI.2 PUBLIC "-//TEI P4//DTD Main Document Type//EN" "http://www.tei-c.org/P4X/DTD/tei2.dtd" [
       	    <!ENTITY % TEI.general 'INCLUDE'>
       	    <!ENTITY % TEI.names.dates 'INCLUDE'>
       	    <!ENTITY % TEI.linking 'INCLUDE'>
       	    <!ENTITY % TEI.XML 'INCLUDE'>
       	    <!ENTITY bibliography SYSTEM "refdbtest.bib.xml">
       	    ]>
       	    ...

   The name of the entity is of course yours to choose, but using “bibliography” as in this example is pretty descriptive.

   When using schema-based documents (i.e. DocBook 5.x or TEI P5), there is no need to declare the bibliography at the beginning of the document.

2. Include the bibliography at the desired spot as an external entity for DTD-based documents:

       ...
       	    &bibliography;
       	    ...

   Alternatively, use xinclude to include the bibliography in schema-based documents:

       ...
       	    <xi:include href="refdbtest.bib.xml"
       	    xmlns:xi="http://www.w3.org/2001/XInclude">
       	    <xi:fallback>refdbtest.bib.xml appears to be missing</xi:fallback>
       	    </xi:include>

   ### Note

   Some XSLT processors require a command-line switch or additional libraries to support xincludes. If your transformed document should lack the bibliographic listing, consult the documentation of your XSLT processor.

   You need to make sure that the included chunk of text is valid at the point where you want to include it. DocBook SGML and XML bibliographies are generated as `bibliography` elements, TEI XML bibliographies are wrapped in `div` elements.

#### Create citations

Creating citations and bibliographies in SGML or XML documents with RefDB is very similar to what you would do if you had to manually code the bibliographies - but without the sweat. First you create the citations. Each citation consists of one or more bibliographic references in the text, each of which points to one particular entry in the bibliography. Then you create a bibliography for all cited publications (and possibly some more). For an increased benefit you would certainly also want to create functional links from the citations to the corresponding bibliography entries, which would act as hyperlinks in suitable output formats like HTML or PDF. In real life, you would probably jump back and forth, adding a bibliography entry whenever you add a new citation, and invent suitable ID values for your bibliographic link targets as needed.

### Note

The distinction made here between a citation and a bibliographical reference may sound like nitpicking, but it will be important when we deal with citations that contain more than one bibliographical reference.

RefDB requires a slightly more formalized approach. You have to stick to a particular syntax when you create the citations, but the good news is that RefDB does almost all of the rest. You will usually also create the citations first and let RefDB create the bibliography just before you are ready to transform the first draft.

RefDB uses three different notations for references:

Short notation

  The short notation is, as the name implies, a lot faster to type and thus more convenient, but it requires an additional preprocessing step that adds some small restrictions to the way you write your documents (please see the section about refdbxp for details about these restrictions). The preprocessing of documents using the short notation also automates the issue of first and subsequent citations of a bibliographic entry and it automatically creates the ID values used in multiple citations. Using multiple databases per document is not supported by the short notation currently.

  The short notation is fully valid SGML or XML code, without any extensions of the original DTDs. You can use all sorts of SGML or XML processing tools on such documents.

Full notation

  The full notation offers full control but requires a lot more typing and thinking. It does not require a preprocessing step before the transformation, though. You need to take care of the issue of first and subsequent citations of a reference, and you have to manually generate ID values for use in multiple citations. You can include references taken from several databases.

  Just like the short notation, the full notation is also fully valid SGML or XML code, without any extensions of the original DTDs.

ID notation for raw bibliographies

  If you want to process your document with the default Docbook or TEI stylesheets using a raw bibliography, you just use the citation key as te value of the `linkend` attribute of the `xref` or `biblioref` elements to refer to the appropriate reference entry in the bibliography. RefDB will generate the bibliography using the citation key as the `id` or `xml:id` (for DocBook 5.x and TEI P5) attribute.

First we'll have a look at the short notation, before we get into the gruesome details of the full notation. Keep in mind that the refdbxp application interconverts the short and the full notation. You can convert your document back and forth as often as you wish, so you're not limited to the notation that you initially choose. In fact, you can mix both notations in a single document. Finally, we'll also show examples of the ID notation for raw bibliographies.

##### Short notation

The short notation has been described above as this is the notation which you use in refdbnd-maintained projects. The only thing you must not forget when not using refdbnd is that you must preprocess documents that contain citations in short notation with refdbxp before you transform the document to one of the output formats.

##### Full notation

The full notation is a lot more complex than the simple notation described above. So unless you have specific reasons to write citations in full notation from scratch, it is more advisable to use the short notation and preprocess your documents with refdbxp. The output created by this utility is the full notation described in this section.

The particular syntax of citations and bibliographic references is necessary for two reasons: first we have to tell RefDB which bibliographic database entry (and probably, from which database) we want to reference. Second, we need to encode which type of citation or reference we want. The exact markup depends on the DTD that your document uses, but the basics are the same.

In both DocBook and TEI documents, these two bits of information are encoded in attributes of elements that create a link from the reference to the bibliographic entry. In order to handle multiple citations correctly, these link elements need to be inside a wrapper element. For a DocBook document, basic citations therefore look like this:

    <citation role="REFDB">
    	  <xref linkend="ID1-X">
    	  </citation>
    	  <citation role="REFDB">
    	  <xref linkend="LITIBP-ID2-X">
    	  </citation>

| The `citation` element is a wrapper for one or more bibliographic references. The `role` attribute is set to `REFDB` to distinguish this `citation` from other `citation` elements that RefDB should leave alone. Each `citation` element can contain one or more `xref` elements.

Each `xref` element specifies one bibliographic reference. The value of the `linkend` attribute encodes which bibliographic item is referenced (in this case, the database entry with the ID 1) and how the reference should be rendered (see below). It consists of the string "ID" followed by the numerical database entry ID, and a trailing one-letter type specifier ("X" in this case), separated from the rest by a dash. This simple form does not encode the database from which the reference is to be pulled. When generating the bibliography, you will specify a default database from which all references without an explicit database label will be taken from. This form is most convenient if all your bibliographic items are stored in one database.

This `xref` element shows the syntax when an explicit database (LITIBP in this case) is specified. The attribute value consists of the database name, a dash, the string "ID", the numerical database entry ID, and the trailing type specifier. This form is mandatory only if you reference bibliographic entries from different databases in the same document (again, one database can be set as the default database in subsequent processing steps, so you could use the simple form for all references to entries in that particular database).

### Note

This and the following DocBook examples are given in SGML notation. Keep in mind two things when working with XML documents:

- The empty `xref` elements need a closing slash as in <xref linkend="ID2-X"/>.

- All attribute values relevant to RefDB must be in uppercase. This restriction is imposed by the way citations are currently extracted from the document. It may be dropped in later versions though.

The corresponding syntax in a TEI XML document looks like this:

    <seg type="REFDBCITATION">
    	  <ptr targOrder="U" target="ID1-X" TEIform="ptr"/>
    	  </seg>
    	  <seg type="REFDBCITATION">
    	  <ptr targOrder="U" target="LITIBP-ID2-X" TEIform="ptr"/>
    	  </seg>

| The general-purpose `seg` element with the `type` attribute set to `REFDBCITATION` is the citation wrapper for one or more bibliographic references.
| Each bibliographic reference is specified by a `ptr` element whose `target` attribute encodes the bibliographic entry that is referenced. As explained in the DocBook example, this is the simple form that does not specify the database.
| This is the corresponding bibliographic reference with the database specified.

### Note

You don't have to worry about the attributes in the example which are not mentioned in the explanations. These are TEI default attributes which do not have anything to do with RefDB (your XML editor will most likely create them automatically for you).

There are several ways to render citations and bibliographic references in the text. You select what you need by a trailing capital letter after the database ID (the "X" in the above examples). RefDB will create several preformatted strings in the bibliography file which can be linked to by selecting the proper postfix. These preformatted strings have several purposes, as shown in the following table:

Table 10.1. Bibliographic reference types

Postfix | Purpose
--- | ---
X | The most common case. This is the first occurrence of a reference which is to be displayed outside the flow of the text. In numerical citation schemes this will be something like "(2)", in author-year citation schemes this may be rendered as "(Miller et al., 1992)".
S | This is the same as X, but for a subsequent occurrence of the same reference. This distinction is important for some author-year citation schemes that print the full (or at least a longer) author list at the first occurrence and an abbreviated one at all subsequent occurrences of the same reference.
A | This is the first occurrence of a reference that displays the authorlist inside the flow of the text, like in "Miller et al. reported recently (2001)...".
Q | This is the same as A, but for subsequent occurrences of the same reference.
Y | This type complements the author-only references mentioned above. In numerical citation schemes this is usually rendered like a normal reference, e.g. as "(2)", but in author-year citation schemes usually only the publication date is rendered, as in "(2001)".

### Note

The exact formatting of these references, e.g. which citation style is used or which brackets surround the reference, is controlled by the style specification for a particular publication or publisher. This takes effect when you generate the bibliography and transform the final document.

An additional twist comes into play if you have multiple citations, i.e. a citation that contains more than one bibliographic reference. In most cases, all references are displayed inside of one pair of brackets. Some numerical citation styles require that bibliographic references with consecutive numbers be formatted as ranges within the same citation.

### Note

Formatting consecutive numbers as ranges kills the links from the reference to the bibliographic item for each reference that make up a range. Any generated hyperlinks will therefore point to one common target for all members of a multiple citation. If this is not desired (e.g. to keep the links alive in a HTML presenation of a scientific document), you may override this behaviour during the transformation of the final document.

In order to format these cases properly, you need to include a dummy element whose sole purpose is to provide a link to an element that contains the combined, preformatted citation string. This is shown for a DocBook document in the following example.

    <citation role="REFDB">
    	  <xref endterm="IMTHEFIRST" linkend="ID1" role="MULTIXREF">
    	  <xref linkend="ID1-X">
    	  <xref linkend="ID14-X">
    	  <xref linkend="ID7-X">
    	  </citation>

This is the additional `xref` element which is mandatory in multiple citations. The `linkend` specifies the target of a link, which by convention could be the first of the following references. Note that the attribute value does not have a trailing type specifier. The element must have a `role` attribute with the value `MULTIXREF`. You also have to provide an unique value for the `endterm` attribute. This specifies the ID value that will be used in the corresponding element in the RefDB-generated bibliography that contains the preformatted string for the multiple citation. The ID value has to start with the letters "IM" as a sort of sanity check.

| This and the following `xref` elements define the actual references that comprise the multiple citation.

### Note

The sequence of the `xref` elements that encode the actual references may be important. Depending on the bibliography style used for the document transformation, the references may be displayed in the sequence as they were entered, or they may be rearranged according to the sequence of the bibliographic entries in the finished bibliography.

Keep also in mind that all attribute values must be in uppercase for the same reasons as stated above.

The corresponding TEI citation is a little bit simpler:

    <seg type="REFDBCITATION">
    	  <ptr type="MULTIXREF" targOrder="U" target="IMTHEFIRST" TEIform="ptr"/>
    	  <ptr targOrder="U" target="ID1-X" TEIform="ptr"/>
    	  <ptr targOrder="U" target="LITIBP-ID21-X" TEIform="ptr"/>
    	  <ptr targOrder="U" target="ID5-X" TEIform="ptr"/>
    	  </seg>

This is the additional `ptr` element which is mandatory in multiple citations. The element must have a `type` attribute with the value `MULTIXREF`. You also have to provide an unique value for the `target` attribute. This specifies the ID value that will be used in the corresponding element in the RefDB-generated bibliography. The ID string has to start with "IM". In contrast to DocBook elements, there is no way to specify where a link should point to. The RefDB XSL stylesheets will use the first bibliographic entry referenced in a multiple citation as the link target.

| This and the following `xref` elements define the actual references that comprise the multiple citation.

##### ID notation for raw bibliographies

This notation is similar to what you'd do in a document which does not use RefDB bibliographies at all, except that you have to declare which `citation` elements should be processed by RefDB (it may very well be that RefDB is supposed to process all of these elements, but in order to support cases where it shouldn't, there is a mechanism to allow just this). Just set the `role` attribute of the `citation` element to `REFDB` to include it in the list of citations that runbib extracts from your document, like this:

    <citation role="REFDB"><xref linkend="Bellamy2002"/></citation>

#### Generate the bibliography

Unless you have good reasons not to do so, you should use the runbib shell script to generate the bibliography. This script greatly simplifies this task and offers a common interface for all supported document types. The following subsection will explain the use of this script. If you like to do it the hard way (or if you want to peek under the hood) you'll find a few explanations further down how to do this.

##### Use runbib

Lets assume you have a DocBook SGML document `mypaper.sgml` and want to submit it to the "Journal of Irreproducible Results". We further assume that the bibliography style for this famous periodical is stored in your database under the name "J.Irrep.Res." (see Manage bibliography styles to learn how it gets there). All your bibliography entries (at least those referenced without an explicit database name) are stored in the database `mybib`. Start the script from the directory that contains your document with the following command:

    	    ~$
    	    runbib -d mybib -S "J.Irrep.Res." -t db31 foo.sgml

For a similar TEI XML document `bar.xml` you would run:

    	    ~$
    	    runbib -d mybib -S "J.Irrep.Res." -t teix bar.xml

In both cases you will end up with a bibliography file (`foo.bib.sgml` and `bar.bib.xml`, respectively) as well as with a stylesheet (`J.Irrep.Res.dsl`) or a set of stylesheets (`J.Irrep.Res.fo.xsl` and `J.Irrep.Res.html.xsl`), respectively.

### Note

Don't worry if you are greeted by a list of (Open)Jade errors complaining about missing elements when you first run this script on a particular document. Your document contains a number of crosslinks that point to elements that do not exist yet - you use runbib precisely to create these elements (you thus face a classic bootstrapping problem). As soon as the bibliography is created, these error messages should go away. Later you will only get an error message for each bibliographic entry that was added since the last time you ran runbib.

To tell runbib that you want to create a raw instead of a cooked bibliography, use the `-r` command line switch. As there is no style information involved, you don't need the `-S` option in this case:

    	    ~$
    	    runbib -d mybib -r -t db50x bar.xml

This will create a raw bibliography from the DocBook 5.0 document `bar.xml`, using the reference entries in the database `mybib`.

##### Do it the hardest possible way

The following steps trace back exactly what the runbib script does. The only benefit of the hard way is that you have a chance to fiddle with the intermediate XML file which contains the list of bibliographic entries that should go into the bibliography. You can add further entries to extend the bibliography if you want to include uncited publications. The following procedure was written with a DocBook SGML document in mind, but transferring the commands to XML documents is straightforward. However, when working with XML documents there are additional steps required as outlined below.

1. Extract the list of bibliographic references

   Use Jade or OpenJade with the `citations.dsl` stylesheet to create a list of the reference IDs from SGML files (provide full paths as needed):

       		#~
       		openjade -t sgml -d citations.dsl /usr/lib/sgml/declaration/docbook-3.1.dcl foo.sgml > foo.id.xml

   Be prepared for a long list of "missing ID" error messages. This is due to the fact that the elements with the IDs that the `xref` elements in the citations point to do not yet exist, they will be generated in the RefDB bibliography output. If you process documents with more than 200 citations, you'll have to increase the maximum error limit of Jade in order to obtain all IDs the first time. After the first complete pass (including the steps outlined below), Jade will only complain about any additional citations that you have inserted since the last run.

   XML files are processed using your favourite XSL processor. There are two different stylesheets available for raw and for cooked bibliographies. Both work all the same for DTD-based (DocBook 4.x, TEI P4) and schema-based (DocBook 5.x, TEI P5) documents:

       		#~
       		xsltproc --catalogs --xinclude /usr/local/share/refdb/xsl/citations.xsl  foo.xml > foo.id.xml
       		#~
       		xsltproc --catalogs --xinclude /usr/local/share/refdb/xsl/citationsraw.xsl  foo.xml > foo.id.xml

   In all cases the output is a simple XML file that contains the information about all `citation` and `xref` elements with their relevant attributes. It is absolutely legal to extend this file with additional citation elements to specify references which are not cited but nonetheless should appear in the bibliography.

   Unfortunately, both Jade and OpenJade don't get that Doctype line quite correct. Both forget to insert a space between the public and the system identifier, thus leaving you with a not well-formed document. Fire up your favourite editor and fix this line manually (insert a space between the two consecutive quotation marks on line 2).

   If you edit this intermediate XML file (that is, if you do more than just fixing the Doctype line), you should make sure that the result is still valid according to the CitationList XML DTD. RefDB uses a non-validating parser to read this file so deviations from the DTD may slip through undetected and may have undesired consequences. The intermediate XML file carries the SYSTEM identifier of the CitationList XML DTD in the document type declaration. You may have to adapt the stylesheet `citations.dsl` to use the correct path for your local system.

   The following command lines can be used to validate the document with (o)nsgmls or xmllint (change the paths as necessary):

       		~$
       		onsgmls -wxml -s /usr/lib/sgml/declaration/xml.dcl foo.id.xml
       		~$
       		xmllint --noout --nonet --dtdvalid file:///usr/local/share/refdb/dtd/citationlistx.dtd foo.id.xml

2. Create the bibliography file

       		~$
       		refdbib -d mybib -S "J.Irrep.Res." -t db31 foo.id.xml > foo.bib.sgml

   This assumes that your reference database is called "mybib" and that you try to publish your paper in a journal that accepts the style with the name "J.Irrep.Res.".

   In addition to the bibliography file, refdbib will also create a DSSSL script containing the style specification. This file is a customized driver file for the RefDB-DocBook driver files and provides a couple of variable values specific for the given bibliography style.

   If you want to generate a raw bibliography, use a command like this:

       		~$
       		refdbib -d mybib -r -t db50x foo.id.xml > foo.bib.xml

3. Post-processing

   This step is only required for XML documents. First we have to bring the stylesheets into shape, and if it is a TEI document, we'll also have to transform the bibliography file itself.

   refdbib creates a general-purpose XSL stylesheet which we need to turn into one FO and one HTML stylesheet. Create two copies of the file. If the stylesheet was e.g. `J.Biol.Chem.xsl`, you need one copy named `J.Biol.Chem.fo.xsl` and one copy named `J.Biol.Chem.html.xsl`. Scan the files for an import statement whose `href` attribute is surrounded with two "<!-- REFDBSTYLESHEET -->" comments. The value of this attribute must be set to the full path of the corresponding original stylesheet (DocBook FO or HTML, or TEI FO or HTML).

   If you're working on a TEI P4 XML document, you'll have to transform the bibliography file itself. This is a DocBook SGML document and can be transformed easily with Jade/OpenJade and the `bibdb2tei.dsl` stylesheet. TEI P5 bibliographies are exported directly by refdbd and do not require further processing.

#### Transform the document

Finally you can transform the document to create printable or HTML output. If you use cooked bibliographies you have to use the RefDB driver files for the DocBook or TEI stylesheets.

In addition to the general modifications of these driver files we'll have to apply modifications specific for the particular reference style. Therefore you have to specify the DSSSL or XSL style specification file that was created in the previous step. For your convenience it is recommended to use the supplied refdbjade and refdbxml scripts for DSSSL and XSL transformations, respectively, which were designed for this task:

    	  ~$
    	  refdbjade -t html -s J.Irrep.Res.dsl foo.sgml

    	  ~$
    	  refdbxml -t pdf -s J.Irrep.Res.fo.xsl bar.xml

If you want to change the bibliography style of your document, all you need to do is to rerun runbib and refdbjade or refdbxml with the new parameters. No changes to your DocBook source are necessary.

Processing your document with a raw bibliography does not differ from processing any other DocBook or TEI document. However, you can still use the refdbxml script to avoid having to type the full command line of your XSL processor. Use something like this to process a Docbook 5.0 document with a raw bibliography:

    	  ~$
    	  refdbxml -t pdf -s db5 bar.xml

The `-s` option tells the script to use the stock DocBook stylesheets for version 5. Other values are "db", "tei", and "tei5" for the DocBook stylesheet for version 4.x, the TEI P4 stylesheets, and the TEI P5 stylesheets, respectively

### Note

If you want to create a bibliography for each part of a book or for each chapter, the procedure is not much different. The simplest approach is to keep the parts or chapters in individual files and process these individually as described above for the whole document. You'll get several bibliography files that you can include into the corresponding document source files.

### How to use custom stylesheets

We have assumed in the previous instructions that the stock DocBook or TEI stylesheets suit your needs when processing your documents. However, if you need a particular formatting of the parts of your document which are not under the control of RefDB (things like fonts, colours, font sizes and so on), you'll have to create a driver file with your personal modifications, and somehow make sure this driver file is used whenever your document is processed. This section discusses the available mechanisms to use particular XSL driver files as a per-user or a per-document option. Currently no such mechanism is available for the DSSSL stylesheets.

A driver file is essentially a stylesheet which imports the stock stylesheets and adds a few modifications. XSL is designed such that any definition of a template in the driver file overrides the definition in the imported file. RefDB uses this mechanism extensively to provide the formatting of citations and bibliographic listings. Whenever you run refdbib (or runbib which calls the former), a driver file is created which imports a general RefDB driver file. This general driver file in turn includes the stock stylesheets (imports can be nested). If the stock stylesheets don't suit your needs, you'll have to provide two driver files:

- a driver file for the stock stylesheets which contains your modifications of those parts which are not under RefDB's control. Obviously, this driver file must import the stock stylesheets. You can put this driver file into any convenient subdirectory in your home directory. For further information about how to set up a driver file, please see Bob Stayton's DocBook XSL Guide (the general approach is applicable to TEI and any other XSL stylesheets just as well)

- a modified general RefDB driver file which imports your driver file instead of the stock stylesheets. To this end, copy the relevant general RefDB driver file (there are driver files for fo, html, and xhtml output, and they are available both for DocBook and for TEI) to a convenient subdirectory in your home directory and modify the import statements to suit your needs.

There are two options to have the modified general RefDB driver file used instead of the default ones:

- if you want to apply your modifications as a default to all documents which you process, consider adding the paths to your personal copy of the `runbibrc` configuration file.

- if you want to apply the modifications to a particular refdbnd-created project, just specify the paths of the modified general RefDB driver files when setting up the project. This way, each project can use a different set of modifications.

Figure 10.2, “Stylesheets involved in processing RefDB documents” visualizes how a document containing a RefDB bibliography is processed with a focus on the stylesheets involved. The example shows the transformation of a DocBook XML document to fo (which might then be processed to e.g. PDF). However, the same principles are applicable to other output formats and other document types. The left hand side shows the default processing using the stylesheets installed by RefDB. refdbib (which may be invoked by runbib, or by running a refdbnd-created `Makefile`) creates an intermediate stylesheet containing the style-specific information. This stylesheet is converted to output-type-specific driver files for fo, html, and sometimes xhtml output. The figure shows only the fo driver file to keep it simple. This driver file imports the general RefDB fo driver file, which in turn imports the appropriate official DocBook fo stylesheet. The right hand side shows how to process the same document with a DocBook driver file which may alter the general formatting of the document (page size, borders, fonts and the like). As you can see, you have to provide both the DocBook driver file and an equivalent of the general RefDB fo driver file, which has to import your driver file instead of the stock DocBook stylesheet.

### Note

You can of course add all your general modifications to `myrefdbdriver.xsl` and have that import the stock DocBook stylesheet. However, doing it in two steps as shown will allow you to use `mydocbookdriver.xsl` for non-RefDB projects as well.

Figure 10.2. Stylesheets involved in processing RefDB documents

Prev | Up | Next
Manage bibliography styles | Home | Create LaTeX/BibTeX bibliographies