Reputation: 1
I've been asked to look at some old XSL-FO stylesheets and convert them to XSLT (HTML) so I can get an HTML output.
The only tool one I could find is the the one from RenderX XSLFOToHTML but am unsure how to use this free xsl. Prefer in .NET otherwise can try other languages as it's a once-off process only.
Have tried to use the XslCompiledTransform in .NET but not sure if that's the correct way to use it.
Any way to use the existing XSL-FO to render the xml data as HTML?
Upvotes: 0
Views: 104
Reputation: 8068
An approach that I have seen is for the XSLT that generates the FOs to also generate attributes (in a non-XSL namespace) on the FOs, where the attributes contain extra information that is used as hints in a second transformation that generates the (X)HTML. The attributes in an unrecognised namespace should not affect formatting the XSL-FO to make pages, although your XSL formatter might complain about seeing them.
Not quite as simple as running your XSL-FO through an existing library, I know.
Upvotes: 0
Reputation: 2115
An XSL-FO stylesheet is generally used to convert an XML file into XSL-FO, which can then be rendered by an FO rendering engine.
The conversion from XML to FO loses a lot of information that would be useful to have in the HTML. A big one is paragraph styles: where your XML may contain style names, the FO loses this and just retains the style properties. You want those style names in the HTML, because that allows you to use CSS for styling.
If you have the XML that was used to create the FO, it will often be easier to use that for an XML to HTML conversion, skipping the FO file entirely.
This conversion will be highly dependent on your XML structure. Depending on the source that created you XML you might be able to find an XSLT that can create an HTML file from your source. For example, I use Author-it, and there are XSLTs to create both XSLFO and HTML from the same XML output.
The RenderX solution tries to create an HTML plus CSS from an FO file. Because there is no paragraph style data in the FO, you're likely to end up with tons of CSS that do the styling for each paragraph individually.
Upvotes: 0