Re: [xsl] <br/> in FO?

Subject: Re: [xsl] <br/> in FO?
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Wed, 27 Feb 2002 16:07:45 +0100
"Gustaf Liljegren" <gustaf.liljegren@xxxxxx> wrote:
> I've found a reason for a <br/> tag in my DTD, and I wonder how to implement
> it in the XSL (to FO).

You have already been told that the FO equivalent of HTML

 <p>Stuff<br>more stuff</p>

is preferably

   <fo:block>more stuff</fo:block>

You asked also how to get from something resembling the first to the
second. This is easy if the <br/> is a immediate child of the <p>, one
solution is

 <xsl:template match="p">
       <xsl:apply-templates select="node()[not(previous-sibling::br)]"/>
     <xsl:for-each select="br">

or you can handle it as a more general grouping problem, see the XSLT FAQ.
If the <br/> could be nested, for example

 <p><em>Important Stuff<br/>more important stuff</em></p>

i can only think of a multipass solution which pulls up the <br/> to direct
child level, thereby splitting all elements it contains. (Not recommended
hack: use disable-output-escaping to generate "lone" tags)

If the above becomes unpracticable, you can have the FO processor honor
linefeed by setting the linefeed-treatment property to preserve.
( That's more
of a kludge and may give unexpected results in some contexts, but you
might get a cheap shot. Inserting dummy blocks
 <xsl:template match="br">
(perhaps with some modifications) might also be a cheap if brittle solution
in you concrete case.


 XSL-List info and archive:

Current Thread