This is the mail archive of the xsl-list@mulberrytech.com mailing list .


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

Creating Headers in XSL:FO that correspond to chapter numbers



I have recently been converting an installation guide written in xml to a
pdf document using the xsl:fo translating language.  I am fairly new
to both xsl and fo, so please excuse the possible naivety of my questions.
I am writing to ask for advice on placing chapter numbers on page headings
corresponding to pages within those chapters. 

The XML document that I'm using has been summarized below:

<book>
  <title>
    text
  </title>
  <chapter>
    <title>titleval1</title>
    <body>text</body>
  </chapter>
  <chapter>
    <title>titleval2</title>
    <body>....</body>
  </chapter>
  <chapter>
    <title>titleval3</title>
    <body>....</body>
  </chapter>
</book>

In my xsl, I'd like to have a header that displays both the title
of the book, and the chapter number.  Here is a clip of code
from my xsl that displays the header:

<fo:static-content flow-name="xsl-before">
   <fo:block text-align-last="centered" font-size="10pt">
     <xsl:value-of select="title" />
     <xsl:text>/Chapter&#160;</xsl:text>
     <!-- Commands for Chapter Number go here -->
   </fo:block>
   <fo:display-rule />
</fo:static-content>

I number my chapters using the <xsl:number /> function.  I'll give
you a better idea of how I do this by displaying a piece of my
<xsl:template match="chapter"> template, which shows the code behind
chapter cover pages:

<xsl:if test="@pagebreak='yes'">
  <fo:block break-before="page" font-size="30pt"
   space-before.optimum="125pt" text-align-last="centered" 
   line-height="40pt" font-weight="bold">
    <xsl:text>Chapter&#160;</xsl:text>
    <xsl:number />
  </fo:block>
</xsl:if>
<xsl:if test="not(@pagebreak='yes')">
  <fo:block font-size="30pt" space-before.optimum="125pt"
   text-align-last="centered" line-height="40pt" font-weight="bold">
    <xsl:text>Chapter&#160;</xsl:text>
    <xsl:number/>
  </fo:block>
</xsl:if>

I'm finding it difficult to display the current chapter number in the
header since there doesn't seem to be a way for me to conditionalize
the header based on page number.  If there is a page-number-position
function, I can tell the header to display different chapter numbers 
depending on the page its on.  

A more robust way (in terms of code) of displaying chapter numbers would
involve finding a way to communicate to the header the chapter that is
currently being displayed in the region-body.  Although this seems
rather simple, variations of the <xsl:for-each> and <xsl:value-of select>
functions have left me with few results.  I have only found ways to
display one  chapter number throughout the entire installguide, or
all three chapter numbers together (123) throughout the guide.

I greatly appreciate any help you can give me.  Thank you in advance.

Sincerely,

Aadel Chaudhuri

Scientific Computing and Imaging (SCI) Institute
MIT Undergrad Student






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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