xsl-list
[Top] [All Lists]

[xsl] Converting XHTML to FO using XHTML2FO.xsl

2006-10-18 21:36:09

G'day all, I'm using FCKeditor in a JSP page in my application to
capture some formatted text. I then clean this up with Jtidy into XHTML.
I'm then transforming this into FO using the XHTML2FO.xsl. 
What I'm attempting to do is one thing on most <br> tags and another
thing on the last <br> tag under a <li> or <p> tag (I've bolded these in
the example below). My problem is the <br> tag can be n deeply nested
under formatting tags such as <strong>, <em>, etc. 
An example of my XHTML file is; 
<?xml version="1.0" encoding="UTF-8"?>
<div>
<ul>
<li>
<strong>asdfa df<br/>asdfasdf<br/><br/>asdfasdfasdf<br/><br/></strong>
</li>
<li>
<strong>asdfasdfasdfadsfasdfasdf</br></strong></br>
</li>
<li>
asdf<br/>
</li>
<li>
<strong style="font-size: 150%">asdfasdfasdfasdfa<br/></strong>
</li>
<li>
<strong style="font-size: 150%">asdf asdf asdf asdf asdf asdf asdfasdf
asdfasdf asdf asd fasdfas d</strong>
<strong style="font-size:
150%">dfasdfasdfasdfasdfasdfasdfasdfasdfasdf<br/></strong>
</li>
<li>
<strong style="font-size: 150%"><em>asdfasdf</br></em></strong>
</li>
</ul>
<p>Mr Person<br/>
<strong>CHIEF EXECUTIVE</strong>
<br/>
<strong>this is some text<br/></strong>
</p>
</div>
he's a portion of the XHTML2FO.xsl stylesheet, i've included the match
on the last <br> tag but this only works when the <br> tags are the same
depth; 
<!-- ============================================
We handle a break element by inserting an empty <fo:block>.
=============================================== -->
<xsl:template match="br">
<fo:block> </fo:block>
</xsl:template>
<xsl:template match="br[position()=last()]">
<fo:block><fo:leader/></fo:block>
</xsl:template>
<xsl:template match="ul">
<fo:list-block provisional-distance-between-starts="10mm"
provisional-label-separation="1mm"space-before="6pt" space-after="6pt">
<xsl:apply-templates/>
</fo:list-block>
</xsl:template>
<!-- ============================================
List items inside unordered lists are easy; we just have to use the
correct Unicode character for the bullet. 
=============================================== -->
<xsl:template match="ul/li">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>&#x2022;</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:template>
I'm thinking that an XPath expression will be able to do my match, any
help on this would be much appreciated. 
Thanks in advance, 

 Brett Fleetwood

--~------------------------------------------------------------------
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>