XSL-FO Table of Contents Help!

Discussion in 'Software' started by Rezon, Apr 19, 2005.

  1. Rezon

    Rezon Private E-2

    Hi everyone,

    I'm new to XSL-FO and I've been trying to create a table of contents for a book and am having no such luck. Maybe I'm not sure where to put it or maybe something in my syntax is messed up. Maybe I'm missing the whole point. The following is my code for the toc portion:

    <xsl:template name="toc">
    <page-sequence master-reference="contents">
    <fo:block font-family="Garamond" text-align="center"
    font-size="12pt">
    Table of Contents
    </fo:block>
    <xsl:for-each select="book/text/chapter">
    <fo:block font-family="Garamond" text-align="justify" font-size="10pt">
    <fo:inline>
    <xsl:value-of select="@name" />
    <fo:leader leader-pattern="dots" />
    <fo:page-number-citation ref-id="{generate-id()}" />
    </fo:inline>
    </fo:block>
    </xsl:for-each>
    </page-sequence>
    </xsl:template>

    I've been placing the "<xsl:call-template name="toc"/>" inside a template match for the title-page after a closing page-sequence tag. I'm doing this becuase this is where I want the TOC to be placed. I'm just not sure what I'm doing wrong and it seems there isn't much information online about creating a TOC using XSL-FO. I find the O'Reilly book to not be much help either. Any help you could give me is greatly appreciated. If you need to see my .xsl file, send me a PM and I'd be happy to send it your way. I'm also not very good with XSLT, I know the basics from online tutorials, but I am by no means good at it. Thanks in advance.

    ~Rezon
     
  2. Rezon

    Rezon Private E-2

    Alright I got the chapter titles to appear... but the page numbers still don't. I have footers with page numbers on each page... they're working fine. Here is my code currently:

    <xsl:template match="/" mode="toc">
    <fo:block font-family="Garamond" text-align="center" font-size="12pt">
    Table of Contents
    </fo:block>

    <xsl:for-each select="book/text/chapter">
    <fo:block font-family="Garamond" text-align="justify" font-size="10pt">
    <fo:inline>
    <xsl:value-of select="@name" />
    <fo:leader leader-pattern="dots" />
    <fo:page-number-citation ref-id="{generate-id()}" />
    </fo:inline>
    </fo:block>

    </xsl:for-each>
    <fo:block break-after="page" />
    </xsl:template>

    I don't think I really understand the <page-number-citation> command... I've used {generate-id()} and I've used the @id attribute which is part of my chapter tag. Bot don't produce page numbers and the O'Reilly book doesn't explain them as far as I can tell.

    ~Rezon
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds