[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Creating Headers in XSL:FO that correspond to chapter

Subject: Creating Headers in XSL:FO that correspond to chapter numbers
From: Aadel Chaudhuri <aadel@xxxxxxxxxxx>
Date: Thu, 26 Jul 2001 10:15:44 -0600
aadel chaudhuri
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.