Customizing bibliography output

If you don't like the square brackets, you can change them with a stylesheet customization. These two templates control the prefix and suffix characters:

<xsl:template match="biblioentry|bibliomixed" mode="xref-to-prefix">

<xsl:template match="biblioentry|bibliomixed" mode="xref-to-suffix">

Copy these templates to your customization layer and change the text that they generate.

If you have other customizations for the labels on entries, then you can customize the biblioentry.label template. For example, you may have turned off numbering of entries, but some of your entries have an abbrev element that you don't want to show. You can turn them off with the following customization:

<xsl:template name="biblioentry.label">
 <!--do nothing --> 

This template normally generates the label with a number or abbreviation. This customization turns off all labels for entries in a bibliography by redefining the template to do nothing.

If you don't like the way a particular bibliographic item is formatted, then you can customize its template. Elements in a biblioentry are processed with templates in mode="bibliography.mode" Elements in a bibliomixed are processed with templates in mode="bibliomixed.mode". Look for the appropriate template in biblio.xsl (either html or fo), and then copy it to your customization layer to change it. For example:

<xsl:template match="author" mode="bibliography.mode">
  <span class="{name(.)}">
    <xsl:call-template name=""/>
    <xsl:value-of select="$biblioentry.item.separator"/>

This template formats an author within a biblioentry for HTML output. It puts the output within an HTML span element so it can add a class="author" attribute, which makes it possible to apply styles with a CSS stylesheet. Then it calls the template to output the author's name. Then it adds the $biblioentry.item.separator, which is just a period by default. The template for bibliomixed using mode="bibliomixed.mode" is similar except it omits the trailing period. It assumes you are adding any necessary punctuation literally.

If you want the order of elements in the output to differ from how they appear in biblioentry element, then you will have to do a larger customization. There is no easy way to do this now, but you can expect this feature to become available in a future version of the DocBook stylesheets. To do it now, you must copy the template from biblio.xsl with match="biblioentry" to your customization layer. Within that template, locate these lines (HTML version):

<div class="{name(.)}">
    <xsl:call-template name="anchor"/>
      <xsl:call-template  name="biblioentry.label"/>
      <xsl:apply-templates  mode="bibliography.mode"/>

The line <xsl:apply-templates mode="bibliography.mode"/> acts on each child of the biblioentry in the order in which they appear in the document. You need to replace that line with a sequence of similar lines, each of which selects a particular element. The order is then determined by those lines. For example:

<xsl:apply-templates  select="author"  mode="bibliography.mode"/>
<xsl:apply-templates  select="title"  mode="bibliography.mode"/>
<xsl:apply-templates  select="publisher"  mode="bibliography.mode"/>

Now the output for each entry will have the order author, title, publisher, regardless of the order of those elements in the source document.

Bibliography title

The title Bibliography that appears at the beginning of a bibliography is generated by the stylesheet if you don't include a title element. If your document uses a lang other than English, then the generated title is in the appropriate language. If you need to change the title text, just add a title element to your document, as in the following example:

  <title>Further Reading</title>

The formatting of the bibliography title is handled as part of the general titlepage mechanism in DocBook XSL. That means the specifications original in the title page spec file titlepage.templates.xml (that's .xml) in the html or fo stylesheet subdirectory.

For HTML output, it is easiest to format the title using a CSS stylesheet. You can create a CSS selector like this:

div.bibliography div.titlepage h2.title {
   put your CSS styles here

For print output, the bibliography title, like other component elements, is processed using the component.title template. See the section “Other component titles” for a description of how to customize such titles.