[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] customized header and footer
Isabelle DENGHIEN - IFR49 wrote: > > Thanks a lot, but it is not exactly that I'm looking for. > In fact, I would like to customize header and footer with image, > personal content ..... > Do you know a way to do this ? > > Isa Isabelle, The xsl template I'm using for HTML is the following ---------------------- Cut Here --------------------------------- <!-- This template creates the header of a page for chunked output Original definition in : chunk-common.xsl --> <xsl:template name="header.navigation"> <xsl:param name="prev" select="/foo"/> <xsl:param name="next" select="/foo"/> <xsl:param name="nav.context"/> <xsl:variable name="home" select="/*[1]"/> <xsl:variable name="up" select="parent::*"/> <xsl:variable name="prt" select="ancestor::part"/> <xsl:variable name="index" select="/descendant::index[1]"/> <xsl:variable name="itext"> <xsl:call-template name="gentext"> <xsl:with-param name="key" select="'index'"/> </xsl:call-template> </xsl:variable> <xsl:if test="$suppress.navigation = '0' and $suppress.header.navigation = '0'"> <div class="navheader"> <table width="100%" summary="Navigation header" cellpadding="0" cellspacing="0"> <tr> <td width="15%" align="left"> <xsl:if test="count($prev) > 0"> <a accesskey="p"> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$prev"/> </xsl:call-template> </xsl:attribute> <xsl:call-template name="navig.content"> <xsl:with-param name="direction" select="'prev'"/> </xsl:call-template> </a> <xsl:text>  </xsl:text> </xsl:if> <xsl:if test="count($up) > 0 and $home != ."> <a accesskey="u"> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$up"/> </xsl:call-template> </xsl:attribute> <xsl:call-template name="navig.content"> <xsl:with-param name="direction" select="'up'"/> </xsl:call-template> </a> <xsl:text>  </xsl:text> </xsl:if> <xsl:if test="count($next)>0"> <a accesskey="n"> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$next"/> </xsl:call-template> </xsl:attribute> <xsl:call-template name="navig.content"> <xsl:with-param name="direction" select="'next'"/> </xsl:call-template> </a> </xsl:if> </td> <th width="70%" align="center"> <xsl:apply-templates select="/*" mode="title.markup"/> <xsl:if test="count($prt) > 0 and generate-id($up) != generate-id($prt)"> <xsl:text> - </xsl:text> <xsl:apply-templates select="$prt" mode="title.markup"/> </xsl:if> <xsl:if test="count($up) > 0 and generate-id($up) != generate-id($home) and $navig.showtitles != 0"> <xsl:text> - </xsl:text> <xsl:apply-templates select="$up" mode="title.markup"/> </xsl:if> </th> <td rowspan="2" width="15%" align="right"> <table cellpadding="0" cellspacing="0"> <tr> <td align="center"> <div class="boxed" id="llink"> <xsl:choose> <xsl:when test="$haiku = 1"> <a accesskey="l" href="../index.html"> <xsl:value-of select="$l10n.gentext.default.language"/> </a> </xsl:when> <xsl:otherwise> <xsl:value-of select="$l10n.gentext.default.language"/> </xsl:otherwise> </xsl:choose> </div> </td> <!-- Add a link to the index if it exists --> <xsl:if test="count($index) > 0 and $index != ."> <td align="center"> <div class="boxed" id="ilink"> <a accesskey="i"> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$index"/> </xsl:call-template> </xsl:attribute> <xsl:value-of select="substring($itext,1,1)"/> </a> </div> </td> </xsl:if> <xsl:if test="$home != ."> <td align="center"> <a accesskey="h"> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$home"/> </xsl:call-template> </xsl:attribute> <xsl:call-template name="navig.content"> <xsl:with-param name="direction" select="'home'"/> </xsl:call-template> </a> </td> </xsl:if> </tr> <tr> <td> </td> <xsl:if test="count($index) > 0 and $index != ."> <td align="center"> <a> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$index"/> </xsl:call-template> </xsl:attribute> <xsl:value-of select="$itext"/> </a> </td> </xsl:if> <xsl:if test="$home != ."> <td align="center"> <a accesskey="h"> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$home"/> </xsl:call-template> </xsl:attribute> <xsl:call-template name="gentext"> <xsl:with-param name="key" select="'nav-home'"/> </xsl:call-template> </a> </td> </xsl:if> </tr> </table> </td> </tr> <tr> <td colspan="2"> <xsl:if test="count($prev) > 0"> <xsl:call-template name="gentext"> <xsl:with-param name="key" select="'nav-prev'"/> </xsl:call-template> <xsl:text>: </xsl:text> <a> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$prev"/> </xsl:call-template> </xsl:attribute> <xsl:apply-templates select="$prev" mode="title.markup"/> </a> <xsl:text>  </xsl:text> </xsl:if> <xsl:if test="(count($up) > 0) and ($home != .)"> <xsl:call-template name="gentext"> <xsl:with-param name="key" select="'nav-up'"/> </xsl:call-template> <xsl:text>: </xsl:text> <a> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$up"/> </xsl:call-template> </xsl:attribute> <xsl:apply-templates select="$up" mode="title.markup"/> </a> <xsl:text>  </xsl:text> </xsl:if> <xsl:if test="count($next) > 0"> <xsl:call-template name="gentext"> <xsl:with-param name="key" select="'nav-next'"/> </xsl:call-template> <xsl:text>: </xsl:text> <a> <xsl:attribute name="href"> <xsl:call-template name="href.target"> <xsl:with-param name="object" select="$next"/> </xsl:call-template> </xsl:attribute> <xsl:apply-templates select="$next" mode="title.markup"/> </a> </xsl:if> </td> </tr> </table> <xsl:if test="$header.rule != 0"> <hr/> </xsl:if> </div> </xsl:if> </xsl:template> ---------------------- Cut Here --------------------------------- With the output looking like HeaderExample.jpg And for XSL-FO. For FO you also need to set the margins to allow for the extra logo space. ---------------------- Cut Here --------------------------------- <!-- Change footer to show IssueNum, Date, Copyright Page Number BeOS Logo Original in fo/pagesetup.xsl --> <xsl:template name="footer.content"> <xsl:param name="pageclass" select="''"/> <xsl:param name="sequence" select="''"/> <xsl:param name="position" select="''"/> <xsl:param name="gentext-key" select="''"/> <fo:block> <!-- pageclass can be front, body, back --> <!-- sequence can be odd, even, first, blank --> <!-- position can be left, center, right --> <xsl:choose> <xsl:when test="$pageclass = 'titlepage'"> <!-- nop; no footer on title pages --> </xsl:when> <xsl:when test="$double.sided != 0 and $sequence = 'even' and $position='left'"> <fo:page-number/> </xsl:when> <xsl:when test="$double.sided != 0 and ($sequence = 'odd' or $sequence = 'first') and $position='right'"> <fo:page-number/> </xsl:when> <xsl:when test="$double.sided = 0 and $position='left'"> <fo:block> <xsl:text>Issue </xsl:text> <xsl:value-of select="/article/info/issuenum"/> <xsl:text>, </xsl:text> <xsl:value-of select="/article/info/date"/> </fo:block> <fo:block> © 1995-2001 Be Inc. </fo:block> </xsl:when> <xsl:when test="$double.sided = 0 and $position='center'"> <xsl:text>Page </xsl:text> <fo:page-number/> <xsl:text> of </xsl:text> <fo:page-number-citation ref-id="lastpage"/> </xsl:when> <xsl:when test="$double.sided = 0 and $position='right'"> <fo:external-graphic width="100%" scaling="uniform"> <xsl:attribute name="src"> <xsl:call-template name="fo-external-image"> <xsl:with-param name="filename">../../images/be_logo.png</xsl:with-param> </xsl:call-template> </xsl:attribute> </fo:external-graphic> </xsl:when> <xsl:when test="$sequence='blank'"> <xsl:choose> <xsl:when test="$double.sided != 0 and $position = 'left'"> <fo:page-number/> </xsl:when> <xsl:when test="$double.sided = 0 and $position = 'center'"> <fo:page-number/> </xsl:when> <xsl:otherwise> <!-- nop --> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <!-- nop --> </xsl:otherwise> </xsl:choose> </fo:block> </xsl:template> <!-- Change footer cells to use 'display-align: center'. This sets the vertical alignment. --> <xsl:template name="footer.table"> <xsl:param name="pageclass" select="''"/> <xsl:param name="sequence" select="''"/> <xsl:param name="gentext-key" select="''"/> <!-- default is a single table style for all footers --> <!-- Customize it for different page classes or sequence location --> <xsl:choose> <xsl:when test="$pageclass = 'index'"> <xsl:attribute name="margin-left">0pt</xsl:attribute> </xsl:when> </xsl:choose> <xsl:variable name="column1"> <xsl:choose> <xsl:when test="$double.sided = 0">1</xsl:when> <xsl:when test="$sequence = 'first' or $sequence = 'odd'">1</xsl:when> <xsl:otherwise>3</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="column3"> <xsl:choose> <xsl:when test="$double.sided = 0">3</xsl:when> <xsl:when test="$sequence = 'first' or $sequence = 'odd'">3</xsl:when> <xsl:otherwise>1</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="candidate"> <fo:table table-layout="fixed" width="100%"> <xsl:call-template name="foot.sep.rule"> <xsl:with-param name="pageclass" select="$pageclass"/> <xsl:with-param name="sequence" select="$sequence"/> <xsl:with-param name="gentext-key" select="$gentext-key"/> </xsl:call-template> <fo:table-column column-number="1"> <xsl:attribute name="column-width"> <xsl:text>proportional-column-width(</xsl:text> <xsl:call-template name="header.footer.width"> <xsl:with-param name="location">footer</xsl:with-param> <xsl:with-param name="position" select="$column1"/> </xsl:call-template> <xsl:text>)</xsl:text> </xsl:attribute> </fo:table-column> <fo:table-column column-number="2"> <xsl:attribute name="column-width"> <xsl:text>proportional-column-width(</xsl:text> <xsl:call-template name="header.footer.width"> <xsl:with-param name="location">footer</xsl:with-param> <xsl:with-param name="position" select="2"/> </xsl:call-template> <xsl:text>)</xsl:text> </xsl:attribute> </fo:table-column> <fo:table-column column-number="3"> <xsl:attribute name="column-width"> <xsl:text>proportional-column-width(</xsl:text> <xsl:call-template name="header.footer.width"> <xsl:with-param name="location">footer</xsl:with-param> <xsl:with-param name="position" select="$column3"/> </xsl:call-template> <xsl:text>)</xsl:text> </xsl:attribute> </fo:table-column> <fo:table-body> <fo:table-row height="14pt"> <fo:table-cell text-align="left" display-align="center"> <xsl:if test="$fop.extensions = 0"> <xsl:attribute name="relative-align">baseline</xsl:attribute> </xsl:if> <fo:block> <xsl:call-template name="footer.content"> <xsl:with-param name="pageclass" select="$pageclass"/> <xsl:with-param name="sequence" select="$sequence"/> <xsl:with-param name="position" select="'left'"/> <xsl:with-param name="gentext-key" select="$gentext-key"/> </xsl:call-template> </fo:block> </fo:table-cell> <fo:table-cell text-align="center" display-align="center"> <xsl:if test="$fop.extensions = 0"> <xsl:attribute name="relative-align">baseline</xsl:attribute> </xsl:if> <fo:block> <xsl:call-template name="footer.content"> <xsl:with-param name="pageclass" select="$pageclass"/> <xsl:with-param name="sequence" select="$sequence"/> <xsl:with-param name="position" select="'center'"/> <xsl:with-param name="gentext-key" select="$gentext-key"/> </xsl:call-template> </fo:block> </fo:table-cell> <fo:table-cell text-align="right" display-align="center"> <xsl:if test="$fop.extensions = 0"> <xsl:attribute name="relative-align">baseline</xsl:attribute> </xsl:if> <fo:block> <xsl:call-template name="footer.content"> <xsl:with-param name="pageclass" select="$pageclass"/> <xsl:with-param name="sequence" select="$sequence"/> <xsl:with-param name="position" select="'right'"/> <xsl:with-param name="gentext-key" select="$gentext-key"/> </xsl:call-template> </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </xsl:variable> <!-- Really output a footer? --> <xsl:choose> <xsl:when test="$pageclass='titlepage' and $gentext-key='book' and $sequence='first'"> <!-- no, book titlepages have no footers at all --> </xsl:when> <xsl:when test="$sequence = 'blank' and $footers.on.blank.pages = 0"> <!-- no output --> </xsl:when> <xsl:otherwise> <xsl:copy-of select="$candidate"/> </xsl:otherwise> </xsl:choose> </xsl:template> ---------------------- Cut Here --------------------------------- Which produces something like FooterExample.jpg Experimentation is the key. Don't be afraid to break the formatting. Regards Simon Kennedy
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]