XML technologies / DocBook / The DocBook XSL stylesheets / Customizing a title page directly / Adding a logo
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
This section shows how to add a logo to an article and transform it to HTML. Proceed as follows:
Customizing your document
In your article, insidearticleinfoorinfoadd an image usingmediaobject. For a particular alignment or size, add attributes toimagedata(see Graphics). Replace the logo filename and path if needed:
For DocBook 4 documents:
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd">
<article>
<articleinfo>
<mediaobject>
<imageobject role="html">
<imagedata fileref="logo.png"/>
</imageobject>
<imageobject role="fo">
<imagedata fileref="logo.png"/>
</imageobject>
</mediaobject>
</articleinfo>
<!-- Inhalt des Artikels -->
</article>
For DocBook 5 documents:
<article xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="de">
<info>
<mediaobject>
<imageobject role="html">
<imagedata fileref="logo.png"/>
</imageobject>
<imageobject role="fo">
<imagedata fileref="logo.png"/>
</imageobject>
</mediaobject>
</info>
<!-- Inhalt des Artikels -->
</article>Where should the logo appear?
Choose where the logo should appear: before, after or within a title page. In this example, it appears before the title page, so customize the templatearticle.titlepage.before.recto.Create a customization file
Create a customization file as shown in Creating a customization file.Adding templates to the customization file
Add the following template, choosing the customization file for your DocBook version:
For DocBook 4 documents, add:
<xsl:template name="article.titlepage.before.recto">
<xsl:if test="articleinfo/mediaobject">
<div class="logo">
<xsl:apply-templates select="articleinfo/mediaobject"/>
</div>
</xsl:if>
</xsl:template>
For DocBook 5 documents, add:
<xsl:template name="article.titlepage.before.recto">
<xsl:if test="d:info/d:mediaobject">
<div class="logo">
<xsl:apply-templates select="d:info/d:mediaobject"/>
</div>
</xsl:if>
</xsl:template>Transforming
Transform the document with the customization file:
xsltproc --output artikel.html XSLT-Stylesheet artikel.xmlThese steps also work for XSL-FO. Simply replace the div element from (X)HTML with fo:block from XSL-FO and delete the p element.
If you inserted several images in articleinfo or info all are considered. Whether this is useful depends on your document. If documents always use the same logo, this method is overly flexible. Instead, inside article.titlepage.before.recto include the logo directly. For (X)HTML, add an img element referencing the logo. For XSL-FO, use fo:external-graphic or fo:instream-foreign-object.
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top