xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kindaian@gmail.com" <kinda...@gmail.com>
Subject Re: xml file with html code inside. How to make xml -> FOP -> pdf
Date Tue, 13 May 2008 23:14:33 GMT
Ok... I had a worse problem with the project i was involved...

I had to "clean-up" from MSOffice html to produce nice xml that would be 
"eaten" up by fop.

The issue was simply sorted with the use of tons of regexp, coupled with 
the use of tidy to convert the html to xml compliant html and then the 
final fase of transform to fo (i opted for doing it by hand, but xslt 
can also be used after you have a compliant xml).

I opted not to use xslt because of the ton of exceptions that MSOffice 
trash inserted into the html. And my cleanup system had more then 500 
lines of code! Full of regexps, replaces and the like.

My main problems where:

a) tags intermingled in the wrong order like < b > < i > < / b > < /
i > 
b) tags without start/end < br > < l i > (replaces)
c) uncompreensible stuff: all the css and meta tags MSOffice likes so 
much (regexp and replaces)
d) strange characters: unicode entities not declared, characters that 
break xml < & (regexp and replaces)

To conclude, yes, it was a work intensive task, but in the end, i had a 
clean html, with the formatings i needed to keep and those that i didn't 
needed removed. And when you have 5k pages of text to review, you don't 
go and tell the client: "correct the text and try again"... You do 
something to cleanup the problems (the great majority of them at least).

In the example you provided the following will break xml:

          <Title>Na zolotom kryl&apos;ce sideli</Title>

Most of the regexp and replaces i had to use was to replace stuff like 
that with the xml compliant ones (and/or define stuff as entity).

So, good luck on the project... and hope i was of some help...

P.S.- it was all done with php/tidy/javabridge/tomcat/fop btw and if you 
want an advice, twick the editor to allow only the stuff you need and 
try to use tidy for the rest, prolly you can sort out all the problems 
that way.

Tatiyana escreveu:
> Dear All,
>  Two months ago fop was completely new area for me but with great help of
> this forum I got our web application to use FOP transformation (xml -> xsl
> -> pdf) to make pdf  summary form for users.  Users were filling information
> fields and getting  standard  summary form in pdf format as a one of the 
> results. 
> Now  users are allowed to edit some of the text fields using tiny-mce editor
> and because of it  our xml file ended up having  some parts with html code
> inside.  Could somebody please  help me  to figure out what changes need to
> be done in the xml or xsl files to recognize html elements in xml file and
> show them in the pdf form properly?  I am using fop-0.94, jdk1.5.0.
> I am attaching the part of xsl file and xml file. The Title and Description
> elements of the Public Service node  and  International Service node will
> have html code inside. 
> Thank you. 
> http://www.nabble.com/file/p17214471/xsl_file.xsl.doc xsl_file.xsl.doc 
> http://www.nabble.com/file/p17214471/xml_file.xml.doc xml_file.xml.doc 

To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org

View raw message