xsl-list
[Top] [All Lists]

RE: XSLT and FO/FOP workarounding

2004-09-13 07:31:14
I believe it is "fo:keep-together". I also believe that the last version of 
Apache FOP that I used implemented this feature. 

Ofcourse, if FOP implements this "keep-together" functionality only for certain 
elements, then I might suggest encapsulating them into an element that does 
support it. 

I have used a similar work around once as you may observe from the xsl code 
snippet below. I have been able to use <fo:table-row> elements to be the 
"encapsulation" that keeps everything inside on the same page. Ofcourse, this 
leads to "nesting", but I have not found a better way of getting around, and so 
far have been very successful (lucky maybe) using a whole lot of nested tables 
under FO (Can anyone suggest some work arounds to prevent nested tables in FO, 
especially when you have diverse XML Tree content that has to be rendered 
"complete" ?)

<fo:table table-layout="fixed" width="190.5mm">
        <fo:table-column column-width="190.5mm"/>
        <fo:table-body>
                
                <fo:table-row keep-together="always">
                        <fo:table-cell>

                                <!--Nested Items -->

                                <fo:table table-layout="fixed" width="190mm" 
border="0">
                                        <fo:table-column column-width="190mm" 
vertical-align="top"/>
                                        <fo:table-body>

Hope that helps.
____________________________________________________________

Abhishek Sanwal
HP - Houston Campus


-----Original Message-----
From: Sönke Ruempler [mailto:ruempler(_at_)topconcepts(_dot_)com] 
Sent: Monday, September 13, 2004 1:45 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] XSLT and FO/FOP workarounding

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


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



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