Loading ...
Sorry, an error occurred while loading the content.

Re: How to arrange Pages in Fo

Expand Messages
  • neuggs@concentric.net
    Anand, There really isn t a way to deal with the result try after the fact. However, depending on the organization of the XML, I d think something like a TOC
    Message 1 of 4 , Sep 7, 2001
    • 0 Attachment
      Anand,

      There really isn't a way to deal with the result try "after the
      fact." However, depending on the organization of the XML, I'd think
      something like a TOC could be "calculated" using XSLT.

      Here's an example of what I mean. (Note that I omitted all the FO
      stuff in order to clearly illustrate the point of ordered processing
      via XSLT.)

      XML:
      <?xml version='1.0'?>
      <Book Title="Some Title">
      <Chapter Title="First Chapter">
      <P>Some text for the first ch.</P>
      </Chapter>
      <Chapter Title="Second Chapter">
      <P>Some text for the second ch.</P>
      </Chapter>
      <Chapter Title="Third Chapter">
      <P>Some text for the third ch.</P>
      </Chapter>
      <Chapter Title="Fourth Chapter">
      <P>Some text for the fourth ch.</P>
      </Chapter>
      </Book>

      XSL Stylesheet:
      <?xml version='1.0'?>

      <xsl:stylesheet
      xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
      version='1.0'>

      <xsl:template match="/">
      <!-- Create TOC -->
      <xsl:call-template name="TOC">
      <xsl:with-param name="Book" select="Book"/>
      </xsl:call-template>

      <!-- Process the document as always -->
      <xsl:apply-templates select="Book"/>
      </xsl:template>

      <!-- "Normal" template -->
      <xsl:template match="Chapter">
      <xsl:value-of select="@Title"/>
      <xsl:value-of select="./P"/>
      </xsl:template>

      <!-- Named template for TOC -->
      <xsl:template name="TOC">
      Table Of Contents
      <xsl:for-each select="$Book/Chapter">
      <xsl:value-of select="position(.)"/>
      <xsl:value-of select="@Title"/>
      </xsl:for-each>
      </xsl:template>
      </xsl:stylesheet>

      What I do first is call a named template (i.e., "TOC") and pass it
      the data I want it to deal with (the "Book" element and everything
      under it) for the TOC. In that template, I iterate through
      the "Chapter" elements and print out a TOC.

      Then, after the call to the named template, I simply process the
      document as always (i.e., using apply-templates or whatever). The
      result isn't pretty, but I wasn't trying to format the output, just
      get the output in the order I intended.

      Hope this helps.

      Regards,
      Frank.



      --- In XSL-FO@y..., "Anand" <a_pophale@y...> wrote:
      > Hi,
      > I am generating FO in a java program.I need to generate the 'table
      > of Contents' page at last in my java program.
      > But i want this page to appear as the first page in the PDF.
      > Can i do so???I mean generating the table of contents in the
      program
      > at last but making this page appear as the first page????
      >
      > Help pls.....
      > Ragards,
      > Anand
    Your message has been successfully submitted and would be delivered to recipients shortly.