If you can modify the XSLT stylesheets a little, you could use normalize-space() to automatically remove the whitespace.
Something like this: <xsl:template match="title" mode="toc"> <fo:inline> <xsl:value-of select="normalize-space()"/> </fo:inline> </xsl:template> This won't work if you need to handle other kinds of elements in <title> tags besides text nodes though, like <title><b>Bold</b> text</title>. Another solution could be to run the XML input through a pretty-printer (or rather, the opposite of one) that removes this "insignificant" whitespace before applying the XSLT. I had a similar problem (but not specifically related to XSL-FO/FOP) where I wanted to remove extra whitespace from certain elements. I ended up writing this small utility: https://github.com/kibook/xml-utils/tree/master/xml-trimspace This is basically the reverse-pretty-printer described above, but it targets only specified elements, so that ones where "extra" whitespace might actually be significant are ignored. Example usage: [input.xml] <section> <title> Do <b>This</b> First </title> </section> $ xml-trimspace title < input.xml > output.xml [output.xml] <section> <title>Do <b>This</b> First</title> </section> Mark Giffin <m1...@earthlink.net> wrote: > I'm using FOP 2.3 with the DITA Open Toolkit. The <title> tags in DITA > topics are used in the table of contents in a PDF. Each table of > contents line is justified like this in the PDF: > > (left margin)Intro to > XYZ........................................................14(right margin) > (left margin)Setting Up > XYZ...................................................18(right margin) > > Most lines line up neatly on the right margin, but a few do not go to > the margin. The cause of a line that does not go all the way to the > right margin is a <title> tag with white space in it like this: > > <title> > Do This First > </title> > > This white space gets copied over to the XSL-FO produced by the DITA OT: > > height="150%"><fo:inline end-indent="14pt"> > Do This First > </fo:inline><fo:inline color="black" > keep-together.within-line="always" start-indent="-14pt"><fo:leader > color="black" leader-pattern="dots"/><fo:page-number-citation... > > And FOP renders this in the PDF like this, where the line does not go > all the way to the right margin: > > (left margin)Do This > First....................................................10 (right margin) > (left margin)Intro to > XYZ........................................................14(right margin) > (left margin)Setting Up > XYZ...................................................18(right margin) > > When I remove the whitespace in the XSL-FO, the line renders correctly, > all the way to the right margin. Both Antenna House and XEP render the > line correctly, ignoring the extraneous whitespace. This seems like a > FOP bug, is there a fix for this? Other than removing the whitespace? > > Thanks, > Mark --------------------------------------------------------------------- To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org