Using XSL-FO and HTML?

I am trying to convert some XML data to HTML with XSLT for my undergraduate dissertation.

My professor wants me to consider XSL-FO too, or at least to write some kind of word about it. But I really love that.

So my questions are:

Is it possible to combine FO with HTML? Can I use FO istead HTML and CSS? If so, how will my browser do this? Are there any examples / tutorials on how to convert xml to web pages using FO?

+4
source share
2 answers

XSL-FO is intended only for display in PDF format (this is not entirely true, but you can take it as a guide). So HTML output and FO output are not related. From your XML source, you can use XSLT to generate XHTML or XSL-FO, but not both at the same time.

See, for example, DocBook. It comes with several ready-to-use XSLT stylesheets, one for HTML output and one for PDF (via Apache Fop). If you are satisfied with the result, another question may arise.

+5
source

Generating XSL-FO and XHTML from XSLT is not necessarily any choice.

XSL-FO is commonly used to create PDFs. To do this, you need the XSL-FO engine , for example FOP , RenderX , Antenna House , IBex , etc. However, you can convert XSL-FO to XHTML and then render in a browser.

Generally, it would be useless if your XSLT created XSL-FO and then converted to XHTML (just create XHTML directly) if you do not want to create both output formats (PDF and XHTML) with reduced effort.

** XSL-FO and XHTML can be created at the same time without supporting two complete sets of styles to produce similar output in different dictionaries **.

Instead of choosing between one or the other format or having two clearly distinguishable (but similar) style libraries, you can create your main style library to create either XSL-FO or XHTML , and then use the second transform to convert from XSL-FO in XHTML and vice versa. There are existing XSLT style sheets that you can use to do this.

In the past, I designed XSL-FO stylesheets , and then used the Render-X Stylesheet FO2HTML to convert XSL-FO output to XHTML . It converts the <block> elements to <div> , <inline> to <span> , etc.

I have not used them before, but you can also use HTML2FO style sheets to convert out XHTML to XSL-FO .

Out of the box, you can get surprisingly similar output in both formats, while maintaining one XSLT library for one specific output format.

If you don't need to customize the output a bit (for example, different header content for XHTML ), you just need to import / expand the conversion stylesheets and override the appropriate template for diverging content. This simplifies maintenance, so you don’t have to worry about updating multiple sets of stylesheets with essentially the same information.

+8
source

Source: https://habr.com/ru/post/1308457/


All Articles