xsl-list
[Top] [All Lists]

XSLT and FO/FOP workarounding

2004-09-12 23:44:34
Hi,

I am using XML, XSLT and FOP to generate PDFs via XSL-FO. I have written
(and copied some stuff) a XSLT Stylesheet that transforms a HTML-like
Language to XSL-FO. Since FOP does not support the feature of FO that i can
the a Element that it never breaks with the next elements in 2 pages, I am
looking for a workaround. FOP supports that if the 2 elements are
transformed into a table:

XML:

<h1>title</h1>
<p>blahtext</p>

XSLT Template:

  <template match="h1">
   <fo:table table-layout="fixed" width="100%">
     <fo:table-column column-width="proportional-column-width()"/>
     <fo:table-body>
       <fo:table-row keep-with-next="always">
          <fo:table-cell>
                <fo:block xsl:use-attribute-sets="h1">
                        <xsl:apply-templates/>
                </fo:block>
          </fo:table-cell>
       </fo:table-row>
       <fo:table-row>
          <fo:table-cell>
            <xsl:apply-templates select="following-sibling::*"/>
          </fo:table-cell>
       </fo:table-row>
     </fo:table-body>
   </fo:table>

That works so far, but the problem is that now the element after the h1 tag
is processed two times: one in the h1 tag and one for the element itself.

So my question is how to exclude the next element via XSLT, something like:

<xsl:apply-templates
     select="*[not(preceding-sibling::*[1][self::h1])]"/>

One guy at the FOP Maling List told me that, but then FOP says:

[Fatal Error] :-1:-1: Premature end of file.
[ERROR] Premature end of file.)


My second Question is that i don't want to copy that stylesheet for each
heading (h1, h2, ...) and a general stylesheet for the headings would be
nice.


--

Sönke



<Prev in Thread] Current Thread [Next in Thread>