RE: breaking paragraphs and lines
Processing xml as text is kinda dangerous, especially when you are trying to fiddle with tags, I believe a better and more safe way is to handle \n\n stuff one stage earlier - during fo generation, that's pretty simple in xslt to tokenize string into blocks by any delimiter, trivial recursive template can do that. Very cool. I'm really surprised to see how powerful, though arcane, XSLT is. I naively thought that since I can't write imperatively, it's not a programming language, and if something isn't in the XSL spec, it's hard/impossible to do. But with the hint of the tokenizing stuff be trivial, I took the initiative I should have had before and found some 3rd libraries/algorithms to do the \n\n - fo:block/ conversion. Nice. content This is a long line that I want brokenbr/here. /content Search in the archive - that's faq, you can use either block/ or unicode line separator (#x2028;). Egads. Sorry for not following the best practice of searching the archives. This little topic of breaking is mentioned all over the place. xsl:template match=br xsl:text disable-output-escaping=yes lt;/fo:blockgt; lt;fo:blockgt; /xsl:text /xsl:template Wrong way, disable-output-escaping implies serialization of a result tree hence doesn't work otherwise, e.g. in mozilla, cocoon and fop. This facility is for generating text (e.g. SQL), but not markup. Huh. Interesting. Thanks for all the great information, things are going much smoother now. And sorry for not doing my homework first; I really should have known better. - Stephen
Re: breaking paragraphs and lines
Stephen Haberman wrote: 2) Run this result through a text manipulation program to replace all of the \n\n with /fo:blockfo:block to simulate a paragraph break. 3) Run this result through FOP. I'm thinking this will work once I get some scripts setup for it, but I'm just wondering if there is a better, within-FO/FOP way? Processing xml as text is kinda dangerous, especially when you are trying to fiddle with tags, I believe a better and more safe way is to handle \n\n stuff one stage earlier - during fo generation, that's pretty simple in xslt to tokenize string into blocks by any delimiter, trivial recursive template can do that. Also, a subset of this problem is that I was wanting to have a little bit of control over breaking from the XML file, e.g. force a line break. E.g.: content This is a long line that I want brokenbr/here. /content Search in the archive - that's faq, you can use either block/ or unicode line separator (#x2028;). xsl:template match=br xsl:text disable-output-escaping=yes lt;/fo:blockgt; lt;fo:blockgt; /xsl:text /xsl:template Wrong way, disable-output-escaping implies serialization of a result tree hence doesn't work otherwise, e.g. in mozilla, cocoon and fop. This facility is for generating text (e.g. SQL), but not markup. -- Oleg Tkachenko eXperanto team Multiconn Technologies, Israel
RE: breaking paragraphs and lines
You may want to try white-space-collapse=false as an attribute on your fo:block. There are also other white space attributes that may be useful. I'm not sure if all are supported in fop 0.20.4. -Original Message- From: Stephen Haberman [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 05, 2002 1:00 AM To: [EMAIL PROTECTED] Subject: breaking paragraphs and lines Hi, After much debate between whether I'd pick up LaTeX or XML-FO as my preferred environment for writing reports and the like, I went with XML-FO, FOP specifically, and have been enjoying it so far (ah, clean separate of data and presentation). However, I've run into a small problem I thought some others might be able to shed some light on. One of the things I liked about LaTeX was that two newlines were taken to mean separate paragraphs. As far as reproducing this before with FOP using XML/XSLT is that I'd probably have to: 1) Use Xalan to stitch XML/XSLT together. All text blocks would be in generic fo:blocks, e.g.: fo:block color=grey fo:block text text /fo:block /fo:block 2) Run this result through a text manipulation program to replace all of the \n\n with /fo:blockfo:block to simulate a paragraph break. 3) Run this result through FOP. I'm thinking this will work once I get some scripts setup for it, but I'm just wondering if there is a better, within-FO/FOP way? Also, a subset of this problem is that I was wanting to have a little bit of control over breaking from the XML file, e.g. force a line break. E.g.: content This is a long line that I want brokenbr/here. /content So I was going to use the same approach of a double fo:block to put the text in, but then have a match against br and insert an artificial block/inline-container type thing. The problem is that the match against br has to look like: xsl:template match=br xsl:text disable-output-escaping=yes lt;/fo:blockgt; lt;fo:blockgt; /xsl:text /xsl:template With straight Xalan, the result is exactly what I want... the closing, opening fo:block comes out in XML just like the previous opening fo:block. However, FOP seems to ignore this disable-output-escaping=yes attribute and I see the literal /fo:blockfo:block text in the PDF instead of it being interpreted it as FO commands. If I run the result of Xalan on the same XML/XSLT file through FOP via -fo, then it works great. Any insight into either of the two issues I'm pondering would be greatly appreciated. This is fun stuff. Thanks, Stephen This electronic transmission is strictly confidential to Smith Nephew and intended solely for the addressee. It may contain information which is covered by legal, professional or other privilege. If you are not the intended addressee, or someone authorized by the intended addressee to receive transmissions on behalf of the addressee, you must not retain, disclose in any form, copy or take any action in reliance on this transmission. If you have received this transmission in error, please notify the sender as soon as possible and destroy this message.
Re: breaking paragraphs and lines
Koes, Derrick wrote: You may want to try white-space-collapse=false as an attribute on your fo:block. There are also other white space attributes that may be useful. I'm not sure if all are supported in fop 0.20.4. None of them is supported in 0.20.4. J.Pietschmann