Subject: [xsl] Converting XHTML to FO using XHTML2FO.xsl From: "Fleetwood, Brett \(DCS\)" <fleetwood.brett2@xxxxxxxxxxxxxxxx> Date: Thu, 19 Oct 2006 14:05:45 +0930 |
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>•</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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Setting the namespace in , Michael Burek | Thread | Re: [xsl] Converting XHTML to FO us, J.Pietschmann |
[xsl] Setting the namespace in a do, Michael Burek | Date | RE: [xsl] Adding an element of a sp, Hofman, Peter |
Month |