RE: [xsl] XSLT and FO/FOP workarounding

Subject: RE: [xsl] XSLT and FO/FOP workarounding
From: "SANWAL, ABHISHEK (HP-Houston)" <abhishek.sanwal@xxxxxx>
Date: Mon, 13 Sep 2004 09:31:14 -0500
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: Svnke Ruempler [mailto:ruempler@xxxxxxxxxxxxxxx]
Sent: Monday, September 13, 2004 1:45 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
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.


--

Svnke

Current Thread