Re: [xep-support] Creating a Table of Contents from an HTML file being transformed using XSL to FO

From: Kenneth Aitken (kenneth_aitken@freenet.de)
Date: Thu Sep 30 2004 - 00:01:03 PDT

  • Next message: Geurt Lagemaat: "[xep-support] XEP and Saxon8"

    Hi Werner,

    Our problem is that we have already adapted an Antenna House stylesheet and it works fine for us except for a couple of problems. Creating a 3-level table of contents is the most urgent issue and I do not have time to create a completely new XSLT stylesheet from scratch.
    We created a TOC with h1 and h2 from XHTML by using the<div> tag to nest h2. But going from h2 to h3 seems to be much more difficult, and as yet, we have not succeeded. Below is the code for creating a TOC, with h1 and h2 (the block after each h1 is contained in a <div class = "x"></div> block).

    Any ideas?

    Greetings,

    Kenneth

      <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
           TOC
      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
      
    <xsl:template match="html:h1" mode="toc">
      <fo:block text-align-last="justify" font-size="14pt" space-before="8mm" space-after="4mm">
        <fo:basic-link internal-destination="{generate-id(.)}">

       <xsl:apply-templates/>
        </fo:basic-link>
        <xsl:text> </xsl:text>
        <fo:leader leader-length.minimum="12pt" leader-length.optimum="40pt"
                   leader-length.maximum="100%" leader-pattern="space"/>
        <xsl:text> </xsl:text>
        <fo:page-number-citation ref-id="{generate-id(.)}"/>
      </fo:block>
    <!-- the following selects *all* <h2> elements that are on the same level as the <h1> element -->
      <xsl:apply-templates select="../html:h2" mode="toc"/>
    </xsl:template>
      
    <xsl:template match="html:h2" mode="toc">
      <fo:block start-indent="10mm" text-align-last="justify" font-size="10pt">
        <fo:basic-link internal-destination="{generate-id(.)}">
          <xsl:apply-templates/>
        </fo:basic-link>
        <xsl:text> </xsl:text>
        <fo:leader leader-length.minimum="12pt" leader-length.optimum="40pt"
                   leader-length.maximum="100%" leader-pattern="dots"/>
        <xsl:text> </xsl:text>
        <fo:page-number-citation ref-id="{generate-id(.)}"/>
      </fo:block>
    </xsl:template>

    *********** REPLY SEPARATOR ***********

    On 29.09.2004 at 23:12 Werner Donné wrote:

    >Kenneth,
    >
    >Unfortunately the style sheet I have sent only transforms XHTML into
    >XHTML. It just adds a few things to it. Producing XSL-FO with an XSLT
    >style sheet is possible but complex. You can find an example at
    >http://www.antennahouse.com/XSLsample/XSLsample.htm.
    >
    >The disadvantage of this approach, however, is that you have to choose
    >a particular style for your XHTML documents. Starting from an existing
    >set of XSLT files, it is not easy to do customisations. That is because
    >XSLT is not very suitable for a kind of library approach. You can't
    >easily say, for example, "do what you normally do and this little bit
    >different", without knowlegde of the style sheets you are customising.
    >
    >Freedom of style is given to XHTML through CSS, which is very customisable
    >because of its cascading mechanism. It is also less powerful in addressing
    >parts of your input document, as well as in producing a formatted result.
    >You can obtain XSL-FO, however, by using CSSToXSLFO. It can convert an
    >XHTML document with a CSS style sheet into XSL-FO. Since you are an XEP
    >user, you can use the alternative packaging of CSSToXSLFO that feeds
    >the XSL-FO straight into XEP, giving you a XHTML/CSS to PDF or PostScript
    >converter. We do this in our project for reports up to 2000 pages. The
    >solution is quite performant, if you give it enough memory, which is not
    >a problem on a big server.

    -------------------
    (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
    in the body of the message to majordomo@renderx.com from the address
    you are subscribed from.
    (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html



    This archive was generated by hypermail 2.1.5 : Thu Sep 30 2004 - 00:22:44 PDT