XSL FO in a browser
XSL Formatting Objects are an XML dialect; why not render them to HTML by an XSLT stylesheet The translator is an attempt to materialize this idea. It has been prepared by RenderX development team as an add-on to our principal product, XEP. Please download the stylesheet and try to view your favorite XSL FO documents in a browser. Don't expect the result to be perfect — see below about limitations. If you plan to extend it to cover more or another version of the recommendation, please share your accomplishments with us.
A stylesheet like this may be used to reduce the complexity in a publishing system with multiple target media: you generate XSL FOs from semantic XML data, and use it as a source for all other presentation formats. When your data structure changes, you only have to modify XML-to-XSLFO stylesheet.
The stylesheet tries to convert XSL FO data into HTML+CSS1. CSS2 support is still rare among browsers, and hardly can be relyed upon. Even with CSS1, there are many discrepancies between MS Internet Explorer and Netscape Communicator. However, one can hardly do this task without using any stylesheet capabilities at all; so CSS1 seemed to be a common denominator.
It goes without saying that XSL FOs are much more powerful than HTML+CSS1; moreover, since paged media are organized differently from scrollable media, absolute similarity is not achievable. Therefore, the conversion aims mostly at giving the user a possibility to browse FO files, without pretending to preserve all formatting subtleties predisposed for quality printing. The task is also simplified by common vocabulary shared by XSL FO and CSS. With this premises, the problem can be solved by amazingly simple means: a 30 kb stylesheet does the bulk of the work.
Certainly, not everything can be achieved easily: for instance, calculating the inheritance propagation along the FO tree is a really tough task, as well as parsing CSS2 shorthands in XSLT. We didn't even attempted to tackle this: in our opinion, this is more easily achieved by a preprocessor. RenderX has such a preprocessor built into XEP; redirecting its output into a file gives us a "canonical" XSL FO document — with all shorthands expanded, inheritance propagated, length units normalized etc.
However, if your XSL FO documents don't make use of shorthands, multiple columns, absolutely positioned blocks and similar advanced features, the results of the conversion can be very close to the truth even without preprocessing, like in the examples given above. This requires special care while writing XSL FO stylesheets; but our experience shows it is relatively easy.
Privacy Policy Terms of Service
© 2004 RenderX