0
votes

I am nearly finished with a program to convert HTML to a PDF format. My issue is more specific than this program though. I have an XSL file that is giving me some grief when I try to use it with my program.

When using javax.xml.transform.Transformer.transform(source, result) I am getting the following warning and error messages due to my XSL styleSheet:

Compiler Warnings: Attribute 'leader-length' outside of element.
ERROR: 'Error(Unknown location): fo:list-item is not a valid child element of fo:block.'

The XSL file in question can be found here: http://webcoder.info/downloads/xhtml2fo.html

It is recommended by this tutorial: https://blogs.oracle.com/chrisf/entry/converting_html_to_pdf_using

Any assistance with what/where these error messages are coming from would be of great help! I am totally unfamiliar with XSL files.

Thank you so much.

EDIT: I suppose it is possible that something else is at fault. Using other XSL files, I get: "Document is empty (Something might be wrong with your XSLT stylesheet)" However, I am following the Oracle tutorial pretty much to the letter. Does he have a bug in his code? (Within the link above.)

EDIT2: I should have posted this in the first place: http://webcoder.info/downloads/xhtml2fo.xsl

If that link isn't working, I'll paste in the exact code here. Thanks!

EDIT3: This is some of the HTML I am trying to use as an example: http://docs.oracle.com/javase/1.4.2/docs/tooldocs/solaris/classpath.html

1
The actual error (not the warning) is an XSL-FO error. List items are trying to be output in an fo:block. Can you post your input HTML? - Daniel Haley
All but the simplest HTML pages are having issues with the list(s). What do I need to change in the XSL file? It seems very complicated and is a bit over my head. - BlackVegetable
I can't tell what needs to be changed until I can reproduce the error. The "classpath.html" in EDIT3 is not even close to well-formed so it can't be treated as XML which is what XSLT needs to be able to process. Do you have another example that can be processed by the XSLT? - Daniel Haley
Within the code, I am using HTMLCleaner (2.2) which is supposed to take HTML input and clean it up to be well-formed XML. Now the example is using v2.1 which may be a source of error, but I cannot find where a place to download 2.1 . I don't think it is working at the moment. - BlackVegetable
I can't help directly, but there are a strong recommendation to check "CSS+XHTML to PDF" technologies in your future work, see Why use XSL-FO instead of CSS2, for transform HTML into good PDF?. I was studying XSL-FO and CSS since of the post, and concluded that, for near future, the CSS2 for paged media is the best solution for any XML-Publishing pipeline. All XML tools (from author-tools and editors to mass-production tools) are compatible with XHTML and CSS standards, and there are many mature tools and people working with it. - Peter Krauss

1 Answers

1
votes

On the line before <fo:leader ... /> should not have that slash /.