xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Uplawski <michael.uplaw...@uplawski.eu>
Subject Dynamic bookmark-tree
Date Mon, 25 Jul 2011 18:50:56 GMT
Hi there.

I know how to create a bookmark-tree in a PDF output-file. Now I hoped
to re-use my existing XSL-FO sheet for a diversity of XHTML-input-files
and try to avoid the inclusion of individual XSL-fragments just for the
purpose of creating an adaptation of the bookmark-tree.

So, what I do currently, is the creation of ids for the header-elements,
that I like to see represented in the bookmarks, like this:

<xsl:template match="h3">
    <xsl:variable name="h3_id">
       <xsl:value-of select="concat(&#39;h3_&#39;, .)" />
    </xsl:variable>
    <fo:block id="{$h3_id}" font-size="1.3em" font-weight="bold"
    font-style="italic" color="#003050" margin="1em 2em 0.5em 0"
    keep-with-next="always">
      <xsl:value-of select="." />
    </fo:block>
</xsl:template>

and hope to reuse them in the bookmark-tree. The best results, which is
still not acceptable, I produce with the code, that follows further below.
For simplicity I attach a screenshot of the generated and functional
bookmarks in the Okular-reader. Compared to the examples that I find
elsewhhere, I deem this a success already. But does one of you have a
hint on how I can finally "break" out of the for-each structure or
rather: in which way can I avoid to handle those nodes, which are
*siblings of the current node* but follow a node of a different type.

The problem clearly arises from the fact, that I process XHTML-code and
the usual structure of such a document:
<h1></h1><h2></h2><h3></h3><h2></h2><h3></h3>...

Thank you for any input on this. ;-)

Michael.

------ XSL/FO ------
<fo:bookmark-tree>
        <xsl:for-each select="//h1">
          <xsl:variable name="id">
            <xsl:value-of select="concat(&#39;h1_&#39;, .)" />
          </xsl:variable>
          <fo:bookmark>
            <xsl:attribute name="internal-destination">
              <xsl:value-of select="concat(&#39;h1_&#39;, .)" />
            </xsl:attribute>
            <fo:bookmark-title font-weight="bold">
              <xsl:value-of select="." />
            </fo:bookmark-title>
              <xsl:for-each select="following-sibling::h2">
                  <fo:bookmark>
                    <xsl:attribute name="internal-destination">
                      <xsl:value-of select="concat(&#39;h2_&#39;, .)" />
                    </xsl:attribute>
                    <fo:bookmark-title font-weight="bold">
                      <xsl:value-of select="." />
                    </fo:bookmark-title>
                    <xsl:variable name="h2_id">
                      <xsl:value-of select="concat(&#39;h2_&#39;, .)" />
                    </xsl:variable>
                    <xsl:for-each select="following-sibling::h3">			
                        <fo:bookmark>
                          <xsl:attribute name="internal-destination">
                            <xsl:value-of select="concat(&#39;h3_&#39;,
.)" />
                          </xsl:attribute>
                          <fo:bookmark-title font-weight="bold">
                            <xsl:value-of select="." />
                          </fo:bookmark-title>
                        </fo:bookmark>
                    </xsl:for-each>
                  </fo:bookmark>
              </xsl:for-each>
          </fo:bookmark>
        </xsl:for-each>
      </fo:bookmark-tree>
-- 
PSE send your e-mail encrypted. My GnuPG/OpenPGP-key:
2048 bits D/74a227d5 g/4e580a13 [expires: 2012-04-08]
fingerprint: 1E6E 87CF B2F5 EBBC ACB6  7120 0A44 0972 74A2 27D5

Mime
View raw message