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

From: Werner DonnÚ (werner.donne@re.be)
Date: Thu Sep 30 2004 - 01:21:57 PDT

  • Next message: Lars J°rgen Tvedt: "[xep-support] Type 1 font looses special characters"

    Kenneth,

    On the spot where you want to generate the table of contents you can do

    <xsl:apply-templates select="//*[namespace-uri() = 'http://www.w3.org/1999/xhtml' and
        (local-name() = 'h1' or local-name() = 'h2' or local-name() = 'h3')]" mode="toc"/>

    This will encounter the headings in document order, meaning you can write a
    template for each level that depends on nothing else. It is also independent
    of the level of nesting.

    Werner.

    Kenneth Aitken wrote:
    > 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
    >
    >

    -- 
    Werner DonnÚ  --  Re BVBA
    Engelbeekstraat 8
    B-3300 Tienen
    tel: (+32) 486 425803	e-mail: werner.donne@re.be
    -------------------
    (*) 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 - 01:43:38 PDT