This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [docbook-apps] About different graphical headers on pages


Hi Costin,
You asked how to get the part or chapter number.  You can get that number
using the 'label.markup' mode. When applied to a part, chapter, appendix or
section, that mode returns the number of the part, chapter, appendix or
section.  (Likewise, the 'title.markup' mode returns its title). The
'header.content' template that specifies your header graphic is called once
for each page-sequence, which is typically each chapter or appendix.  That
means the context node is a chapter or appendix.  So this will return its
number:

<xsl:variable name="mynumber">
  <xsl:apply-templates select="." mode="label.markup"/>
</xsl:variable>

Then you can use that value as part of the filename string for the
fo:external-graphic in the header, perhaps using the concat() function.

A <part> element has a page-sequence, but only for the part titlepage and
partintro.  It doesn't contain the pages for the chapters in the part.  So
if you want a chapter to display a part number, you would need to use:

  <xsl:apply-templates select="../part" mode="label.markup"/>

The processing instruction is another way to do it.  I think your template
didn't work because it didn't actually find the PI relative to the current
context.  You selected:

<xsl:with-param name="pis"
        select="ancestor-or-self::entry/processing-instruction('dbfo')"/>

Here 'entry' is a DocBook entry element, which is a table cell.   Given that
the context in the 'header.content' template is typically a chapter element,
this won't work, because a chapter will never have a table cell as an
ancestor.  But this might work:

select="chapterinfo/processing-instruction('dbfo')"

or

select="../part/partinfo/processing-instruction('dbfo')"

Hope this helps.

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net


----- Original Message ----- 
From: "Costin Stroie" <costinstroie@yahoo.co.uk>
To: <docbook-apps@lists.oasis-open.org>
Sent: Monday, April 11, 2005 2:12 PM
Subject: [docbook-apps] About different graphical headers on pages


> I'm in charge of writing an User Guide for a commercial product and I
> choose DocBook to write it. Most of the customization was made starting
> from the book "DocBook XSL: The Complete Guide", which is wonderful. I've
> learned how to put graphical headers on pages, but I have a problem I
> cannot solve.
>
> How can I put graphical headers different for each part or chapter? The
> image will contain the part or chapter name and number over some artwork.
> Therefore these graphics have to change from part to part (or chapter).
>
> I think one solution is to watch for the part number in the customization
> layer and use a different graphic file as external resource. But how can I
> find the part number?
>
> Another idea would be to use processing instructions inserted in each
> partinfo or chapterinfo pointing to some file and to use this attribute as
> variable in the customization layer. I have tried it and no results.
>
> The PI would be:
> <?dbfo headerimg="'../images/graphics/header_odd_p1.png'"?>
>
> And the xsl code is:
> <xsl:variable name="header.image.odd">
>     <xsl:call-template name="dbfo-attribute">
>       <xsl:with-param name="pis"
>         select="ancestor-or-self::entry/processing-instruction('dbfo')"/>
>       <xsl:with-param name="attribute" select="'headerimg'"/>
>     </xsl:call-template>
> </xsl:variable>
>
> And so, the variable is header.image.odd but when I tried to use it as:
> <fo:external-graphic content-height="15mm" text-align="center">
>     <xsl:attribute name="src">
>       <xsl:call-template name="fo-external-image">
>         <xsl:with-param name="filename" select="$header.image.odd"/>
>       </xsl:call-template>
>     </xsl:attribute>
> <fo:external-graphic>
>
> all I got in the fo file was:
> <fo:external-graphic content-height="15mm" text-align="center" src=""/>
>
> As I have no more solutions for this problem, I have chosen to write to
> Mr. Bob Stayton, who istructed me to join the list, and ask for help.
>
> -- 
> Costin Stroie (icq: 157008123)
>
>
>



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]